LED: when not using ipc automatic using fade effect; swap the hand of local-motion turn and rotate

This commit is contained in:
xpeng
2022-08-01 23:22:40 +02:00
parent 20ea89c666
commit db1b1d8cf8
4 changed files with 110 additions and 143 deletions
+15 -3
View File
@@ -8,7 +8,8 @@ public class LightManager : MonoBehaviour
{
public List<GameObject> Lights = new List<GameObject>();
List<Material> Materials = new List<Material>();
public static bool useIPC = true;
public static bool useIPC = false;
public static bool useIPC_Config = true;
static Texture2D RGBColor2D;
public static MemoryMappedFile sharedBuffer;
@@ -20,9 +21,9 @@ public class LightManager : MonoBehaviour
private void Start()
{
if (JsonConfiguration.HasKey("useIPC"))
useIPC = JsonConfiguration.GetBoolean("useIPC");
useIPC_Config = JsonConfiguration.GetBoolean("useIPC");
else
JsonConfiguration.SetBoolean("useIPC", useIPC);
JsonConfiguration.SetBoolean("useIPC", useIPC_Config);
for (int i = 0; i < Lights.Count; i++)
Materials.Add(Lights[i].GetComponent<Renderer>().material);
@@ -37,9 +38,18 @@ public class LightManager : MonoBehaviour
}
private void Update()
{
if (!useIPC_Config)
CheckIPCState();
if (useIPC)
UpdateLED();
}
private void CheckIPCState()
{
if (RGBColor2D.GetPixel(0 , 0).a == 0)
useIPC = false;
else
useIPC = true;
}
private void InitializeIPC(string sharedMemoryName, int sharedMemorySize)
{
MemoryMappedFileSecurity CustomSecurity = new MemoryMappedFileSecurity();
@@ -85,6 +95,7 @@ public class LightManager : MonoBehaviour
if (State)
{
Materials[Area].SetColor("_EmissionColor", new Color(1f, 1f, 1f, 1f));
Materials[Area].SetColor("_EmissionColor2", new Color(1f, 1f, 1f, 1f));
}
else
{
@@ -100,6 +111,7 @@ public class LightManager : MonoBehaviour
{
float p = 1 - time / FadeDuration;
mat.SetColor("_EmissionColor", new Color(p, p, p, 1f));
mat.SetColor("_EmissionColor2", new Color(p, p, p, 1f));
yield return null;
}
}