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); }
private static void MenuItemNewWindow(MenuCommand command) { if (command.context) { InspectPlusWindow.Inspect(PreferablyGameObject(command.context), true); } else { InspectPlusWindow.Inspect(PreferablyGameObject(Selection.objects), true); } }
private static void ContextMenuItemNewWindow(MenuCommand command) { InspectPlusWindow.Inspect(command.context, true); }
private static void ContextMenuItemNewTab(MenuCommand command) { InspectPlusWindow.Inspect(command.context, false); }
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)); } }
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()); }