/// <summary> /// Destroys the specified faces. /// </summary> /// <param name="faces"> /// The faces to destroy. /// </param> private void DestroyFaces(ClippingBoxFaces faces) { // Loop through specified faces ForSpecificFaces(faces, (face, faceObject) => { // Get the cut plane component ARRCutPlaneComponent cutPlane = faceObject.GetComponent <ARRCutPlaneComponent>(); // If connected, disable the cut plane component if (RemoteManagerUnity.IsConnected) { try { cutPlane.RemoteComponent.Enabled = false; } catch (Exception ex) { Debug.LogFormat(LogType.Warning, LogOption.NoStacktrace, null, "{0}", $"Could not disable cut plane: {ex.Message}"); } } // Remove the face object from the active list faceObjects.Remove(face); // Mark it for destruction GameObject.Destroy(faceObject); }); }
private void DestroyRemoteComponent() { Object.Destroy(localCutPlaneComponent); Object.Destroy(remoteEntitySync); localCutPlaneComponent = null; remoteEntitySync = null; }
/// <summary> /// Enables or disables all faces. /// </summary> /// <param name="enabled"> /// <c>true</c> if faces should be enabled; otherwise <c>false</c>. /// </param> private void EnableFaces(bool enabled) { // Loop through active faces ForAllFaces((face, faceObject) => { // Get the cut plane component ARRCutPlaneComponent cutPlane = faceObject.GetComponent <ARRCutPlaneComponent>(); // Update enabled if ((cutPlane != null) && (cutPlane.RemoteComponent != null)) { cutPlane.RemoteComponent.Enabled = enabled; } }); }
private void CreateRemoteComponent() { if (localCutPlaneComponent == null) { localCutPlaneComponent = gameObject.CreateArrComponent <ARRCutPlaneComponent>(RemoteManagerUnity.CurrentSession); } if (remoteEntitySync == null) { remoteEntitySync = gameObject.GetComponent <RemoteEntitySyncObject>(); remoteEntitySync.SyncEveryFrame = true; } localCutPlaneComponent.RemoteComponent.Normal = Axis.X; localCutPlaneComponent.RemoteComponent.FadeLength = 0.025f; localCutPlaneComponent.RemoteComponent.FadeColor = new Color4Ub(255, 128, 0, 255); localCutPlaneComponent.RemoteComponent.Enabled = true; }
/// <summary> /// Creates the specified faces. /// </summary> /// <param name="faces"> /// The faces to create. /// </param> private void CreateFaces(ClippingBoxFaces faces) { // Loop through all values foreach (ClippingBoxFaces face in Enum.GetValues(typeof(ClippingBoxFaces))) { // Is this face being passed in? if (faces.HasFlag(face)) { // Only create if not already alive if (!faceObjects.ContainsKey(face)) { // Create the object GameObject faceObject = new GameObject(Enum.GetName(typeof(ClippingBoxFaces), face)); // Parent it faceObject.transform.SetParent(transform, worldPositionStays: false); // Create the component ARRCutPlaneComponent cutPlane = faceObject.CreateArrComponent <ARRCutPlaneComponent>(RemoteManagerUnity.CurrentSession); // Configure it if (cutPlane.RemoteComponent != null) { cutPlane.RemoteComponent.Normal = FaceToNormal(face); cutPlane.RemoteComponent.FadeLength = .0000025f; cutPlane.RemoteComponent.FadeColor = new Color4Ub(0, 0, 75, 255); } RemoteEntitySyncObject syncObject = faceObject.GetComponent <RemoteEntitySyncObject>(); if (syncObject != null) { syncObject.SyncEveryFrame = true; } // Add it to the active list faceObjects[face] = faceObject; } } } }
void Update() { if (!RemoteManagerUnity.IsConnected) { // can't do anything while we are not connected return; } if (localCutPlaneComponent == null) { localCutPlaneComponent = gameObject.CreateArrComponent <ARRCutPlaneComponent>(RemoteManagerUnity.CurrentSession); } if (remoteEntitySync == null) { remoteEntitySync = gameObject.GetComponent <RemoteEntitySyncObject>(); remoteEntitySync.SyncEveryFrame = true; } localCutPlaneComponent.RemoteComponent.Normal = Axis.X; localCutPlaneComponent.RemoteComponent.FadeLength = 0.025f; localCutPlaneComponent.RemoteComponent.FadeColor = new Color4Ub(255, 128, 0, 255); localCutPlaneComponent.RemoteComponent.Enabled = true; }