better led perfomance
This commit is contained in:
parent
73fb326b1c
commit
fd5681d6b9
@ -10972,6 +10972,9 @@ GameObject:
|
||||
- component: {fileID: 1483037935}
|
||||
- component: {fileID: 1483037933}
|
||||
- component: {fileID: 1483037940}
|
||||
- component: {fileID: 1483037942}
|
||||
- component: {fileID: 1483037943}
|
||||
- component: {fileID: 1483037941}
|
||||
m_Layer: 5
|
||||
m_Name: ConfigCanvas
|
||||
m_TagString: Untagged
|
||||
@ -11114,6 +11117,156 @@ MonoBehaviour:
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Camera: {fileID: 1326126835}
|
||||
--- !u!114 &1483037941
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1483037931}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 0ad34abafad169848a38072baa96cdb2, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_InteractionManager: {fileID: 1730787728}
|
||||
m_Colliders:
|
||||
- {fileID: 1483037943}
|
||||
m_InteractionLayerMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_InteractionLayers:
|
||||
m_Bits: 1
|
||||
m_DistanceCalculationMode: 1
|
||||
m_SelectMode: 0
|
||||
m_CustomReticle: {fileID: 0}
|
||||
m_FirstHoverEntered:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_LastHoverExited:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_HoverEntered:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_HoverExited:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_FirstSelectEntered:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_LastSelectExited:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_SelectEntered:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_SelectExited:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Activated:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Deactivated:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_OnFirstHoverEntered:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_OnLastHoverExited:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_OnHoverEntered:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_OnHoverExited:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_OnSelectEntered:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_OnSelectExited:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_OnSelectCanceled:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_OnActivate:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_OnDeactivate:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_AttachTransform: {fileID: 0}
|
||||
m_UseDynamicAttach: 1
|
||||
m_MatchAttachPosition: 1
|
||||
m_MatchAttachRotation: 1
|
||||
m_SnapToColliderVolume: 1
|
||||
m_AttachEaseInTime: 0.15
|
||||
m_MovementType: 2
|
||||
m_VelocityDamping: 1
|
||||
m_VelocityScale: 1
|
||||
m_AngularVelocityDamping: 1
|
||||
m_AngularVelocityScale: 1
|
||||
m_TrackPosition: 1
|
||||
m_SmoothPosition: 0
|
||||
m_SmoothPositionAmount: 5
|
||||
m_TightenPosition: 0.5
|
||||
m_TrackRotation: 1
|
||||
m_SmoothRotation: 0
|
||||
m_SmoothRotationAmount: 5
|
||||
m_TightenRotation: 0.5
|
||||
m_ThrowOnDetach: 0
|
||||
m_ThrowSmoothingDuration: 0.25
|
||||
m_ThrowSmoothingCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0
|
||||
outWeight: 0
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
m_ThrowVelocityScale: 1.5
|
||||
m_ThrowAngularVelocityScale: 1
|
||||
m_ForceGravityOnDetach: 0
|
||||
m_RetainTransformParent: 0
|
||||
m_AttachPointCompatibilityMode: 0
|
||||
--- !u!54 &1483037942
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1483037931}
|
||||
serializedVersion: 2
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_UseGravity: 1
|
||||
m_IsKinematic: 1
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 0
|
||||
--- !u!65 &1483037943
|
||||
BoxCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1483037931}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 1, y: 1, z: 1}
|
||||
m_Center: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &1494369262
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -2,6 +2,7 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
public class LightManager : MonoBehaviour
|
||||
{
|
||||
@ -11,7 +12,9 @@ public class LightManager : MonoBehaviour
|
||||
private bool isIPCIdle = true;
|
||||
[SerializeField]
|
||||
private bool useIPCLighting = true;
|
||||
static Texture2D RGBColor2D;
|
||||
//static Texture2D RGBColor2D;
|
||||
static byte[] RGBAColors;
|
||||
static byte[][] Colors;
|
||||
|
||||
private IEnumerator[] coroutines = new IEnumerator[240];
|
||||
public float FadeDuration = 0.5f;
|
||||
@ -41,7 +44,7 @@ public class LightManager : MonoBehaviour
|
||||
|
||||
if (useIPCLighting)
|
||||
{
|
||||
RGBColor2D = new Texture2D(480, 1, TextureFormat.RGBA32, false);
|
||||
//RGBColor2D = new Texture2D(480, 1, TextureFormat.RGBA32, false);
|
||||
//RGBColor2D.filterMode = FilterMode.Point; //for debugging
|
||||
//GetComponent<Renderer>().material.mainTexture = RGBColor2D; //for debugging
|
||||
}
|
||||
@ -56,7 +59,10 @@ public class LightManager : MonoBehaviour
|
||||
|
||||
if (IPCManager.sharedBuffer != null)
|
||||
{
|
||||
GetTextureFromBytes(IPCManager.GetLightData());
|
||||
//GetTextureFromBytes(IPCManager.GetLightData());
|
||||
RGBAColors = IPCManager.GetLightData();
|
||||
Colors = SplitByteArray(RGBAColors, 4);
|
||||
CheckIPCState(RGBAColors);
|
||||
if (isIPCIdle)
|
||||
return;
|
||||
UpdateLED();
|
||||
@ -87,10 +93,19 @@ public class LightManager : MonoBehaviour
|
||||
{
|
||||
for (int ii = 0; ii < 4; ii++)
|
||||
{
|
||||
Materials[119 - i - ii * 30].SetColor("_EmissionColor", RGBColor2D.GetPixel(index * 2, 0));
|
||||
Materials[119 - i - ii * 30].SetColor("_EmissionColor2", RGBColor2D.GetPixel(index * 2 + 1, 0));
|
||||
Materials[210 + i - ii * 30].SetColor("_EmissionColor", RGBColor2D.GetPixel((index + 120) * 2, 0));
|
||||
Materials[210 + i - ii * 30].SetColor("_EmissionColor2", RGBColor2D.GetPixel((index + 120) * 2 + 1, 0));
|
||||
|
||||
Materials[119 - i - ii * 30].SetColor("_EmissionColor",
|
||||
new Color32(Colors[index * 2][0], Colors[index * 2][1], Colors[index * 2][2], 255));
|
||||
Materials[119 - i - ii * 30].SetColor("_EmissionColor2",
|
||||
new Color32(Colors[index * 2 + 1][0], Colors[index * 2 + 1][1], Colors[index * 2 + 1][2], 255));
|
||||
Materials[210 + i - ii * 30].SetColor("_EmissionColor",
|
||||
new Color32(Colors[(index + 120) * 2][0], Colors[(index + 120) * 2][1], Colors[(index + 120) * 2][2], 255));
|
||||
Materials[210 + i - ii * 30].SetColor("_EmissionColor2",
|
||||
new Color32(Colors[(index + 120) * 2 + 1][0], Colors[(index + 120) * 2 + 1][1], Colors[(index + 120) * 2 + 1][2], 255));
|
||||
// Materials[119 - i - ii * 30].SetColor("_EmissionColor", RGBColor2D.GetPixel(index * 2, 0));
|
||||
// Materials[119 - i - ii * 30].SetColor("_EmissionColor2", RGBColor2D.GetPixel(index * 2 + 1, 0));
|
||||
// Materials[210 + i - ii * 30].SetColor("_EmissionColor", RGBColor2D.GetPixel((index + 120) * 2, 0));
|
||||
// Materials[210 + i - ii * 30].SetColor("_EmissionColor2", RGBColor2D.GetPixel((index + 120) * 2 + 1, 0));
|
||||
index++;
|
||||
}
|
||||
}
|
||||
@ -104,8 +119,8 @@ public class LightManager : MonoBehaviour
|
||||
return;
|
||||
var newbytes = new byte[1920];
|
||||
newbytes = bytes;
|
||||
RGBColor2D.LoadRawTextureData(newbytes);
|
||||
RGBColor2D.Apply();
|
||||
//RGBColor2D.LoadRawTextureData(newbytes);
|
||||
//RGBColor2D.Apply();
|
||||
|
||||
}
|
||||
public void UpdateFadeLight(int Area, bool State)
|
||||
@ -137,4 +152,20 @@ public class LightManager : MonoBehaviour
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
public static byte[][] SplitByteArray(byte[] byteArray, int chunkSize)
|
||||
{
|
||||
int numChunks = (byteArray.Length + chunkSize - 1) / chunkSize;
|
||||
byte[][] result = new byte[numChunks][];
|
||||
for (int i = 0; i < numChunks; i++)
|
||||
{
|
||||
int offset = i * chunkSize;
|
||||
int chunkLength = Math.Min(chunkSize, byteArray.Length - offset);
|
||||
byte[] chunk = new byte[chunkLength];
|
||||
Buffer.BlockCopy(byteArray, offset, chunk, 0, chunkLength);
|
||||
result[i] = chunk;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user