Example #1
0
    public override void OnHeaderGUI()
    {
        if (node == null)
        {
            node = target as ActNode;
        }

        if (node.sourceAction != null)
        {
            GUILayout.Label(node.sourceAction.name.ToString(), NodeEditorResources.styles.nodeHeader, GUILayout.Height(30));
        }
        else
        {
            inspectStuff.Show();
            OdinEditorWindow.InspectObject(inspectStuff, node);
            //window.Repaint();
        }

        if (node == null)
        {
            node = target as ActNode;
        }

        if (node.nodeInFilter == null || node.nodeOutFilter == null)
        {
            node.initNode();
            window.Repaint();
        }
    }
Example #2
0
    public override void OnHeaderGUI()
    {
        if (node == null)
        {
            node = target as NormNode;
        }

        if (node.sourceNorm != null)
        {
            GUILayout.Label(node.sourceNorm.GetType().ToString(), NodeEditorResources.styles.nodeHeader, GUILayout.Height(30));
        }
        else
        {
            inspectStuff.Show();
            OdinEditorWindow.InspectObject(inspectStuff, node);
            //window.Repaint();
        }

        if (node == null)
        {
            node = target as NormNode;
        }

        if (node.context == null)
        {
            node.initNode();
            window.Repaint();
        }
    }
            private void OpenObject()
            {
                var obj = this.UnityObject;

                if (obj == null)
                {
                    obj = AssetDatabase.LoadAssetAtPath(this.StringValue, typeof(UnityEngine.Object));
                }

                EditorGUIUtility.PingObject(obj);
                if (obj as ScriptableObject)
                {
                    var window = OdinEditorWindow.InspectObject(obj);
                    window.position = GUIHelper.GetEditorWindowRect().AlignCenter(windowSize.x, windowSize.y);
                }
                else
                {
                    UnityEditorEventUtility.DelayAction(() =>
                    {
                        AssetDatabase.OpenAsset(obj);
                        if (obj as SceneAsset)
                        {
                            UnityEditorEventUtility.DelayAction(() =>
                            {
                                GameObject.FindObjectsOfType <Transform>()
                                .Where(x => x.parent == null && x.childCount > 0)
                                .OrderByDescending(x => x.GetSiblingIndex())
                                .Select(x => x.transform.GetChild(0).gameObject)
                                .ForEach(x => EditorGUIUtility.PingObject(x));
                            });
                        }
                    });
                }
            }
        private static void OpenGettingStarted()
        {
            var assetPath = "Assets/" + SirenixAssetPaths.SirenixPluginPath + "Getting Started With Odin.asset";
            var asset     = AssetDatabase.LoadAssetAtPath(assetPath, typeof(UnityEngine.Object));

            OdinEditorWindow.InspectObject(asset).position = GUIHelper.GetEditorWindowRect().AlignCenter(632, 743);
        }
Example #5
0
    public override void OnHeaderGUI()
    {
        if (node == null)
        {
            node = target as GoalNode;
        }
        if (node.sourceGoal != null)
        {
            GUILayout.Label(node.sourceGoal.GetType().ToString(), NodeEditorResources.styles.nodeHeader, GUILayout.Height(30));
        }
        else
        {
            inspectStuff.Show();
            OdinEditorWindow.InspectObject(inspectStuff, node);
        }

        if (node == null)
        {
            node = target as GoalNode;
        }

        if (node.filter == null)
        {
            node.initNode();
            window.Repaint();
        }
        // Debug.Log("in the heeeead");
    }
Example #6
0
        private void OtherStuffYouCanDo()
        {
            var window = OdinEditorWindow.InspectObject(this.someObject);

            window.position = GUIHelper.GetEditorWindowRect().AlignCenter(270, 200);
            window.titleContent = new GUIContent("Custom title", EditorIcons.RulerRect.Active);
            window.OnClose += () => Debug.Log("Window Closed");
            window.OnBeginGUI += () => GUILayout.Label("-----------");
            window.OnEndGUI += () => GUILayout.Label("-----------");
        }
        public override void DrawCommandGUI()
        {
            serializedObject.Update();

            SetGame t = target as SetGame;

            if (GUILayout.Button("Configure"))
            {
                OdinEditorWindow.InspectObject(t);
            }
            serializedObject.ApplyModifiedProperties();
        }
            private void OpenEditorWindow()
            {
                var type = AssemblyUtilities.GetTypeByCachedFullName(this.StringValue);

                if (type != null)
                {
                    if (type.InheritsFrom <UnityEditor.EditorWindow>())
                    {
                        var window = EditorWindow.GetWindow(type);
                        window.position = GUIHelper.GetEditorWindowRect().AlignCenter(windowSize.x, windowSize.y);
                    }
                    else
                    {
                        var window = OdinEditorWindow.InspectObject(Activator.CreateInstance(type));
                        window.position = GUIHelper.GetEditorWindowRect().AlignCenter(windowSize.x, windowSize.y);
                    }
                }
                else if (File.Exists(this.StringValue))
                {
                    var obj    = AssetDatabase.LoadAssetAtPath(this.StringValue, typeof(UnityEngine.Object));
                    var window = OdinEditorWindow.InspectObject(obj);
                    window.position = GUIHelper.GetEditorWindowRect().AlignCenter(windowSize.x, windowSize.y);
                }
            }
Example #9
0
 private void InCenter()
 {
     var window = OdinEditorWindow.InspectObject(this.someObject);
     window.position = GUIHelper.GetEditorWindowRect().AlignCenter(270, 200);
 }
Example #10
0
 private void InspectObject()
 {
     OdinEditorWindow.InspectObject(this.someObject);
 }
        private void OnInspectorGUI()
        {
            var title    = new GUIStyle(SirenixGUIStyles.SectionHeaderCentered);
            var subTitle = new GUIStyle(SirenixGUIStyles.SectionHeader);

            title.fontSize    = this.TitleFontSize;
            subTitle.fontSize = this.SubTitleFontSize;

            GUIHelper.RequestRepaint();
            // Draw dark BG
            EditorGUI.DrawRect(GUIHelper.GetCurrentLayoutRect().Expand(5, 5, 4, 20), SirenixGUIStyles.DarkEditorBackground);

            // Draw title
            GUILayout.BeginVertical(new GUIStyle()
            {
                padding = new RectOffset(20, 20, 20, 20)
            });
            if (this.Title != null)
            {
                GUILayout.Label(new GUIContent(this.Title, this.Icon), title);
            }
            GUILayout.EndVertical();

            var padding = new GUIStyle()
            {
                padding = new RectOffset(20, 20, 20, 20)
            };

            foreach (var item in this.Examples)
            {
                if (item.VerticalResources)
                {
                    GUILayout.BeginVertical(padding);
                }
                else
                {
                    GUILayout.BeginHorizontal(padding);
                }
                {
                    // bg
                    EditorGUI.DrawRect(GUIHelper.GetCurrentLayoutRect().Padding(-10, -10, 5, 5), SirenixGUIStyles.BoxBackgroundColor);

                    // Draw texts
                    GUILayout.BeginVertical();
                    {
                        GUILayout.Label(item.Title, subTitle);
                        GUILayout.Label(item.SubTitle, SirenixGUIStyles.MultiLineLabel);
                    }
                    GUILayout.EndVertical();

                    // Draw buttons
                    if (item.VerticalResources)
                    {
                        GUILayout.Space(10);
                        GUILayout.BeginHorizontal();
                    }
                    else
                    {
                        GUILayout.BeginVertical(item.VerticalResources ? GUILayoutOptions.ExpandWidth() : GUILayoutOptions.Width(this.BtnWidth));
                    }
                    {
                        for (int i = 0; i < item.Resources.Count; i++)
                        {
                            if (i != 0 && item.VerticalResources)
                            {
                                GUILayout.FlexibleSpace();
                            }
                            item.Resources[i].Draw();
                        }
                    }
                    if (item.VerticalResources)
                    {
                        GUILayout.EndHorizontal();
                    }
                    else
                    {
                        GUILayout.EndVertical();
                    }
                }
                if (item.VerticalResources)
                {
                    GUILayout.EndVertical();
                }
                else
                {
                    GUILayout.EndHorizontal();
                }
            }

            if (!(GUIHelper.CurrentWindow as OdinEditorWindow))
            {
                GUIHelper.PushColor(Color.green);
                if (GUILayout.Button("Open this in a new window", GUILayoutOptions.Height(30)))
                {
                    OdinEditorWindow.InspectObject(this).position = GUIHelper.GetEditorWindowRect().AlignCenter(570, 700);
                    Selection.objects = new UnityEngine.Object[0];
                }
                GUIHelper.PopColor();
            }

            GUILayout.FlexibleSpace();
        }
 private void OpenEditor()
 {
     OdinEditorWindow.InspectObject(this);
 }
Example #13
0
    private void DrawModels()
    {
        if (!Application.isPlaying)
        {
            EditorGUILayout.LabelField("Enter Play Mode to view Models.");
            return;
        }

        if (Selection.activeObject == null)
        {
            EditorGUILayout.LabelField("Select a RichMVCContext Root GameObject");
            return;
        }

        GameObject rootGameObject = Selection.activeObject as GameObject;

        if (rootGameObject == null)
        {
            EditorGUILayout.LabelField("Select a RichMVCContext Root GameObject");
            return;
        }

        _inspectedRoot = rootGameObject.GetComponent <RichMVCContextRoot>();
        if (_inspectedRoot == null)
        {
            EditorGUILayout.LabelField("Select a RichMVCContext Root GameObject");
            return;
        }

        SirenixEditorFields.UnityObjectField("Inspecting", _inspectedRoot, typeof(RichMVCContextRoot), true);
        SirenixEditorGUI.DrawThickHorizontalSeperator(5f, 5f, 5f);

        CrossContext context = _inspectedRoot.context as CrossContext;

        EditorGUILayout.Toggle("Context Found", context != null);
        if (context == null)
        {
            return;
        }

        FieldInfo fieldInfo = typeof(CrossContextInjectionBinder).BaseType.GetField("bindings", BindingFlags.Instance | BindingFlags.NonPublic);

        EditorGUILayout.Toggle("Bindings Found", fieldInfo != null);
        if (fieldInfo == null)
        {
            return;
        }

        InjectionBinder injectionBinder = context.injectionBinder as CrossContextInjectionBinder;

        EditorGUILayout.Toggle("InjectionBinder Casted", injectionBinder != null);
        if (injectionBinder == null)
        {
            return;
        }

        SirenixEditorGUI.DrawThickHorizontalSeperator(5f, 5f, 5f);
        SirenixEditorGUI.Title("Bindings", "", TextAlignment.Center, false);
        SirenixEditorGUI.BeginBox();

        object bindings = fieldInfo.GetValue(injectionBinder);
        Dictionary <object, Dictionary <object, IBinding> > bindingDictionaries = (Dictionary <object, Dictionary <object, IBinding> >)bindings;

        if (bindingDictionaries == null)
        {
            return;
        }

        foreach (object mainKey in bindingDictionaries.Keys)
        {
            string typeName;
            if (!(mainKey is Type))
            {
                continue;
            }

            Type mainKeyType = mainKey as Type;

            if (_ignoredTypeList.Contains(mainKeyType))
            {
                continue;
            }

            IBinding binding = injectionBinder.GetBinding(mainKeyType);

            if (binding == null)
            {
                continue;
            }
            SirenixEditorGUI.BeginBox();

            typeName = mainKey.ToString();
            SirenixEditorGUI.Title(mainKeyType.Name, "", TextAlignment.Center, false);

            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();

            object instance = injectionBinder.GetInstance(mainKeyType);
            if (GUILayout.Button("Inspect", GUILayout.Height(20), GUILayout.Width(80)))
            {
                OdinEditorWindow.InspectObject(instance);
            }

            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();

            SirenixEditorGUI.EndBox();
            SirenixEditorGUI.DrawHorizontalLineSeperator(2f, 2f, 2f);
        }
        SirenixEditorGUI.EndBox();
    }