update package; clean serial code; add fps limit for 3rd person; LightManager Update
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
using UnityEngine;
|
||||
[RequireComponent(typeof(Camera))]
|
||||
public class CameraSmooth : MonoBehaviour {
|
||||
|
||||
public Transform target;
|
||||
public float smoothSpeed = 0.125f;
|
||||
public Vector3 PositionOffset;
|
||||
public int FPS = 60;
|
||||
private void Start()
|
||||
{
|
||||
QualitySettings.vSyncCount = 0;
|
||||
Application.targetFrameRate = FPS;
|
||||
}
|
||||
void Update ()
|
||||
{
|
||||
transform.position = Vector3.Lerp(transform.position, target.position + PositionOffset, smoothSpeed);
|
||||
transform.rotation = Quaternion.Lerp(transform.rotation, target.rotation, smoothSpeed);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e44f24d571d0baa46bacf3d93aca3592
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -5,25 +5,30 @@ using UnityEngine;
|
||||
public class LightManager : MonoBehaviour
|
||||
{
|
||||
public List<GameObject> Lights = new List<GameObject>();
|
||||
public List<Material> Materials = new List<Material>();
|
||||
public float FadeDuration = 0.5f;
|
||||
private IEnumerator[] coroutines = new IEnumerator[240];
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
for (int i = 0; i < Lights.Count; i++)
|
||||
{
|
||||
Materials[i] = Lights[i].GetComponent<Renderer>().material;
|
||||
}
|
||||
}
|
||||
public void UpdateLight(int Area, bool State)
|
||||
{
|
||||
Area -= 1;
|
||||
Material mat = Lights[Area].GetComponent<Renderer>().material;
|
||||
|
||||
if (State)
|
||||
{
|
||||
mat.SetColor("_EmissionColor", new Color(1f, 1f, 1f, 1f));
|
||||
Materials[Area].SetColor("_EmissionColor", new Color(1f, 1f, 1f, 1f));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (coroutines[Area] != null)
|
||||
StopCoroutine(coroutines[Area]);
|
||||
coroutines[Area] = FadeOut(Area, mat);
|
||||
coroutines[Area] = FadeOut(Area, Materials[Area]);
|
||||
StartCoroutine(coroutines[Area]);
|
||||
}
|
||||
}
|
||||
|
||||
+5
-48
@@ -29,10 +29,10 @@ public class Serial : MonoBehaviour
|
||||
string read2 = " 11 11 11 128 103 103 115 138 127 103 105 111 126 113 95 100";
|
||||
string read3 = " 101 115 98 86 76 67 68 48 117 0 82 154 0 6 35 4";
|
||||
|
||||
byte[] SettingData_160 = new byte[8];
|
||||
byte[] SettingData_162 = new byte[7];
|
||||
byte[] SettingData_148 = new byte[7];
|
||||
byte[] SettingData_201 = new byte[7];
|
||||
byte[] SettingData_160 = new byte[8] {160, 49, 57, 48, 53, 50, 51, 44};
|
||||
byte[] SettingData_162 = new byte[3] {162, 63, 29};
|
||||
byte[] SettingData_148 = new byte[3] {148, 0, 20};
|
||||
byte[] SettingData_201 = new byte[3] {201, 0, 73};
|
||||
static byte[] TouchPackL = new byte[36];
|
||||
static byte[] TouchPackR = new byte[36];
|
||||
public static bool[] TouchPackAll = new bool[240];
|
||||
@@ -49,10 +49,6 @@ public class Serial : MonoBehaviour
|
||||
Console.WriteLine($"Failed to Open Serial Ports: {ex}");
|
||||
}
|
||||
//Debug.Log("Touch Serial Initializing..");
|
||||
SetSettingData_160();
|
||||
SetSettingData_201();
|
||||
SetSettingData_162();
|
||||
SetSettingData_148();
|
||||
//Send touch update periodically to keep "read" alive
|
||||
_touchQueue = Queue.Synchronized(new Queue());
|
||||
_touchThread = new Thread(TouchThreadLoop);
|
||||
@@ -105,9 +101,6 @@ public class Serial : MonoBehaviour
|
||||
SendTouch(ComR, TouchPackR);
|
||||
}
|
||||
}
|
||||
private void FixedUpdate() {
|
||||
//SendTouchState();
|
||||
}
|
||||
|
||||
IEnumerator TouchTest(bool State) //this is a touch test code
|
||||
{
|
||||
@@ -233,13 +226,7 @@ public class Serial : MonoBehaviour
|
||||
void SendTouch(SerialPort Serial, byte[] Pack) //Send touch data
|
||||
{
|
||||
if (StartUp)
|
||||
{
|
||||
// Debug.Log($"Pack {string.Join(" ", Pack)}");
|
||||
var output = GetTouchPack(Pack);
|
||||
// Debug.Log($"Output {string.Join(" ", output)}");
|
||||
Serial.Write(output, 0, 36);
|
||||
}
|
||||
|
||||
Serial.Write(GetTouchPack(Pack), 0, 36);
|
||||
}
|
||||
public static void SetTouch(int Area, bool State) //set touch data 0-239
|
||||
{
|
||||
@@ -257,36 +244,6 @@ public class Serial : MonoBehaviour
|
||||
}
|
||||
TouchPackAll[Area] = State;
|
||||
}
|
||||
|
||||
void SetSettingData_160()
|
||||
{
|
||||
SettingData_160[0]=160;
|
||||
SettingData_160[1]=49;
|
||||
SettingData_160[2]=57;
|
||||
SettingData_160[3]=48;
|
||||
SettingData_160[4]=53;
|
||||
SettingData_160[5]=50;
|
||||
SettingData_160[6]=51;
|
||||
SettingData_160[7]=44;
|
||||
}
|
||||
void SetSettingData_201()
|
||||
{
|
||||
SettingData_201[0]=201;
|
||||
SettingData_201[1]=0;
|
||||
SettingData_201[2]=73;
|
||||
}
|
||||
void SetSettingData_162()
|
||||
{
|
||||
SettingData_162[0]=162;
|
||||
SettingData_162[1]=63;
|
||||
SettingData_162[2]=29;
|
||||
}
|
||||
void SetSettingData_148()
|
||||
{
|
||||
SettingData_148[0]=148;
|
||||
SettingData_148[1]=0;
|
||||
SettingData_148[2]=20;
|
||||
}
|
||||
}
|
||||
|
||||
public static class ByteHelper
|
||||
|
||||
Reference in New Issue
Block a user