1
0
mirror of synced 2024-12-18 01:05:54 +01:00

fix light issue and dispose IPC after wacvr closed

This commit is contained in:
xpeng 2022-11-08 21:23:25 +01:00
parent 1db320fa5d
commit a7ce4f3900
8 changed files with 1772 additions and 4 deletions

File diff suppressed because it is too large Load Diff

View File

@ -25,7 +25,7 @@ public class Config
public int TouchSampleRate = 3;
public int HandTrackingMode = 1;
public float Threshold = 0.3f;
public bool TouchPanelAirWall = false;
public bool TouchAirWall = false;
public bool UseIPCLighting = true;
public bool UseIPCTouch = true;
public float LightStrength = 1.35f;

View File

@ -171,6 +171,7 @@ public class ConfigManager : MonoBehaviour
{
foreach (var configPanelComponent in _configPanelComponents)
{
Debug.Log(configPanelComponent.ConfigKeyName);
var componentObject = configPanelComponent.Widget;
if (componentObject.GetComponent<TMP_Dropdown>() != null)
{

View File

@ -70,6 +70,13 @@ public class HandFollowManager : MonoBehaviour
Vector3 rotationDeltaInDegrees = angle * axis;
currentRigidbody.angularVelocity = rotationDeltaInDegrees * Mathf.Deg2Rad / Time.fixedDeltaTime;
}
private void DistanceSnap()
{
transform.position = Target.transform.position;
transform.rotation = Target.transform.rotation;
}
private void Update()
{
gameObject.transform.localScale = Target.transform.localScale;

View File

@ -0,0 +1,26 @@
// Code from https://forum.unity.com/threads/cant-run-my-coroutine-ondestroy.785756/
// Credit: Kurt-Dekker (https://forum.unity.com/members/kurt-dekker.225647/)
using UnityEngine;
using System.Collections;
public class CallAfterDelay : MonoBehaviour
{
float delay;
System.Action action;
public static CallAfterDelay Create( float delay, System.Action action)
{
CallAfterDelay cad = new GameObject("CallAfterDelay").AddComponent<CallAfterDelay>();
cad.delay = delay;
cad.action = action;
return cad;
}
IEnumerator Start()
{
yield return new WaitForSeconds( delay);
action();
Destroy ( gameObject);
}
}

View File

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

View File

@ -1,3 +1,16 @@
{
"name": "IPCManager"
"name": "IPCManager",
"rootNamespace": "",
"references": [
"GUID:e9ef0e10f8c2b264e9705f57f028b9e8"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@ -52,6 +52,37 @@ public class IPCManager : MonoBehaviour
return bytes;
}
private void OnDestroy() {
Debug.Log("Disposing IPC");
//CallAfterDelay.Create(0.1f, () => {
//StartCoroutine(DisposeWait());
//});
Dispose();
}
private static IEnumerator DisposeWait()
{
IPCManager.sharedBufferAccessor.Write(244 + 3, 0); // Clear the flag
yield return new WaitForSeconds(0.1f); // Wait if the IPC is still in use
IPCManager.sharedBufferAccessor.Read<byte>(244 + 3, out byte flag); // Get the flag again
if (flag == 0)
{
Dispose();
}
}
private static void Dispose()
{
if (sharedBuffer != null)
{
IPCManager.sharedBuffer.Dispose();
IPCManager.sharedBuffer = null;
IPCManager.sharedBufferAccessor = null;
IPCManager.isInitialized = false;
}
Debug.Log("IPC Disposed");
}
public static void SetTouchData(bool[] bytes)
{
EnsureInitialization();