예제 #1
0
        private void EventProcessing()
        {
            Event e = Event.current;

            if (e != null)
            {
                if (e.type == EventType.MouseDown)
                {
                    if (e.button == 2)
                    {
                        Undo.RecordObjects(targets, "Active");
                        for (int i = 0; i < targets.Length; i++)
                        {
                            MonoBehaviour mono = targets[i] as MonoBehaviour;
                            mono.enabled = !mono.enabled;
                        }

                        e.Use();
                    }
                    else if (e.clickCount == 2)
                    {
                        AutoReferencer.FindReferences(targets);
                        e.Use();
                    }
                }
            }
        }
예제 #2
0
        internal static void DrawBottomPanel(IEnumerable <Object> targets)
        {
            if (s_BottomPanelContents == null)
            {
                s_BottomPanelContents = new BottomPanelContents();
            }

            Event e = Event.current;

            if (e != null)
            {
                if (e.type == EventType.MouseDown)
                {
                    if (e.button == 2)
                    {
                        AutoReferencer.FindReferences(targets);
                        e.Use();
                    }
                }
            }

            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button(s_BottomPanelContents.calc))
                {
                    var Info = new ProcessStartInfo
                    {
                        FileName = "calc.exe "
                    };
                    Process.Start(Info);
                }

                if (GUILayout.Button(s_BottomPanelContents.findRef))
                {
                    AutoReferencer.FindReferences(targets);
                }

                if (GUILayout.Button(s_BottomPanelContents.calledByEditor, "ButtonLeft"))
                {
                    AutoReferencer.CalledByEditor(targets);
                }

                if (GUILayout.Button(s_BottomPanelContents.calledByEditorc, "ButtonRight"))
                {
                    TextEditor te = new TextEditor();
                    te.text =
                        @"
#if UNITY_EDITOR
    private void CalledByEditor()
    {
        
    }
#endif
";
                    te.OnFocus();
                    te.Copy();
                }
            }
            EditorGUILayout.EndHorizontal();
        }
예제 #3
0
        internal static void DrawBottomPanel(Object target, IEnumerable <Object> targets)
        {
            Event e = Event.current;

            if (e != null)
            {
                if (e.type == EventType.MouseDown)
                {
                    if (e.button == 2)
                    {
                        if (e.alt)
                        {
                            AutoReferencer.FindReferences(targets);
                            e.Use();
                            return;
                        }

                        SelectionHelper.ToggleGameObjcetActiveSelf();
                        e.Use();
                    }
                }
            }

            if (s_BottomPanelContents == null)
            {
                s_BottomPanelContents = new BottomPanelContents();
            }

            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button(s_BottomPanelContents.findRef))
                {
                    AutoReferencer.FindReferences(targets);
                }

                if (GUILayout.Button(s_BottomPanelContents.calledByEditor, "ButtonLeft"))
                {
                    AutoReferencer.CalledByEditor(targets);
                }

                if (GUILayout.Button(s_BottomPanelContents.calledByEditorc, "ButtonRight"))
                {
                    TextEditor te = new TextEditor();
                    te.text =
                        @"
#if UNITY_EDITOR
    private void CalledByEditor()
    {
        
    }
#endif
";
                    te.OnFocus();
                    te.Copy();
                }
            }
            EditorGUILayout.EndHorizontal();
        }
        internal static void DrawBottomPanel(IEnumerable <Object> targets)
        {
            if (s_BottomPanelContents == null)
            {
                s_BottomPanelContents = new BottomPanelContents();
            }

            Event e = Event.current;

            if (e != null)
            {
                if (e.type == EventType.MouseDown)
                {
                    if (e.button == 2)
                    {
                        if (e.alt)
                        {
                            AutoReferencer.FindReferences(targets);
                            e.Use();
                            return;
                        }

                        Undo.RecordObjects(Selection.gameObjects, "Active");
                        Selection.gameObjects.ForEach(go =>
                        {
                            go.SetActive(!go.activeSelf);
                        });
                        e.Use();
                    }
                }
            }

            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button(s_BottomPanelContents.findRef))
                {
                    AutoReferencer.FindReferences(targets);
                }

                if (GUILayout.Button(s_BottomPanelContents.calledByEditor, "ButtonLeft"))
                {
                    AutoReferencer.CalledByEditor(targets);
                }

                if (GUILayout.Button(s_BottomPanelContents.calledByEditorc, "ButtonRight"))
                {
                    TextEditor te = new TextEditor();
                    te.text =
                        @"
#if UNITY_EDITOR
    private void CalledByEditor()
    {
        
    }
#endif
";
                    te.OnFocus();
                    te.Copy();
                }
            }
            EditorGUILayout.EndHorizontal();
        }
예제 #5
0
        internal static void DrawBottomPanel(Object target, IEnumerable <Object> targets)
        {
            Event e = Event.current;

            if (e != null)
            {
                if (e.type == EventType.MouseDown)
                {
                    if (e.button == 2)
                    {
                        if (e.alt)
                        {
                            AutoReferencer.FindReferences(targets);
                            e.Use();
                            return;
                        }

                        SelectionHelper.ToggleGameObjcetActiveSelf();
                        e.Use();
                    }
                }
            }

            if (s_BottomPanelContents == null)
            {
                s_BottomPanelContents = new BottomPanelContents();
            }

            EditorGUILayout.BeginHorizontal();
            {
                if (GUILayout.Button(s_BottomPanelContents.findRef))
                {
                    AutoReferencer.FindReferences(targets);
                }

                if (GUILayout.Button(s_BottomPanelContents.name))
                {
                    //sb用来生成代码并复制到剪贴板
                    StringBuilder sb = new StringBuilder(128);
                    foreach (Object item in targets)
                    {
                        Transform t   = item as Transform;
                        Image     img = t.GetComponent <Image>(); //优先给Image命名
                        if (img && img.sprite)
                        {
                            Undo.RecordObject(t.gameObject, "Rename");
                            t.name = "img" + img.sprite.name;
                            sb.Append("public Image ").Append(t.name).AppendLine(";");
                            continue;
                        }

                        Component[] coms = t.GetComponents <Component>(); //没有Image的话
                        if (coms.Length > 1)                              //只有Transform的话排除
                        {
                            Undo.RecordObject(t.gameObject, "Rename");
                            string strType  = coms[1].GetType().Name;
                            string strValue = strType[0].ToString().ToLower() + strType.Substring(1);
                            t.name = strType;
                            sb.Append("public ").Append(strType).Append(" ").Append(strValue).AppendLine(";");
                        }
                    }

                    GUIUtility.systemCopyBuffer = sb.ToString();
                }

                if (GUILayout.Button(s_BottomPanelContents.calledByEditor, "ButtonLeft"))
                {
                    AutoReferencer.CalledByEditor(targets);
                }

                if (GUILayout.Button(s_BottomPanelContents.calledByEditorc, "ButtonRight"))
                {
                    GUIUtility.systemCopyBuffer =
                        @"
#if UNITY_EDITOR
    private void CalledByEditor()
    {
        
    }
#endif
";
                }
            }
            EditorGUILayout.EndHorizontal();
        }