Exemple #1
0
        private static void OpenWindow()
        {
            ObjectCloner window = GetWindow <ObjectCloner>();

            window.titleContent = new GUIContent("Object placer");
        }
Exemple #2
0
        static void createToolbar()
        {
            SceneView sceneView = SceneView.lastActiveSceneView;

            Handles.BeginGUI();
            GUILayout.BeginVertical();



            if (GUILayout.Button(contents[0], GUILayout.Width(32), GUILayout.Height(32)))
            {
                sceneView.LookAt(gizmoPosition);
            }

            else if (GUILayout.Button(contents[1], GUILayout.Width(32), GUILayout.Height(32)))
            {
                if (Selection.activeGameObject != null)
                {
                    Selection.activeGameObject.transform.position = gizmoPosition;
                }
            }

            else if (GUILayout.Button(contents[2], GUILayout.Width(32), GUILayout.Height(32)))
            {
                if (Selection.activeGameObject != null)
                {
                    gizmoPosition = Selection.activeGameObject.transform.position;
                }
            }

            else if (GUILayout.Button(contents[3], GUILayout.Width(32), GUILayout.Height(32)))
            {
                int gridSize = EditorPrefs.GetInt("Toolkit_GridSize", 1);

                Vector3 pos = gizmoPosition;

                pos.x = EditorHelper.snap((int)pos.x, gridSize);
                pos.z = EditorHelper.snap((int)pos.z, gridSize);

                gizmoPosition = pos;
            }

            else if (GUILayout.Button(contents[4], GUILayout.Width(32), GUILayout.Height(32)))
            {
                if (Selection.gameObjects.Length > 0)
                {
                    ShapeFactory.combineObjects(Selection.gameObjects);
                }
            }

            else if (GUILayout.Button(contents[5], GUILayout.Width(32), GUILayout.Height(32)))
            {
                Selection.activeGameObject.SetActive(true);
            }

            else if (GUILayout.Button(contents[6], GUILayout.Width(32), GUILayout.Height(32)))
            {
                Selection.activeGameObject.SetActive(false);
            }

            else if (GUILayout.Button(contents[7], GUILayout.Width(32), GUILayout.Height(32)))
            {
                if (objectCloner == null)
                {
                    objectCloner = ScriptableObject.CreateInstance <ObjectCloner>();
                }
                objectCloner.Show();
            }


            else if (GUILayout.Button(contents[8], GUILayout.Width(32), GUILayout.Height(32)))
            {
                if (selector == null)
                {
                    selector = ScriptableObject.CreateInstance <FilterSelector>();
                }
                selector.Show();
            }

            else if (GUILayout.Button(contents[9], GUILayout.Width(32), GUILayout.Height(32)))
            {
                if (colorSelector == null)
                {
                    colorSelector = ScriptableObject.CreateInstance <ColorSelector>();
                }
                colorSelector.Show();
            }


            else if (GUILayout.Button(contents[10], GUILayout.Width(32), GUILayout.Height(32)))
            {
                if (waypointGenerator == null)
                {
                    waypointGenerator = ScriptableObject.CreateInstance <WaypointGenerator>();
                }
                waypointGenerator.Show();
            }

            GUILayout.EndVertical();
            Handles.EndGUI();
        }