/// <summary> /// Performs the specified action for the specific faces. /// </summary> /// <param name="faces"> /// The faces to match. /// </param> /// <param name="action"> /// The action to perform. /// </param> private void ForSpecificFaces(ClippingBoxFaces faces, Action <ClippingBoxFaces, GameObject> action) { // Loop through all enum values foreach (ClippingBoxFaces face in Enum.GetValues(typeof(ClippingBoxFaces))) { // But only if this flag was passed in if (faces.HasFlag(face)) { // And only if it's alive if (faceObjects.ContainsKey(face)) { // Perform the action action(face, faceObjects[face]); } } } }
/// <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; } } } }