1
0
mirror of synced 2024-11-30 17:04:29 +01:00

update package; clean serial code; add fps limit for 3rd person; LightManager Update

This commit is contained in:
xpeng 2022-07-26 15:13:45 +02:00
parent 8931d431f5
commit 642f28b29c
11 changed files with 78 additions and 122 deletions

View File

@ -15,7 +15,7 @@ LightingSettings:
m_BounceScale: 1
m_AlbedoBoost: 1
m_IndirectOutputScale: 1
m_UsingShadowmask: 1
m_UsingShadowmask: 0
m_BakeBackend: 1
m_LightmapMaxSize: 1024
m_BakeResolution: 40
@ -26,7 +26,7 @@ LightingSettings:
m_CompAOExponent: 1
m_CompAOExponentDirect: 0
m_ExtractAO: 0
m_MixedBakeMode: 2
m_MixedBakeMode: 1
m_LightmapsBakeMode: 1
m_FilterMode: 1
m_LightmapParameters: {fileID: 15204, guid: 0000000000000000f000000000000000, type: 0}

View File

@ -13963,6 +13963,7 @@ MonoBehaviour:
- {fileID: 802529247}
- {fileID: 512944751}
- {fileID: 215619937}
Materials: []
FadeDuration: 0.5
--- !u!4 &1251312952
Transform:
@ -17798,6 +17799,7 @@ GameObject:
- component: {fileID: 1740661842}
- component: {fileID: 1740661841}
- component: {fileID: 1740661839}
- component: {fileID: 1740661843}
m_Layer: 0
m_Name: Third-Person Camera
m_TagString: Untagged
@ -17897,6 +17899,22 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 7.278, y: 21.625, z: 0.272}
--- !u!114 &1740661843
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1740661838}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: e44f24d571d0baa46bacf3d93aca3592, type: 3}
m_Name:
m_EditorClassIdentifier:
target: {fileID: 1699975370}
smoothSpeed: 0
PositionOffset: {x: 0, y: 0, z: 0}
FPS: 60
--- !u!65 &1744786996
BoxCollider:
m_ObjectHideFlags: 0
@ -34397,7 +34415,7 @@ Transform:
m_GameObject: {fileID: 4132370725483181716}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.028199367, y: 0.000000044703484, z: -0.000000059604645}
m_LocalScale: {x: 1.1738297, y: 0.99999976, z: 1.0000004}
m_LocalScale: {x: 1.1738298, y: 0.99999976, z: 1.0000004}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 8291635641984613349}
@ -38029,7 +38047,7 @@ Transform:
m_GameObject: {fileID: 8745419925326491997}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.01617647, y: -0.0000000034842422, z: 0.000000007450581}
m_LocalScale: {x: 1.3437866, y: 0.99999976, z: 0.9999997}
m_LocalScale: {x: 1.3437865, y: 0.99999976, z: 0.9999997}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 5263490648690488489}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 244 KiB

After

Width:  |  Height:  |  Size: 242 KiB

View File

@ -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);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e44f24d571d0baa46bacf3d93aca3592
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -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]);
}
}

View File

@ -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

View File

@ -3,20 +3,17 @@
"com.hecomi.uwindowcapture": "https://github.com/hecomi/uWindowCapture.git#upm",
"com.ultraleap.tracking": "5.11.0",
"com.ultraleap.tracking.openxr": "1.0.0-pre.5",
"com.unity.collab-proxy": "1.15.17",
"com.unity.ide.rider": "3.0.13",
"com.unity.ide.visualstudio": "2.0.15",
"com.unity.ide.visualstudio": "2.0.16",
"com.unity.ide.vscode": "1.2.5",
"com.unity.nuget.newtonsoft-json": "3.0.2",
"com.unity.render-pipelines.universal": "12.1.6",
"com.unity.test-framework": "1.1.31",
"com.unity.test-framework": "2.0.1-pre.18",
"com.unity.textmeshpro": "3.0.6",
"com.unity.timeline": "1.6.4",
"com.unity.ugui": "1.0.0",
"com.unity.visualscripting": "1.7.8",
"com.unity.xr.interaction.toolkit": "2.1.0-pre.1",
"com.unity.xr.management": "4.2.1",
"com.unity.xr.oculus": "3.0.1",
"com.unity.xr.openxr": "1.4.1",
"com.unity.xr.oculus": "3.0.2",
"com.unity.xr.openxr": "1.4.2",
"com.unity.modules.ai": "1.0.0",
"com.unity.modules.androidjni": "1.0.0",
"com.unity.modules.animation": "1.0.0",

View File

@ -33,33 +33,15 @@
},
"url": "https://packages.unity.com"
},
"com.unity.collab-proxy": {
"version": "1.15.17",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.services.core": "1.0.1"
},
"url": "https://packages.unity.com"
},
"com.unity.ext.nunit": {
"version": "1.0.6",
"version": "2.0.2",
"depth": 1,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.ide.rider": {
"version": "3.0.13",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.ext.nunit": "1.0.6"
},
"url": "https://packages.unity.com"
},
"com.unity.ide.visualstudio": {
"version": "2.0.15",
"version": "2.0.16",
"depth": 0,
"source": "registry",
"dependencies": {
@ -92,7 +74,7 @@
},
"com.unity.nuget.newtonsoft-json": {
"version": "3.0.2",
"depth": 2,
"depth": 0,
"source": "registry",
"dependencies": {},
"url": "https://packages.unity.com"
@ -125,17 +107,6 @@
"dependencies": {},
"url": "https://packages.unity.com"
},
"com.unity.services.core": {
"version": "1.3.1",
"depth": 1,
"source": "registry",
"dependencies": {
"com.unity.modules.unitywebrequest": "1.0.0",
"com.unity.nuget.newtonsoft-json": "3.0.2",
"com.unity.modules.androidjni": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.shadergraph": {
"version": "12.1.6",
"depth": 1,
@ -155,11 +126,11 @@
"url": "https://packages.unity.com"
},
"com.unity.test-framework": {
"version": "1.1.31",
"version": "2.0.1-pre.18",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.ext.nunit": "1.0.6",
"com.unity.ext.nunit": "2.0.2",
"com.unity.modules.imgui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
},
@ -174,18 +145,6 @@
},
"url": "https://packages.unity.com"
},
"com.unity.timeline": {
"version": "1.6.4",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.modules.director": "1.0.0",
"com.unity.modules.animation": "1.0.0",
"com.unity.modules.audio": "1.0.0",
"com.unity.modules.particlesystem": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.ugui": {
"version": "1.0.0",
"depth": 0,
@ -195,16 +154,6 @@
"com.unity.modules.imgui": "1.0.0"
}
},
"com.unity.visualscripting": {
"version": "1.7.8",
"depth": 0,
"source": "registry",
"dependencies": {
"com.unity.ugui": "1.0.0",
"com.unity.modules.jsonserialize": "1.0.0"
},
"url": "https://packages.unity.com"
},
"com.unity.xr.core-utils": {
"version": "2.0.0",
"depth": 1,
@ -253,7 +202,7 @@
"url": "https://packages.unity.com"
},
"com.unity.xr.oculus": {
"version": "3.0.1",
"version": "3.0.2",
"depth": 0,
"source": "registry",
"dependencies": {
@ -262,7 +211,7 @@
"url": "https://packages.unity.com"
},
"com.unity.xr.openxr": {
"version": "1.4.1",
"version": "1.4.2",
"depth": 0,
"source": "registry",
"dependencies": {