コード例 #1
0
        protected override void CopyComponent(int id)
        {
            m_SerializedObject.Update();

            var property     = m_ComponentProperty.GetArrayElementAtIndex(id);
            var componentObj = property.objectReferenceValue;

            if (s_ClipboardGameObject == null)
            {
                s_ClipboardGameObject = GameObject.Find(k_ClipboardGameObjectName)
                                        ?? EditorUtility.CreateGameObjectWithHideFlags(k_ClipboardGameObjectName, HideFlags.HideAndDontSave);
                s_ClipboardGameObject.SetActive(false);
            }

            if (s_ClipboardContent != null)
            {
                UnityObjectUtils.Destroy(s_ClipboardContent);
                s_ClipboardContent = null;
            }

            var component = componentObj as Component;

            Assert.IsNotNull(component);

            var compType = component.GetType();

            s_ClipboardContent = s_ClipboardGameObject.GetComponent(compType);

            if (s_ClipboardContent == null)
            {
                s_ClipboardContent = s_ClipboardGameObject.AddComponent(compType);
            }

            EditorUtility.CopySerializedIfDifferent(componentObj, s_ClipboardContent);
        }
コード例 #2
0
 public void Shutdown()
 {
     if (m_SpatialHintUI)
     {
         UnityObjectUtils.Destroy(m_SpatialHintUI.gameObject);
     }
 }
コード例 #3
0
        void IFunctionalityProvider.UnloadProvider()
        {
            m_ARPointCloudManager.pointCloudsChanged -= ARPointCloudManagerOnPointCloudsChanged;
            if (m_NewARPointCloudManager)
            {
                UnityObjectUtils.Destroy(m_NewARPointCloudManager);
            }

            ARFoundationSessionProvider.TearDownARSession();

            if (m_Identifiers.IsCreated)
            {
                m_Identifiers.Dispose();
            }

            if (m_Positions.IsCreated)
            {
                m_Positions.Dispose();
            }

            if (m_ConfidenceValues.IsCreated)
            {
                m_ConfidenceValues.Dispose();
            }
        }
コード例 #4
0
        internal override void CancelCreate()
        {
            if (EditMode)
            {
                if (m_CreatedObject == null) // Possible if child was already destroyed by closing the create window
                {
                    UnityObjectUtils.Destroy(m_BackupObject);
                }
                else
                {
                    m_BackupObject.transform.parent = m_CreatedObject.transform.parent;
                    m_BackupObject.transform.SetSiblingIndex(m_CreatedObject.transform.GetSiblingIndex());
                    m_BackupObject.name = m_BackupObject.name.Remove(m_BackupObject.name.LastIndexOf("(BACKUP)"));
                    foreach (var potentialCondition in m_PotentialConditions)
                    {
                        potentialCondition.gameObjectOwner = m_BackupObject;
                    }

                    UnityObjectUtils.Destroy(m_CreatedObject);
                    m_CreatedObject            = m_BackupObject;
                    m_CreatedObject.hideFlags &= ~HideFlags.HideInHierarchy;
                }
            }
            else
            {
                if (m_PlacedChildContent != null)
                {
                    UnityObjectUtils.Destroy(m_PlacedChildContent);
                }

                base.CancelCreate();
            }
        }
コード例 #5
0
ファイル: MainMenuFace.cs プロジェクト: PushyPixels/EditorXR
 public void ClearSubmenus()
 {
     foreach (var submenu in m_Submenus)
     {
         UnityObjectUtils.Destroy(submenu);
     }
 }
コード例 #6
0
        public void Setup()
        {
            manager = EditingContextManager.instance;
            go      = new GameObject("context test object");
            var transformTool       = go.AddComponent <TransformTool>();
            var createPrimitiveTool = go.AddComponent <CreatePrimitiveTool>();

            context      = ScriptableObject.CreateInstance <EditorXRContext>();
            context.name = "Some Other Context";
            context.m_DefaultToolStack = new List <MonoScript>();
            context.m_DefaultToolStack.Add(MonoScript.FromMonoBehaviour(transformTool));
            context.m_DefaultToolStack.Add(MonoScript.FromMonoBehaviour(createPrimitiveTool));
            UnityObjectUtils.Destroy(go);

            context2      = ScriptableObject.CreateInstance <EditorXRContext>();
            context2.name = "Yet Another Context";
            context2.m_DefaultToolStack = context.m_DefaultToolStack;

            settings = ScriptableObject.CreateInstance <EditingContextManagerSettings>();
            settings.defaultContextName = "Custom Default Context";
            newSettings = ScriptableObject.CreateInstance <EditingContextManagerSettings>();
            newSettings.defaultContextName = "New Custom Default Context";

            // Save once so that we can detect a change--without this, SaveProjectSettings_UpdatesProjectSettingsFile will fail on CloudBuild
            EditingContextManager.SaveProjectSettings(settings);
        }
コード例 #7
0
        public void Shutdown()
        {
            m_CameraInitialized     = false;
            m_OriginalNearClipPlane = 0;
            m_OriginalFarClipPlane  = 0;
            hmdReady = false;

            foreach (var playerObject in m_VRPlayerObjects)
            {
                UnityObjectUtils.Destroy(playerObject);
            }

            m_VRPlayerObjects.Clear();

            var cameraRig = CameraUtils.GetCameraRig();

            if (cameraRig)
            {
                cameraRig.transform.parent = null;
            }

            if (customPreviewCamera != null && customPreviewCamera as MonoBehaviour != null)
            {
                UnityObjectUtils.Destroy(((MonoBehaviour)customPreviewCamera).gameObject);
            }
        }
        public void DestroySession()
        {
            var arSessions = Resources.FindObjectsOfTypeAll <ARSession>();

            if (arSessions.Length > 0)
            {
                UnityObjectUtils.Destroy(arSessions[0].gameObject);
            }
        }
コード例 #9
0
        public static void DestroyDefaultProxyObjects()
        {
            foreach (var gameObject in k_ToDestroy)
            {
                UnityObjectUtils.Destroy(gameObject);
            }

            k_ToDestroy.Clear();
        }
コード例 #10
0
 void IFunctionalityProvider.UnloadProvider()
 {
     m_ARCameraManager.frameReceived -= ARCameraFrameEvent;
     if (m_NewARCameraManager)
     {
         UnityObjectUtils.Destroy(m_NewARCameraManager);
     }
     ARFoundationSessionProvider.TearDownARSession();
 }
コード例 #11
0
        void IFunctionalityProvider.UnloadProvider()
        {
            if (m_NewARRaycastManager)
            {
                UnityObjectUtils.Destroy(m_NewARRaycastManager);
            }

            ARFoundationSessionProvider.TearDownARSession();
        }
コード例 #12
0
ファイル: AssetGridItem.cs プロジェクト: PushyPixels/EditorXR
        void OnDestroy()
        {
            if (m_SphereMaterial)
            {
                UnityObjectUtils.Destroy(m_SphereMaterial);
            }

            UnityObjectUtils.Destroy(m_Cube.sharedMaterial);
        }
コード例 #13
0
ファイル: BlinkVisuals.cs プロジェクト: PushyPixels/EditorXR
        void OnDestroy()
        {
            UnityObjectUtils.Destroy(m_VisualsMaterial);

            foreach (var sphere in m_Spheres)
            {
                UnityObjectUtils.Destroy(sphere.gameObject);
            }
        }
コード例 #14
0
        void OnDestroy()
        {
            if (m_MeshFilter != null)
            {
                m_MeshFilter.sharedMesh = m_OriginalMesh;
            }

            UnityObjectUtils.Destroy(m_GeneratedMesh);
        }
コード例 #15
0
ファイル: SpatialMenuUI.cs プロジェクト: PushyPixels/EditorXR
        void DisplayHighlightedSubMenuContents()
        {
            m_BackButton.allowInteraction = true;
            ForceClearHomeMenuElements();

            // Find any element hovered by a ray, for later comparison and selection override
            // of menu elements highlighted via other input modes
            SpatialMenu.SpatialMenuData rayHoveredElementMenuData = null;
            if (spatialInterfaceInputMode == SpatialInterfaceInputMode.Ray)
            {
                foreach (var menuElement in m_CurrentlyDisplayedMenuElements)
                {
                    if (menuElement.hoveringNode != Node.None && menuElement.parentMenuData != null)
                    {
                        rayHoveredElementMenuData = menuElement.parentMenuData;
                        break;
                    }
                }
            }

            foreach (var menuData in spatialMenuData)
            {
                // Ray-based elements that are highlighted should take precedence over elements highlighted by other means
                // (neutral, BCI, etc) when changing menu levels
                if (menuData.highlighted && (rayHoveredElementMenuData == null || rayHoveredElementMenuData == menuData))
                {
                    m_CurrentlyDisplayedMenuElements.Clear();
                    var deleteOldChildren = m_SubMenuContainer.GetComponentsInChildren <Transform>().Where(x => x != m_SubMenuContainer);
                    foreach (var child in deleteOldChildren)
                    {
                        if (child != null && child.gameObject != null)
                        {
                            UnityObjectUtils.Destroy(child.gameObject);
                        }
                    }

                    foreach (var subMenuElement in menuData.spatialMenuElements)
                    {
                        var instantiatedPrefab  = EditorXRUtils.Instantiate(m_SubMenuElementPrefab).transform as RectTransform;
                        var providerMenuElement = instantiatedPrefab.GetComponent <SpatialMenuElement>();
                        this.InjectFunctionalitySingle(providerMenuElement);
                        providerMenuElement.Setup(subMenuContainer, () => Debug.Log("Setting up SubMenu : " + subMenuElement.name), subMenuElement.name, subMenuElement.tooltipText);
                        m_CurrentlyDisplayedMenuElements.Add(providerMenuElement);
                        subMenuElement.VisualElement       = providerMenuElement;
                        providerMenuElement.parentMenuData = menuData;
                        providerMenuElement.visible        = true;
                        providerMenuElement.selected       = subMenuElement.correspondingFunction;
                    }

                    break;
                }
            }

            m_HomeSectionDescription.gameObject.SetActive(false);
            this.RestartCoroutine(ref m_HomeSectionTitlesBackgroundBordersTransitionCoroutine, AnimateTopAndBottomCenterBackgroundBorders(false));
        }
コード例 #16
0
        void OnDestroy()
        {
            UnityObjectUtils.Destroy(m_ButtonMaterial);
            UnityObjectUtils.Destroy(m_ButtonMaskMaterial);

            if (m_Button)
            {
                m_Button.onClick.RemoveAllListeners();
            }
        }
コード例 #17
0
        void MarkerRemovedHandler(MRMarker marker)
        {
            GameObject go;

            if (m_MarkerGameObjects.TryGetValue(marker.id, out go))
            {
                UnityObjectUtils.Destroy(go);
                m_MarkerGameObjects.Remove(marker.id);
            }
        }
コード例 #18
0
ファイル: SpatialMenu.cs プロジェクト: PushyPixels/EditorXR
        void OnDestroy()
        {
            // Reset the applicable selection gizmo (SceneView) states
            sceneViewGizmosVisible = true;

            if (s_SpatialMenuUI)
            {
                UnityObjectUtils.Destroy(s_SpatialMenuUI.gameObject);
            }
        }
コード例 #19
0
 void PlaneRemovedHandler(MRPlane plane)
 {
     if (m_Planes.TryGetValue(plane.id, out var planeVisual))
     {
         UnityObjectUtils.Destroy(planeVisual.GameObject);
         UnityObjectUtils.Destroy(planeVisual.Mesh);
         m_Planes.Remove(plane.id);
         PlaneVisual.Recycle(planeVisual);
     }
 }
        public static void TearDownARSession()
        {
            s_RequestCount--;

            if (s_TemporarySession && !s_SharedSession && s_RequestCount == 0)
            {
                UnityObjectUtils.Destroy(s_TemporarySession.gameObject);
                s_TemporarySession = null;
            }
        }
コード例 #21
0
ファイル: WorkspaceUI.cs プロジェクト: PushyPixels/EditorXR
        void OnDestroy()
        {
            UnityObjectUtils.Destroy(m_TopFaceMaterial);
            UnityObjectUtils.Destroy(m_FrontFaceMaterial);

            m_CloseButton.clicked  -= OnCloseClicked;
            m_CloseButton.hovered  -= OnButtonHovered;
            m_ResizeButton.clicked -= OnResetSizeClicked;
            m_ResizeButton.hovered -= OnButtonHovered;
        }
コード例 #22
0
        public IEnumerator Destroy_OneArg_DestroysImmediately_InEditMode()
        {
            Assert.IsFalse(Application.isPlaying);
            var go = new GameObject();

            UnityObjectUtils.Destroy(go);
            yield return(null); // skip frame to allow destruction to run

            Assert.IsTrue(go == null);
        }
コード例 #23
0
        void LinkToFace()
        {
            if (m_FaceLandmarksAction == null || m_FaceLandmarksVisualPrefab == null)
            {
                return;
            }

            if (m_FaceLandmarksVisual != null)
            {
                UnityObjectUtils.Destroy(m_FaceLandmarksVisual);
            }

            m_FaceLandmarksVisual = Instantiate(m_FaceLandmarksVisualPrefab, transform);
            var landmarkTargets = m_FaceLandmarksVisual.GetComponentsInChildren <FaceLandmarkInteractionTarget>(true);
            var landmarks       = m_FaceLandmarksAction.landmarks;

            foreach (var target in landmarkTargets)
            {
                var landmark = landmarks.Find(x =>
                {
                    if (x.landmarkDefinition == null)
                    {
                        return(false);
                    }

                    MRFaceLandmark faceLandmark;
                    if (Enum.TryParse(x.landmarkDefinition.name, true, out faceLandmark))
                    {
                        return(faceLandmark == target.landmark);
                    }
                    else
                    {
                        return(false);
                    }
                });
                if (landmark != default(LandmarkController))
                {
                    var landmarkTransform = landmark.transform;

                    target.AttachTarget = landmarkTransform;
                    target.gameObject.AddComponent <RedirectSelection>().target = landmarkTransform.gameObject;
                    target.gameObject.SetActive(true);

                    var targetRenderer = target.gameObject.GetComponent <Renderer>();
                    if (targetRenderer != null)
                    {
                        targetRenderer.enabled = false;
                    }
                }
                else
                {
                    target.gameObject.SetActive(false);
                }
            }
        }
コード例 #24
0
        void FaceRemoved(IMRFace face)
        {
            // destroy face mesh
            if (m_FaceMeshRenderer != null)
            {
                UnityObjectUtils.Destroy(m_FaceMeshRenderer.gameObject);
            }

            // reset reference
            m_FaceMeshRenderer = null;
        }
コード例 #25
0
        public void RemoveDestroyedKeysTest()
        {
            var go         = new GameObject();
            var dictionary = new Dictionary <GameObject, object> {
                { go, null }
            };

            UnityObjectUtils.Destroy(go);
            UnityObjectUtils.RemoveDestroyedKeys(dictionary);
            Assert.Zero(dictionary.Count);
        }
コード例 #26
0
        public void RemoveDestroyedObjectsTest()
        {
            var go   = new GameObject();
            var list = new List <GameObject> {
                go
            };

            UnityObjectUtils.Destroy(go);
            UnityObjectUtils.RemoveDestroyedObjects(list);
            Assert.Zero(list.Count);
        }
        void IFunctionalityProvider.UnloadProvider()
        {
            m_ARPlaneManager.planesChanged -= ARPlaneManagerOnPlanesChanged;

            if (m_NewARPlaneManager)
            {
                UnityObjectUtils.Destroy(m_NewARPlaneManager);
            }

            ARFoundationSessionProvider.TearDownARSession();
        }
コード例 #28
0
ファイル: MainMenuUI.cs プロジェクト: PushyPixels/EditorXR
        void OnDestroy()
        {
            foreach (var kvp in m_Faces)
            {
                UnityObjectUtils.Destroy(kvp.Value.gameObject);
            }

            foreach (var material in m_MaterialsToCleanup)
            {
                UnityObjectUtils.Destroy(material);
            }
        }
コード例 #29
0
        public void UnloadModule()
        {
            foreach (var workspace in m_Workspaces.ToList())
            {
                if (workspace.transform)
                {
                    UnityObjectUtils.Destroy(workspace.transform.gameObject);
                }
            }

            m_Workspaces.Clear();
        }
コード例 #30
0
 void OnDestroy()
 {
     UnityObjectUtils.Destroy(m_RowCubeMaterial);
     UnityObjectUtils.Destroy(m_BackingCubeMaterial);
     UnityObjectUtils.Destroy(m_UIMaterial);
     UnityObjectUtils.Destroy(m_UIMaskMaterial);
     UnityObjectUtils.Destroy(m_HighlightMaterial);
     UnityObjectUtils.Destroy(m_HighlightMaskMaterial);
     UnityObjectUtils.Destroy(m_NoClipBackingCubeMaterial);
     UnityObjectUtils.Destroy(m_NoClipHighlightMaterial);
     UnityObjectUtils.Destroy(m_NoClipHighlightMaskMaterial);
 }