private static void OnColorChanged(DependencyObject o, DependencyPropertyChangedEventArgs e)
        {
            ColorSelector cs = o as ColorSelector;

            if (cs != null)
            {
                Color newColor = (Color)e.NewValue;
                Color oldColor = (Color)e.OldValue;

                cs.PaintRectangle(newColor);

                cs.red.Value   = newColor.R;
                cs.green.Value = newColor.G;
                cs.blue.Value  = newColor.B;

                // Raise routed event
                cs.RaiseColorChangedEvent(oldColor, newColor);
            }
        }
示例#2
0
文件: Toolbox.cs 项目: mpue/Toolbox
        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();
        }