예제 #1
0
        private static void OpenIsolatedHierarchy(MenuCommand command, bool newWindow)
        {
            Object[] objs;
            if (command.context)
            {
                objs = new Object[1] {
                    PreferablyGameObject(command.context)
                }
            }
            ;
            else
            {
                objs = PreferablyGameObject(Selection.GetFiltered <Object>(SelectionMode.TopLevel | SelectionMode.ExcludePrefab | SelectionMode.Editable));
            }

            for (int i = 0; i < objs.Length; i++)
            {
                if (objs[i] as GameObject)
                {
                    IsolatedHierarchy isolatedHierarchy = ScriptableObject.CreateInstance <IsolatedHierarchy>();
                    isolatedHierarchy.name          = objs[i].name;
                    isolatedHierarchy.rootTransform = ((GameObject)objs[i]).transform;
                    isolatedHierarchy.hideFlags     = HideFlags.DontSave;

                    objs[i] = isolatedHierarchy;
                }
                else
                {
                    objs[i] = null;
                }
            }

            InspectPlusWindow.Inspect(objs, newWindow);
        }
예제 #2
0
 private static void MenuItemNewWindow(MenuCommand command)
 {
     if (command.context)
     {
         InspectPlusWindow.Inspect(PreferablyGameObject(command.context), true);
     }
     else
     {
         InspectPlusWindow.Inspect(PreferablyGameObject(Selection.objects), true);
     }
 }
예제 #3
0
        public void DrawOnGUI()
        {
            if (m_isExpanded)
            {
                if (!EditorGUILayout.Foldout(true, Getter.description, true))
                {
                    IsExpanded = false;
                    GUIUtility.ExitGUI();
                }
                else
                {
                    if (Obj == null || Obj.Equals(null))
                    {
                        EditorGUILayout.LabelField("Null");
                    }
                    else if (primitiveValue != null)                      // Variable is primitive
                    {
                        EditorGUILayout.LabelField(primitiveValue);
                    }
                    else
                    {
                        if (Obj is Object && parent != null)                          // We want to expose the variables of root entries
                        {
                            EditorGUILayout.ObjectField("", (Object)Obj, Obj.GetType(), true);

                            Event ev = Event.current;
                            if (ev.type == EventType.MouseDown && ev.button == 1 && GUILayoutUtility.GetLastRect().Contains(ev.mousePosition))
                            {
                                GenericMenu menu = new GenericMenu();
                                InspectPlusWindow.OnObjectRightClicked(menu, (Object)Obj);
                                menu.ShowAsContext();

                                GUIUtility.ExitGUI();
                            }
                        }
                        else
                        {
                            if (enumerableRoot != null)
                            {
                                EditorGUI.indentLevel++;
                                enumerableRoot.DrawOnGUI();
                                EditorGUI.indentLevel--;
                            }

                            if (variables != null)
                            {
                                for (int i = 0; i < variables.Count; i++)
                                {
                                    EditorGUI.indentLevel++;
                                    variables[i].DrawOnGUI();
                                    EditorGUI.indentLevel--;
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                if (EditorGUILayout.Foldout(false, Getter.description, true))
                {
                    IsExpanded = true;
                    GUIUtility.ExitGUI();
                }
            }
        }
예제 #4
0
 private static void ContextMenuItemNewWindow(MenuCommand command)
 {
     InspectPlusWindow.Inspect(command.context, true);
 }
예제 #5
0
 private static void ContextMenuItemNewTab(MenuCommand command)
 {
     InspectPlusWindow.Inspect(command.context, false);
 }
예제 #6
0
        private static void AddInspectButtonToMenu(GenericMenu menu, Object obj, string path)
        {
            if (obj is Component)
            {
                string componentType = string.Concat("/", obj.GetType().Name, " Component");

                menu.AddItem(new GUIContent(string.Concat(NEW_TAB_LABEL, path, "/GameObject")), false, () => InspectPlusWindow.Inspect(PreferablyGameObject(obj), false));
                menu.AddItem(new GUIContent(string.Concat(NEW_TAB_LABEL, path, componentType)), false, () => InspectPlusWindow.Inspect(obj, false));
                menu.AddItem(new GUIContent(string.Concat(NEW_WINDOW_LABEL, path, "/GameObject")), false, () => InspectPlusWindow.Inspect(PreferablyGameObject(obj), true));
                menu.AddItem(new GUIContent(string.Concat(NEW_WINDOW_LABEL, path, componentType)), false, () => InspectPlusWindow.Inspect(obj, true));
            }
            else
            {
                menu.AddItem(new GUIContent(string.Concat(NEW_TAB_LABEL, path)), false, () => InspectPlusWindow.Inspect(obj, false));
                menu.AddItem(new GUIContent(string.Concat(NEW_WINDOW_LABEL, path)), false, () => InspectPlusWindow.Inspect(obj, true));
            }
        }
예제 #7
0
        public static void OnPropertyRightClicked(GenericMenu menu, SerializedProperty property)
        {
            Object obj = null;
            bool   isUnityObjectType = false;

            if (property.propertyType == SerializedPropertyType.ExposedReference)
            {
                obj = property.exposedReferenceValue;
                isUnityObjectType = true;
            }
            else if (property.propertyType == SerializedPropertyType.ObjectReference)
            {
                obj = property.objectReferenceValue;
                isUnityObjectType = true;
            }

            if (isUnityObjectType && property.hasMultipleDifferentValues)
            {
                string   propertyPath = property.propertyPath;
                Object[] targets      = property.serializedObject.targetObjects;

                bool containsComponents = false;
                for (int i = 0; i < targets.Length; i++)
                {
                    SerializedProperty _property = new SerializedObject(targets[i]).FindProperty(propertyPath);
                    if (_property.propertyType == SerializedPropertyType.ExposedReference)
                    {
                        targets[i] = _property.exposedReferenceValue;
                        if (targets[i] is Component)
                        {
                            containsComponents = true;
                        }
                    }
                    else if (_property.propertyType == SerializedPropertyType.ObjectReference)
                    {
                        targets[i] = _property.objectReferenceValue;
                        if (targets[i] is Component)
                        {
                            containsComponents = true;
                        }
                    }
                }

                if (containsComponents)
                {
                    menu.AddItem(new GUIContent(NEW_TAB_LABEL + "/All/GameObject"), false, () => InspectPlusWindow.Inspect(PreferablyGameObject(targets), false));
                    menu.AddItem(new GUIContent(NEW_TAB_LABEL + "/All/Component"), false, () => InspectPlusWindow.Inspect(targets, false));
                    menu.AddItem(new GUIContent(NEW_WINDOW_LABEL + "/All/GameObject"), false, () => InspectPlusWindow.Inspect(PreferablyGameObject(targets), true));
                    menu.AddItem(new GUIContent(NEW_WINDOW_LABEL + "/All/Component"), false, () => InspectPlusWindow.Inspect(targets, true));
                }
                else
                {
                    menu.AddItem(new GUIContent(NEW_TAB_LABEL + "/All"), false, () => InspectPlusWindow.Inspect(targets, false));
                    menu.AddItem(new GUIContent(NEW_WINDOW_LABEL + "/All"), false, () => InspectPlusWindow.Inspect(targets, true));
                }

                for (int i = 0; i < targets.Length; i++)
                {
                    if (targets[i])
                    {
                        AddInspectButtonToMenu(menu, targets[i], "/" + targets[i].name);
                    }
                }

                menu.AddSeparator("");
            }
            else if (obj)
            {
                AddInspectButtonToMenu(menu, obj, "");
                menu.AddSeparator("");
            }

            if (!property.hasMultipleDifferentValues && (!isUnityObjectType || obj))
            {
                menu.AddItem(new GUIContent(CONTEXT_COPY_LABEL), false, CopyValue, property.Copy());
            }
            else
            {
                menu.AddDisabledItem(new GUIContent(CONTEXT_COPY_LABEL));
            }

            if (PasteBinWindow.ActiveClipboard == null || !property.CanPasteValue(PasteBinWindow.ActiveClipboard.RootValue, false))
            {
                menu.AddDisabledItem(new GUIContent(CONTEXT_PASTE_LABEL));
            }
            else
            {
                menu.AddItem(new GUIContent(CONTEXT_PASTE_LABEL), false, PasteValue, property.Copy());
            }

            menu.AddItem(new GUIContent(CONTEXT_PASTE_FROM_BIN_LABEL), false, PasteValueFromBin, property.Copy());
        }