예제 #1
0
        public static void SelectHandle(Handle h)
        {
            selectedHandles.Add(h);

            //LevelEditor.editorMode = LevelEditor.EditorMode.edit;

            Vector3[] vertices          = LevelPlacer.generatedLevel.moveArea.meshFilter.mesh.vertices;
            int[]     triangles         = LevelPlacer.generatedLevel.moveArea.meshFilter.mesh.triangles;
            Vector3[] newSelectionVerts = VertHelper.GetTriangleVerticiesByVertex(vertices, triangles, h.transform.position);
            print("seöectHandle " + newSelectionVerts.Length);

            foreach (Vector3 v in newSelectionVerts)
            {
                selectionTriangleVerts.Add(v);
            }
            SoundManager.PlayLightWobble();

            // there are at lest three verticies in total left and we plan to delete a vertex that is component of only one triangle
            if (vertices.Length > 3 && selectionTriangleVerts.Count <= 3)
            {
                UILevelEditor.DeleteShow(true);
            }
            else
            {
                UILevelEditor.DeleteShow(false);
            }
        }
예제 #2
0
        // change the current selected object and controll outline/handler/delete button display
        public static void SetSelectedObject(LevelObject newSelected)
        {
            // the new selection will be null, thus deselect whatever is selected
            if (newSelected == null && !Handle.vertGettingSelected)
            {
                // if the movearea was selected deactivate the handles
                if (selectedObject.objectType == LevelObject.ObjectType.moveArea)
                {
                    VertHandler.showHandles = false;
                }

                if (selectedObject != null)
                {
                    selectedObject.SetOutlineVisible(false);
                }
                selectedObject = null;

                UILevelEditor.DeleteShow(false);

                SoundManager.PlayLightWobble(0.6F);
                editorMode = EditorMode.select;
            }
            // replace the current selection with a new one
            else if (!Handle.vertGettingSelected)
            {
                // there was an object sleected already
                if (selectedObject != null)
                {
                    selectedObject.SetOutlineVisible(false);
                    // if the movearea got selected activate the handles
                    if (selectedObject.objectType == LevelObject.ObjectType.moveArea)
                    {
                        VertHandler._instance.OnDisable();
                    }
                }

                editorMode     = EditorMode.edit;
                selectedObject = newSelected;
                selectedObject.SetOutlineVisible(true);

                // if the movearea got selected activate the handles
                if (newSelected.objectType == LevelObject.ObjectType.moveArea)
                {
                    VertHandler.showHandles = true;
                    UILevelEditor.DeleteShow(false);
                }
                // the new object is not a movearea, activate the delete button (movearea delete button gets displayed when vertices get selected)
                else if (newSelected.objectType != LevelObject.ObjectType.spawn && newSelected.objectType != LevelObject.ObjectType.finish)
                {
                    UILevelEditor.DeleteShow(true);
                    SoundManager.PlayLightWobble();
                }
            }
        }
예제 #3
0
        public void DestroyHandles()
        {
            GameObject[] handles = GameObject.FindGameObjectsWithTag("handle");
#if UNITY_EDITOR
            //if (EditorApplication.isPlaying)
            //{
            //    UILevelEditor.DeleteShow(false);
            //}
#endif
#if UNITY_ANDROID
            UILevelEditor.DeleteShow(false);
#endif

            foreach (GameObject handle in handles)
            {
                DestroyImmediate(handle);
                handlesShown = false;
            }
            selectionTriangleVerts = new List <Vector3>();
            selectedHandles        = new List <Handle>();
        }
예제 #4
0
        public static void DeselectHandle(Handle h)
        {
            selectedHandles.Remove(h);
            SoundManager.PlayLightWobble(0.6F);

            Vector3[] vertices            = LevelPlacer.generatedLevel.moveArea.meshFilter.mesh.vertices;
            int[]     triangles           = LevelPlacer.generatedLevel.moveArea.meshFilter.mesh.triangles;
            Vector3[] newDeselectionVerts = VertHelper.GetTriangleVerticiesByVertex(vertices, triangles, h.transform.position);

            foreach (Vector3 v in newDeselectionVerts)
            {
                selectionTriangleVerts.Remove(v);
            }

            if (selectedHandles.Count == 0)
            {
                selectionTriangleVerts.Clear();
                UILevelEditor.DeleteShow(false);
            }
            else if (vertices.Length > 3 && selectionTriangleVerts.Count <= 3)
            {
                UILevelEditor.DeleteShow(true);
            }
        }