修补一些bug
This commit is contained in:
97
Convention/Resources/Master.mixer
Normal file
97
Convention/Resources/Master.mixer
Normal file
@@ -0,0 +1,97 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!244 &-6002849048023987392
|
||||
AudioMixerEffectController:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_EffectID: ceab011db4879ba41ad52c5eeea147e4
|
||||
m_EffectName: Pitch Shifter
|
||||
m_MixLevel: cd15d53e9c8be5142b26dca79aa9887e
|
||||
m_Parameters:
|
||||
- m_ParameterName: Pitch
|
||||
m_GUID: a397a80ee8dae584d8bf0cca5579369b
|
||||
- m_ParameterName: FFT size
|
||||
m_GUID: a4a905f7c52f4b94e99ba9e6040d409e
|
||||
- m_ParameterName: Overlap
|
||||
m_GUID: 7671900607ffbac4ca75e8a96523d3a2
|
||||
- m_ParameterName: Max channels
|
||||
m_GUID: 088381d8f17bda842aa440a34123a808
|
||||
m_SendTarget: {fileID: 0}
|
||||
m_EnableWetMix: 0
|
||||
m_Bypass: 0
|
||||
--- !u!241 &24100000
|
||||
AudioMixerController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Master
|
||||
m_OutputGroup: {fileID: 0}
|
||||
m_MasterGroup: {fileID: 24300002}
|
||||
m_Snapshots:
|
||||
- {fileID: 24500006}
|
||||
m_StartSnapshot: {fileID: 24500006}
|
||||
m_SuspendThreshold: -80
|
||||
m_EnableSuspend: 1
|
||||
m_UpdateMode: 0
|
||||
m_ExposedParameters:
|
||||
- guid: b0ebf2901c1aeb344b2a87ae242df1b5
|
||||
name: MasterPitch
|
||||
- guid: a397a80ee8dae584d8bf0cca5579369b
|
||||
name: PitchShifterPitch
|
||||
m_AudioMixerGroupViews:
|
||||
- guids:
|
||||
- a3c32b9d162f19a419568f094319d0c7
|
||||
name: View
|
||||
m_CurrentViewIndex: 0
|
||||
m_TargetSnapshot: {fileID: 24500006}
|
||||
--- !u!243 &24300002
|
||||
AudioMixerGroupController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Master
|
||||
m_AudioMixer: {fileID: 24100000}
|
||||
m_GroupID: a3c32b9d162f19a419568f094319d0c7
|
||||
m_Children: []
|
||||
m_Volume: 068965e8a514a9a44863437ee299ef13
|
||||
m_Pitch: b0ebf2901c1aeb344b2a87ae242df1b5
|
||||
m_Send: 00000000000000000000000000000000
|
||||
m_Effects:
|
||||
- {fileID: 24400004}
|
||||
- {fileID: -6002849048023987392}
|
||||
m_UserColorIndex: 0
|
||||
m_Mute: 0
|
||||
m_Solo: 0
|
||||
m_BypassEffects: 0
|
||||
--- !u!244 &24400004
|
||||
AudioMixerEffectController:
|
||||
m_ObjectHideFlags: 3
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name:
|
||||
m_EffectID: a8d7e4c02308ae44f9fc51dc9de13a3e
|
||||
m_EffectName: Attenuation
|
||||
m_MixLevel: 529a1bce94cdf3b43af8d5ba16028c5c
|
||||
m_Parameters: []
|
||||
m_SendTarget: {fileID: 0}
|
||||
m_EnableWetMix: 0
|
||||
m_Bypass: 0
|
||||
--- !u!245 &24500006
|
||||
AudioMixerSnapshotController:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Snapshot
|
||||
m_AudioMixer: {fileID: 24100000}
|
||||
m_SnapshotID: 92ac84973c010d04fbc3a98fc121b6ce
|
||||
m_FloatValues:
|
||||
b0ebf2901c1aeb344b2a87ae242df1b5: 1
|
||||
a397a80ee8dae584d8bf0cca5579369b: 1
|
||||
m_TransitionOverrides: {}
|
8
Convention/Resources/Master.mixer.meta
Normal file
8
Convention/Resources/Master.mixer.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8d8c64a4848e9d849a8e2eddaae1c049
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 24100000
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -18,7 +18,7 @@ GameObject:
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &6739692666707570911
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@@ -482,7 +482,7 @@ MonoBehaviour:
|
||||
m_Calls: []
|
||||
m_text: Assets
|
||||
m_isRightToLeft: 0
|
||||
m_fontAsset: {fileID: 11400000, guid: 3994fc09180bdb54484d538bb5d127b4, type: 2}
|
||||
m_fontAsset: {fileID: 0}
|
||||
m_sharedMaterial: {fileID: -8493678639131513909, guid: 3994fc09180bdb54484d538bb5d127b4, type: 2}
|
||||
m_fontSharedMaterials: []
|
||||
m_fontMaterial: {fileID: 0}
|
||||
|
@@ -62,7 +62,7 @@ MonoBehaviour:
|
||||
m_ChildControlWidth: 0
|
||||
m_ChildControlHeight: 0
|
||||
m_ChildScaleWidth: 0
|
||||
m_ChildScaleHeight: 0
|
||||
m_ChildScaleHeight: 1
|
||||
m_ReverseArrangement: 0
|
||||
--- !u!114 &2447206846939804910
|
||||
MonoBehaviour:
|
||||
|
@@ -1128,7 +1128,7 @@ PrefabInstance:
|
||||
- target: {fileID: 3241788778710343315, guid: 37924db2d27cd6e49bf8002531a08095, type: 3}
|
||||
propertyPath: m_fontAsset
|
||||
value:
|
||||
objectReference: {fileID: 11400000, guid: 3994fc09180bdb54484d538bb5d127b4, type: 2}
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 3241788778710343315, guid: 37924db2d27cd6e49bf8002531a08095, type: 3}
|
||||
propertyPath: m_fontSizeMax
|
||||
value: 12
|
||||
|
File diff suppressed because one or more lines are too long
8
Convention/[IL2CPP].meta
Normal file
8
Convention/[IL2CPP].meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f28191148868da4eb919b1b1d5c2399
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
254
Convention/[IL2CPP]/ProcessLauncher.cs
Normal file
254
Convention/[IL2CPP]/ProcessLauncher.cs
Normal file
@@ -0,0 +1,254 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.InteropServices;
|
||||
using Debug = UnityEngine.Debug;
|
||||
|
||||
// ReSharper disable InconsistentNaming
|
||||
|
||||
#if PLATFORM_WINDOWS
|
||||
|
||||
namespace Convention.IL2CPP
|
||||
{
|
||||
/// <summary>
|
||||
/// <para>rainwl/CreateAndTerminateProcessWithIL2CPP: In Unity,if we use IL2CPP as scripting backend,System.Diagnotics.Process could not be supported (github.com)
|
||||
/// </para>
|
||||
/// <para>When developing with Unity, if you choose IL2CPP as the scripting backend, it brings along several challenges.
|
||||
/// First, code that relies on C# reflection is not supported. Common libraries like Protocol Buffers and log4net, which use reflection, require modifications.
|
||||
/// </para>
|
||||
/// <para>Secondly, the System.Diagnostics.Process namespace is also unsupported.If you need to launch an external application, an alternative approach is necessary.Unfortunately, Unity lacks sufficient resources to modify IL2CPP to support Process. The solutions available online are quite scarce, with only one GitHub repository providing a potential workaround.However, this solution is not readily usable due to various issues.
|
||||
/// Given this situation, I've developed a method utilizing kernel32 API calls to achieve launching and closing external processes, as well as terminating processes with specific names.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
public static class ProcessLauncher
|
||||
{
|
||||
#region DLL Import
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
|
||||
private static extern bool CreateProcessW(
|
||||
string lpApplicationName,
|
||||
string lpCommandLine,
|
||||
IntPtr lpProcessAttributes,
|
||||
IntPtr lpThreadAttributes,
|
||||
bool bInheritHandles,
|
||||
uint dwCreationFlags,
|
||||
IntPtr lpEnvironment,
|
||||
string lpCurrentDirectory,
|
||||
[In] ref StartUpInfo lpStartupInfo,
|
||||
out ProcessInformation lpProcessInformation
|
||||
);
|
||||
|
||||
[DllImport("kernel32.dll", SetLastError = true)]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
private static extern bool TerminateProcess(IntPtr hProcess, uint uExitCode);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
// ReSharper disable once IdentifierTypo
|
||||
public static extern IntPtr CreateToolhelp32Snapshot(uint dwFlags, uint th32ProcessID);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern bool Process32First(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern bool Process32Next(IntPtr hSnapshot, ref PROCESSENTRY32 lppe);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
[return: MarshalAs(UnmanagedType.Bool)]
|
||||
public static extern bool CloseHandle(IntPtr hObject);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern IntPtr OpenProcess(uint dwDesiredAccess, bool bInheritHandle, uint dwProcessId);
|
||||
|
||||
#endregion
|
||||
|
||||
#region Fields
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
private struct PROCESSENTRY32
|
||||
{
|
||||
public uint dwSize;
|
||||
public uint cntUsage;
|
||||
public uint th32ProcessID;
|
||||
public IntPtr th32DefaultHeapID;
|
||||
public uint th32ModuleID;
|
||||
public uint cntThreads;
|
||||
public uint th32ParentProcessID;
|
||||
public int pcPriClassBase;
|
||||
public uint dwFlags;
|
||||
|
||||
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
|
||||
public string szExeFile;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
|
||||
private struct StartUpInfo
|
||||
{
|
||||
public int cb;
|
||||
public string lpReserved;
|
||||
public string lpDesktop;
|
||||
public string lpTitle;
|
||||
public int dwX;
|
||||
public int dwY;
|
||||
public int dwXSize;
|
||||
public int dwYSize;
|
||||
public int dwXCountChars;
|
||||
public int dwYCountChars;
|
||||
public int dwFillAttribute;
|
||||
public int dwFlags;
|
||||
public short wShowWindow;
|
||||
public short cbReserved2;
|
||||
public IntPtr lpReserved2;
|
||||
public IntPtr hStdInput;
|
||||
public IntPtr hStdOutput;
|
||||
public IntPtr hStdError;
|
||||
}
|
||||
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct ProcessInformation
|
||||
{
|
||||
public IntPtr hProcess;
|
||||
public IntPtr hThread;
|
||||
public int dwProcessId;
|
||||
public int dwThreadId;
|
||||
}
|
||||
|
||||
// ReSharper disable once FieldCanBeMadeReadOnly.Local
|
||||
public static List<ProcessInformation> processList = new List<ProcessInformation>();
|
||||
|
||||
#endregion
|
||||
|
||||
#region Process Methods
|
||||
|
||||
public static ProcessInformation StartExternalProcess(string programPath, string arguments, string currentDirectory)
|
||||
{
|
||||
// const string programPath = @"E:\FleX-1.2.0\NvFlexDemoReleaseCUDA_x64.exe";
|
||||
// const string arguments = "-surgeryType=0";
|
||||
|
||||
var startupInfo = new StartUpInfo();
|
||||
startupInfo.cb = Marshal.SizeOf(startupInfo);
|
||||
|
||||
var success = CreateProcessW(
|
||||
programPath,
|
||||
arguments,
|
||||
IntPtr.Zero,
|
||||
IntPtr.Zero,
|
||||
false,
|
||||
0,
|
||||
IntPtr.Zero,
|
||||
currentDirectory,
|
||||
ref startupInfo,
|
||||
out var processInfo
|
||||
);
|
||||
|
||||
if (success)
|
||||
{
|
||||
processList.Add(processInfo);
|
||||
return processInfo;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("Unable to start process, error code: " + Marshal.GetLastWin32Error());
|
||||
}
|
||||
}
|
||||
|
||||
public static void TerminateExternalProcess(ProcessInformation processInfo)
|
||||
{
|
||||
// ReSharper disable once InvertIf
|
||||
if (processInfo.hProcess != IntPtr.Zero)
|
||||
{
|
||||
var success = TerminateProcess(processInfo.hProcess, 0);
|
||||
if (success)
|
||||
{
|
||||
Debug.Log("The external process is shut down");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Unable to shut down external process, error code:" + Marshal.GetLastWin32Error());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void CloseProcessByName(string processName, IntPtr snapShot)
|
||||
{
|
||||
var processEntry = new PROCESSENTRY32
|
||||
{
|
||||
dwSize = (uint)Marshal.SizeOf(typeof(PROCESSENTRY32))
|
||||
};
|
||||
|
||||
// ReSharper disable once InvertIf
|
||||
if (Process32First(snapShot, ref processEntry))
|
||||
{
|
||||
do
|
||||
{
|
||||
// ReSharper disable once InvertIf
|
||||
if (processEntry.szExeFile.Equals(processName, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
var processHandle = OpenProcess(processEntry.th32ProcessID);
|
||||
// ReSharper disable once InvertIf
|
||||
if (processHandle != IntPtr.Zero)
|
||||
{
|
||||
TerminateProcess(processHandle, 0); // Terminate the process
|
||||
CloseHandle(processHandle);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} while (Process32Next(snapShot, ref processEntry));
|
||||
}
|
||||
}
|
||||
|
||||
private static IntPtr OpenProcess(uint processId)
|
||||
{
|
||||
const uint processTerminate = 0x0001;
|
||||
return OpenProcess(processTerminate, false, processId);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Test Methods
|
||||
|
||||
//private ProcessInformation _processInfo1;
|
||||
//private ProcessInformation _processInfo2;
|
||||
|
||||
//private void Update()
|
||||
//{
|
||||
// if (Input.GetKeyDown(KeyCode.A))
|
||||
// {
|
||||
// _processInfo1 =
|
||||
// StartExternalProcess(@"D:\Projects\Log[]\LogInsights\src\LogInsights\bin\x64\Release\LogInsights.exe",
|
||||
// null, null);
|
||||
// _processInfo2 = StartExternalProcess(@"C:\Windows\System32\cmd.exe", null, null);
|
||||
// }
|
||||
|
||||
// if (Input.GetKeyDown(KeyCode.B))
|
||||
// {
|
||||
// TerminateExternalProcess(_processInfo1);
|
||||
// }
|
||||
|
||||
// if (Input.GetKeyDown(KeyCode.C))
|
||||
// {
|
||||
// TerminateExternalProcess(_processInfo2);
|
||||
// }
|
||||
|
||||
// // ReSharper disable once InvertIf
|
||||
// if (Input.GetKeyDown(KeyCode.D))
|
||||
// {
|
||||
// var snapshot = CreateToolhelp32Snapshot(2, 0);
|
||||
// CloseProcessByName("cmd.exe", snapshot);
|
||||
// CloseProcessByName("LogInsights.exe", snapshot);
|
||||
// CloseHandle(snapshot);
|
||||
// }
|
||||
//}
|
||||
|
||||
//private void OnDestroy()
|
||||
//{
|
||||
// foreach (var processInfo in processList)
|
||||
// {
|
||||
// TerminateProcess(processInfo.hProcess, 0);
|
||||
// Debug.Log("The external process is shut down,error code: " + processInfo.dwProcessId);
|
||||
// }
|
||||
//}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
11
Convention/[IL2CPP]/ProcessLauncher.cs.meta
Normal file
11
Convention/[IL2CPP]/ProcessLauncher.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c723354975719bd4abffd154b6d1fa3d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -192,9 +192,7 @@ namespace Convention
|
||||
get
|
||||
{
|
||||
if (source == null)
|
||||
source = this.SeekComponent<AudioSource>();
|
||||
if (source == null)
|
||||
source = this.gameObject.AddComponent<AudioSource>();
|
||||
source = this.GetOrAddComponent<AudioSource>();
|
||||
return source;
|
||||
}
|
||||
set
|
||||
@@ -251,7 +249,7 @@ namespace Convention
|
||||
}
|
||||
public override void SetSpeed(float speed)
|
||||
{
|
||||
SetSpeed(speed, 1.0f, "Master", "MasterPitch", "PitchShifterPitch", true);
|
||||
SetSpeed(speed, "Master", "MasterPitch", "PitchShifterPitch", true);
|
||||
}
|
||||
public override void SetVolume(float volume)
|
||||
{
|
||||
@@ -259,7 +257,6 @@ namespace Convention
|
||||
}
|
||||
|
||||
public void SetSpeed(float speed,
|
||||
float TargetPitchValue,
|
||||
string TargetGroupName,
|
||||
string TargetPitch_Attribute_Name,
|
||||
string TargetPitchshifterPitch_Attribute_Name,
|
||||
@@ -267,19 +264,19 @@ namespace Convention
|
||||
{
|
||||
if (Mixer != null)
|
||||
{
|
||||
if (TargetPitchValue > 0)
|
||||
if (speed > 0)
|
||||
{
|
||||
Source.pitch = 1;
|
||||
Mixer.SetFloat(TargetPitch_Attribute_Name, TargetPitchValue);
|
||||
float TargetPitchshifterPitchValue = 1.0f / TargetPitchValue;
|
||||
Mixer.SetFloat(TargetPitch_Attribute_Name, speed);
|
||||
float TargetPitchshifterPitchValue = 1.0f / speed;
|
||||
Mixer.SetFloat(TargetPitchshifterPitch_Attribute_Name, TargetPitchshifterPitchValue);
|
||||
Source.outputAudioMixerGroup = Mixer.FindMatchingGroups(TargetGroupName)[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
Source.pitch = -1;
|
||||
Mixer.SetFloat(TargetPitch_Attribute_Name, -TargetPitchValue);
|
||||
float TargetPitchshifterPitchValue = -1.0f / TargetPitchValue;
|
||||
Mixer.SetFloat(TargetPitch_Attribute_Name, -speed);
|
||||
float TargetPitchshifterPitchValue = -1.0f / speed;
|
||||
Mixer.SetFloat(TargetPitchshifterPitch_Attribute_Name, TargetPitchshifterPitchValue);
|
||||
Source.outputAudioMixerGroup = Mixer.FindMatchingGroups(TargetGroupName)[0];
|
||||
}
|
||||
@@ -424,6 +421,7 @@ namespace Convention
|
||||
BandNegativeCheck();
|
||||
|
||||
}
|
||||
|
||||
//void Update()
|
||||
//{
|
||||
// float[] spectrum = new float[256];
|
||||
|
@@ -90,11 +90,14 @@ namespace Convention
|
||||
isFocus = false;
|
||||
if (Keyboard.current[Key.LeftCtrl].isPressed && Keyboard.current[Key.LeftShift].isPressed)
|
||||
{
|
||||
TargetFollow.localEulerAngles = new(0, TargetFollow.eulerAngles.y, 0);
|
||||
if(Keyboard.current[Key.Z].wasPressedThisFrame)
|
||||
if(Keyboard.current[Key.Z].isPressed)
|
||||
{
|
||||
TargetFollow.localPosition = Vector3.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
TargetFollow.localEulerAngles = new(0, TargetFollow.eulerAngles.y, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
@@ -2144,5 +2145,21 @@ namespace Convention
|
||||
return Activator.CreateInstance(type);
|
||||
}
|
||||
}
|
||||
|
||||
public static partial class ConventionUtility
|
||||
{
|
||||
public static byte[] ReadAllBytes(this BinaryReader reader)
|
||||
{
|
||||
const int bufferSize = 4096;
|
||||
using (var ms = new MemoryStream())
|
||||
{
|
||||
byte[] buffer = new byte[bufferSize];
|
||||
int count;
|
||||
while ((count = reader.Read(buffer, 0, buffer.Length)) != 0)
|
||||
ms.Write(buffer, 0, count);
|
||||
return ms.ToArray();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -127,12 +127,17 @@ namespace Convention
|
||||
public class InternalProperty
|
||||
{
|
||||
public Dictionary<string, object> property = new();
|
||||
public Dictionary<string, object> find = new();
|
||||
}
|
||||
|
||||
public GlobalConfig SaveProperties()
|
||||
{
|
||||
var configFile = this.ConfigFile;
|
||||
configFile.SaveAsJson(new InternalProperty() { property = data_pair });
|
||||
configFile.SaveAsJson(new InternalProperty()
|
||||
{
|
||||
property = data_pair,
|
||||
find = data_find
|
||||
});
|
||||
return this;
|
||||
}
|
||||
public GlobalConfig LoadProperties()
|
||||
@@ -196,14 +201,18 @@ namespace Convention
|
||||
Log("Error", message);
|
||||
}
|
||||
|
||||
private Dictionary<string, object> data_find = new();
|
||||
|
||||
public object FindItem(string key, object @default = null)
|
||||
{
|
||||
if (Contains(key))
|
||||
{
|
||||
data_find.Remove(key);
|
||||
return this[key];
|
||||
}
|
||||
else
|
||||
{
|
||||
data_find[key] = @default;
|
||||
LogPropertyNotFound(key, @default);
|
||||
return @default;
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Convention
|
||||
{
|
||||
@@ -54,6 +55,11 @@ namespace Convention
|
||||
public readonly Func<T, T, int> _comparer_func = null;
|
||||
public readonly Comparator _comparator = Comparator.less;
|
||||
|
||||
public T GetTP(float p)
|
||||
{
|
||||
return _elements[(int)(Mathf.Clamp01(p) * _elements.Length)];
|
||||
}
|
||||
|
||||
public int Size => _size;
|
||||
public int Capacity => _capacity;
|
||||
public int Count => _size;
|
||||
|
@@ -26,16 +26,31 @@ namespace Convention.WindowsUI.Variant
|
||||
|
||||
public void CameraSelect(bool isScene)
|
||||
{
|
||||
IsSelectSceneCamera = isScene;
|
||||
SceneCamera.gameObject.SetActive(isScene);
|
||||
ModuleCamera.gameObject.SetActive(!isScene);
|
||||
if (m_GameObjectOnSceneOnly != null)
|
||||
if (ModuleCamera == null)
|
||||
{
|
||||
m_GameObjectOnSceneOnly.SetActive(isScene);
|
||||
IsSelectSceneCamera = true;
|
||||
SceneCamera.gameObject.SetActive(true);
|
||||
m_GameObjectOnSceneOnly.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
IsSelectSceneCamera = isScene;
|
||||
SceneCamera.gameObject.SetActive(isScene);
|
||||
ModuleCamera.gameObject.SetActive(!isScene);
|
||||
if (m_GameObjectOnSceneOnly != null)
|
||||
{
|
||||
m_GameObjectOnSceneOnly.SetActive(isScene);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(IsSelectSceneCamera==false&& ModuleCamera==null)
|
||||
{
|
||||
CameraSelect(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
@@ -43,7 +58,7 @@ namespace Convention.WindowsUI.Variant
|
||||
{
|
||||
m_WindowManager = GetComponent<WindowManager>();
|
||||
}
|
||||
if(MainCamera==null)
|
||||
if (MainCamera == null)
|
||||
{
|
||||
MainCamera = Camera.main.GetComponent<CinemachineBrain>();
|
||||
}
|
||||
|
@@ -288,50 +288,12 @@ namespace Convention.WindowsUI.Variant
|
||||
|
||||
private void ForceRebuildLayoutImmediate()
|
||||
{
|
||||
// TODO
|
||||
{
|
||||
RectTransformExtension.AdjustSizeToContainsChilds(ref_value.transform as RectTransform);
|
||||
}
|
||||
return;
|
||||
/*
|
||||
if (ref_value != null)
|
||||
{
|
||||
ConventionUtility.StartCoroutine(Adjuster(ref_value.transform as RectTransform));
|
||||
|
||||
RectTransformExtension.AdjustSizeToContainsChilds(ref_value.transform as RectTransform);
|
||||
if (parentEntry != null)
|
||||
parentEntry.ForceRebuildLayoutImmediate();
|
||||
}
|
||||
if (parentWindow)
|
||||
{
|
||||
ConventionUtility.StartCoroutine(Adjuster(parentWindow.TargetWindowContent));
|
||||
}
|
||||
else
|
||||
{
|
||||
ConventionUtility.StartCoroutine(Adjuster2(parentEntry.ref_value.transform as RectTransform, parentEntry));
|
||||
}
|
||||
|
||||
static IEnumerator Adjuster(RectTransform rectTransform)
|
||||
{
|
||||
if (rectTransform == null)
|
||||
yield break;
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform);
|
||||
yield return null;
|
||||
if (rectTransform == null)
|
||||
yield break;
|
||||
RectTransformExtension.AdjustSizeToContainsChilds(rectTransform);
|
||||
}
|
||||
static IEnumerator Adjuster2(RectTransform rectTransform, ItemEntry parentEntry)
|
||||
{
|
||||
if (rectTransform == null)
|
||||
yield break;
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(rectTransform);
|
||||
yield return null;
|
||||
if (rectTransform == null)
|
||||
yield break;
|
||||
RectTransformExtension.AdjustSizeToContainsChilds(rectTransform);
|
||||
yield return null;
|
||||
parentEntry.ForceRebuildLayoutImmediate();
|
||||
yield break;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
public void DisableChilds(bool isForceRebuildLayoutImmediate)
|
||||
|
@@ -84,8 +84,8 @@ namespace Convention.WindowsUI.Variant
|
||||
{
|
||||
target.CreateItem(() =>
|
||||
{
|
||||
action.callback(rightTop);
|
||||
ReleaseAllCustomMenu();
|
||||
action.callback(rightTop);
|
||||
}, action.name);
|
||||
}
|
||||
CustomMenuRelease.gameObject.SetActive(true);
|
||||
|
Reference in New Issue
Block a user