Beispiel #1
0
    public void OnGUI()
    {
        if (Issues)
        {
            EditorGUILayout.HelpBox("Fix Errors First", MessageType.Info);
        }
        if (GeneratorDrawers != null)
        {
            _scrollPosition = GUILayout.BeginScrollView(_scrollPosition);
            var rect = new Vector2(0f, 28f);
            foreach (var fileGenerator in GeneratorDrawers)
            {
                if (GUIHelpers.DoToolbarEx(fileGenerator.ViewModelObject.Name))
                {
                    var lastRect = new Rect(0f, 0f, Screen.width, Screen.height);

                    fileGenerator.Refresh(InvertGraphEditor.PlatformDrawer, rect);
                    rect.y += fileGenerator.Bounds.height;
                    GUILayoutUtility.GetRect(Screen.width, fileGenerator.Bounds.height);
                    fileGenerator.Draw(InvertGraphEditor.PlatformDrawer, 1f);
                    //EditorGUILayout.TextArea(fileGenerator.ToString());
                }
                rect.y += 28f;
            }
            GUILayout.EndScrollView();
        }
    }
Beispiel #2
0
        public override void OnInspectorGUI()
        {
            GUIHelpers.IsInspector = true;
            //
            DrawTitleBar("Scene Management Service");
            base.OnInspectorGUI();
            serializedObject.Update();

            if (Application.isPlaying)
            {
                if (GUIHelpers.DoToolbarEx("Loaded Scenes"))
                {
                    if (Service != null)
                    {
                        foreach (IScene instance in Service.LoadedScenes)
                        {
                            if (GUIHelpers.DoTriggerButton(new UFStyle {
                                BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall,
                                Label = string.Format("{0}", instance.GetType().Name)
                            }))
                            {
                                Selection.activeGameObject = (instance as MonoBehaviour).gameObject;
                            }
                        }
                    }
                }
            }

            if (serializedObject.ApplyModifiedProperties())
            {
                //var t = Target as GameManager;
                //t.ApplyRenderSettings();
            }
            GUIHelpers.IsInspector = false;
        }
Beispiel #3
0
        public override void OnInspectorGUI()
        {
            GUIHelpers.IsInspector = true;
            //base.OnInspectorGUI();
            DrawTitleBar("View Service");
            serializedObject.Update();

            if (Application.isPlaying && ViewService != null)
            {
                if (GUIHelpers.DoToolbarEx(String.Format("Views ({0})", ViewService.Views.Count), defOn: false, prefsKey: "ViewServiceInspectorViews"))
                {
                    foreach (var instance in ViewService.Views)
                    {
                        EditorGUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.PrefixLabel(instance.GetType().Name);
                            EditorGUILayout.ObjectField(instance as MonoBehaviour, typeof(MonoBehaviour), true);
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
            else
            {
            }

            if (serializedObject.ApplyModifiedProperties())
            {
                //var t = Target as GameManager;
                //t.ApplyRenderSettings();
            }
            GUIHelpers.IsInspector = false;
        }
Beispiel #4
0
        public override void OnGUI()
        {
            base.OnGUI();

            if (GUIHelpers.DoToolbarEx(LocaleText.UIKitSettings))
            {
                mRootLayout.DrawGUI();
            }
        }
    public override void Draw(QuickAccessWindowViewModel data)
    {
        HandleInput(data);
        EditorGUI.DrawRect(new Rect(0f, 0f, Screen.width, Screen.height), new Color(0.3f, 0.3f, 0.5f));
        GUILayout.BeginHorizontal();
        EditorGUI.BeginChangeCheck();
        GUI.SetNextControlName("SearchField");
        data.SearchText = GUILayout.TextField(data.SearchText, TextFieldStyle);
        if (EditorGUI.EndChangeCheck())
        {
            data.UpdateSearch();
        }
        GUILayout.EndHorizontal();
        scrollPosition = GUILayout.BeginScrollView(scrollPosition);
        //var y = GUILayoutUtility.GetLastRect().y;
        var itemHeight = 20;

        if (string.IsNullOrEmpty(data.SearchText))
        {
            foreach (var group in data.GroupedLaunchItems)
            {
                if (GUIHelpers.DoToolbarEx(group.Key, null, null, null, null, true, new Color(0.8f, 0.8f, 0.8f)))
                {
                    var i = 0;
                    foreach (var item in group)
                    {
                        //var isSelected = i == data.SelectedIndex;

                        if (GUILayout.Button(item.Title, ItemStyle))
                        {
                            data.SelectedIndex = i;
                            data.Execute(item);
                        }
                        i++;
                    }
                }
            }
        }
        else
        {
            for (var i = 0; i < data.QuickLaunchItems.Count; i++)
            {
                var item       = data.QuickLaunchItems[i];
                var isSelected = i == data.SelectedIndex;

                if (GUILayout.Button(item.Title, isSelected ? SelectedStyle : ItemStyle))
                {
                    data.SelectedIndex = i;
                    data.Execute();
                }
            }
        }


        GUILayout.EndScrollView();
        GUI.FocusControl("SearchField");
    }
Beispiel #6
0
    private static void DoPlugin(ICorePlugin plugin)
    {
        if (GUIHelpers.DoToolbarEx(plugin.Title))
        {
            EditorGUI.BeginChangeCheck();

            plugin.Enabled = GUILayout.Toggle(plugin.Enabled, "Enabled");
            if (EditorGUI.EndChangeCheck())
            {
                InvertApplication.Container = null;
            }
            if (plugin.Enabled)
            {
                // TODO 2.0 Plugin Inspectors?
                //var inspect = plugin as IPluginInspector;

                var properties = plugin.GetType().GetPropertiesWithAttributeByType <InspectorProperty>(BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly);
                var platform   = InvertGraphEditor.PlatformDrawer as UnityDrawer;
                foreach (var property in properties)
                {
                    var property1 = property;
                    platform.DrawInspector(new PropertyFieldViewModel()
                    {
                        CachedValue = property.Key.GetValue(null, null),
                        Getter      = () => property1.Key.GetValue(null, null),
                        DataObject  = null,
                        Setter      = (d, v) =>
                        {
                            property1.Key.SetValue(null, v, null);
                            InvertApplication.Container = null;
                        },
                        Name = property.Key.Name,
                        Type = property.Key.PropertyType
                    }, EditorStyles.label);
                }
                //if (inspect != null)
                //{
                //    inspect.DoInspector();
                //}
            }
        }

        //if (
        //    GUIHelpers.DoTriggerButton(new UFStyle("     " + plugin.Title, ElementDesignerStyles.EventButtonStyleSmall,
        //        null,
        //        plugin.Enabled ? ElementDesignerStyles.TriggerActiveButtonStyle : ElementDesignerStyles.TriggerInActiveButtonStyle, () => { }, false,
        //        TextAnchor.MiddleCenter)
        //    {
        //        IsWindow = true,
        //        FullWidth = true
        //    }))
        //{
        //    plugin.Enabled = !plugin.Enabled;
        //    InvertApplication.Container = null;
        //}
    }
Beispiel #7
0
        public override void OnGUI()
        {
            base.OnGUI();


            mRootLayout.OnGUI();

            if (GUIHelpers.DoToolbarEx("User Info"))
            {
                GUILayout.BeginVertical("box");

                if (User.Token.Value.IsNullOrEmpty())
                {
                    User.Username.Value = EditorGUIUtils.GUILabelAndTextField("username:"******"password:"******"登录"))
                    {
                        GetTokenAction.DoGetToken(User.Username.Value, User.Password.Value, token =>
                        {
                            User.Token.Value = token;
                            User.Save();
                        });
                    }

                    if (!inRegisterView && GUILayout.Button("注册"))
                    {
                        inRegisterView = true;
                    }

                    if (inRegisterView)
                    {
                        if (GUILayout.Button("注册"))
                        {
                        }

                        if (GUILayout.Button("返回注册"))
                        {
                            inRegisterView = false;
                        }
                    }
                }
                else
                {
                    if (GUILayout.Button("注销"))
                    {
                        User.Clear();
                    }
                }

                GUILayout.EndVertical();
            }
        }
Beispiel #8
0
    public void DrawInspector(Rect rect)
    {
        var d = InvertGraphEditor.PlatformDrawer as UnityDrawer;
          //  d.DrawStretchBox(rect, CachedStyles.WizardListItemBoxStyle, 10);
        if (Groups == null || !Groups.Any())
        {
                var textRect = rect;
                var cacheColor = GUI.color;
                GUI.color = new Color(GUI.color.r, GUI.color.g, GUI.color.b, 0.4f);
                d.DrawLabel(textRect, "No Items Selected", CachedStyles.WizardSubBoxTitleStyle, DrawingAlignment.MiddleCenter);
                GUI.color = cacheColor;
                return;
        }

        var groupRect = rect.WithHeight(30);

        foreach (var group in Groups)
        {

            if (GUIHelpers.DoToolbarEx(group.Key, groupRect))
            {
                var itemRect = rect.WithHeight(17).Below(groupRect);

                foreach (var item in group)
                {

                    Rect inspBounds;
                    if (item.InspectorType == InspectorType.GraphItems)
                    {
                        itemRect = itemRect.WithHeight(30);
                    }
                    else if (item.InspectorType == InspectorType.TextArea)
                    {
                        itemRect = itemRect.WithHeight(60);
                    }
                    else
                    {
                        itemRect = itemRect.WithHeight(17);
                    }
                    d.DrawInspector(itemRect, item, EditorStyles.label);
                    itemRect = itemRect.Below(itemRect).Translate(0,3).WithHeight(17);
                }

                groupRect = groupRect.Below(itemRect.Above(itemRect));

            }
            else
            {
                groupRect = groupRect.Below(groupRect);
            }

        }
    }
Beispiel #9
0
        public override void OnGUI()
        {
            base.OnGUI();

            if (GUIHelpers.DoToolbarEx(LocaleText.FrameworkPackages))
            {
                GUILayout.BeginVertical("box");

                mEGORootLayout.DrawGUI();

                GUILayout.EndVertical();
            }
        }
Beispiel #10
0
 public void DrawInspector(Rect rect)
 {
     if (LastDebugEvent != null)
     {
         foreach (var obj in LastDebugEvent.Variables)
         {
             if (GUIHelpers.DoToolbarEx(obj.GetType().ToString()))
             {
                 var properties = obj.GetType().GetFields(BindingFlags.Default | BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
                 foreach (var property in properties)
                 {
                     var val = property.GetValue(obj);
                     if (val != null)
                     {
                         EditorGUILayout.LabelField(property.Name, val.ToString());
                     }
                 }
             }
         }
     }
 }
Beispiel #11
0
        public override void OnGUI()
        {
            base.OnGUI();

            if (GUIHelpers.DoToolbarEx("UI Kit Settings"))
            {
                GUILayout.BeginVertical("box");

                mUiKitSettingData.Namespace =
                    EditorGUIUtils.GUILabelAndTextField("Namespace", mUiKitSettingData.Namespace);
                mUiKitSettingData.UIScriptDir =
                    EditorGUIUtils.GUILabelAndTextField("UI Script Generate Dir", mUiKitSettingData.UIScriptDir);
                mUiKitSettingData.UIPrefabDir =
                    EditorGUIUtils.GUILabelAndTextField("UI Prefab Dir", mUiKitSettingData.UIPrefabDir);

                if (GUILayout.Button("Apply"))
                {
                    mUiKitSettingData.Save();
                }

                GUILayout.EndVertical();
            }
        }
Beispiel #12
0
    public override void OnGUIScrollView()
    {
        if (Event.current != null && Event.current.isKey && Event.current.keyCode == KeyCode.UpArrow && Event.current.type == EventType.KeyUp)
        {
            MoveDown();
        }
        if (Event.current != null && Event.current.isKey && Event.current.keyCode == KeyCode.DownArrow && Event.current.type == EventType.KeyUp)
        {
            MoveUp();
        }
        if (AllowNode)
        {
            if (
                GUIHelpers.DoTriggerButton(new UFStyle()
            {
                Label = "[NONE]",
                IsWindow = true,
                FullWidth = true,
                BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall
            }))
            {
                SelectedAction(null);
                IsClosing = true;
            }
        }
        if (ItemGroups == null)
        {
            return;
        }
        var index   = 0;
        var isFirst = true;

        foreach (var group in ItemGroups)
        {
            if (group.Any())
            {
                if (string.IsNullOrEmpty(_SearchText))
                {
                    if (GUIHelpers.DoToolbarEx(group.Key))
                    {
                        foreach (var item in group)
                        {
                            var item1 = item;
                            if (item == null)
                            {
                                continue;
                            }
                            if (
                                GUIHelpers.DoTriggerButton(new UFStyle()
                            {
                                Label = item.Title,
                                IsWindow = true,
                                FullWidth = true,

                                BackgroundStyle = index == HighlightedIndex ? ElementDesignerStyles.Item1 : ElementDesignerStyles.EventButtonStyleSmall
                            }))
                            {
                                SelectedAction(item1);
                                IsClosing = true;
                            }
                            if (index == HighlightedIndex && Event.current != null && Event.current.isKey && Event.current.keyCode == KeyCode.Return)
                            {
                                SelectedAction(item1);
                            }
                            isFirst = false;
                            index++;
                        }
                    }
                }
                else
                {
                    foreach (var item in group)
                    {
                        if (item == null)
                        {
                            continue;
                        }
                        var item1 = item;
                        if (GUIHelpers.DoTriggerButton(new UFStyle()
                        {
                            Label = item.Group + " : " + item.Title, IsWindow = true, FullWidth = true,
                            BackgroundStyle = index == HighlightedIndex ? ElementDesignerStyles.Item1 : ElementDesignerStyles.EventButtonStyleSmall
                        }))
                        {
                            SelectedAction(item1);
                            IsClosing = true;
                        }
                        if (index == HighlightedIndex && Event.current != null && Event.current.isKey && Event.current.keyCode == KeyCode.Return)
                        {
                            SelectedAction(item1);
                            IsClosing = true;
                        }
                        isFirst = false;
                        index++;
                    }
                }
            }
        }
    }
Beispiel #13
0
    public override void OnInspectorGUI()
    {
        GUIHelpers.IsInsepctor = true;
        DrawTitleBar("Scene Manager");

        base.OnInspectorGUI();
        if (EditorApplication.isPlaying || EditorApplication.isPlayingOrWillChangePlaymode)
        {
            //if (GUI.Button(GUIHelpers.GetRect(ElementDesignerStyles.ButtonStyle), "Serialize To String", ElementDesignerStyles.ButtonStyle))
            //{
            //    var sm = (target as SceneManager);

            //    sm.SaveState(new TextAssetStorage() { AssetPath = "Assets/TestData.txt" }, new JsonStream() { UseReferences = true });

            //}
            //if (GUI.Button(GUIHelpers.GetRect(ElementDesignerStyles.ButtonStyle), "Load From String", ElementDesignerStyles.ButtonStyle))
            //{
            //    var sm = (target as SceneManager);
            //    sm.LoadState(new TextAssetStorage() { AssetPath = "Assets/TestData.txt" }, new JsonStream() { UseReferences = true });

            //}
            if (GUIHelpers.DoToolbarEx("Persistable Views"))
            {
                foreach (var viewBase in GameManager.ActiveSceneManager.PersistantViews)
                {
                    if (viewBase == null)
                    {
                        continue;
                    }
                    if (GUIHelpers.DoTriggerButton(new UFStyle(viewBase.Identifier + ": " + viewBase.name,
                                                               ElementDesignerStyles.EventButtonStyleSmall, null, null, null, false,
                                                               TextAnchor.MiddleCenter)
                    {
                    }))
                    {
                        //var fileStorage = new TextAssetStorage();
                        var stringStorage = new StringSerializerStorage();
                        var stream        = new JsonStream();
                        viewBase.Write(stream);
                        stringStorage.Save(stream);
                        Debug.Log(stringStorage);
                    }
                }
            }
            if (GUIHelpers.DoToolbarEx("Persistable View-Models"))
            {
                foreach (var viewBase in GameManager.ActiveSceneManager.PersistantViewModels)
                {
                    if (viewBase == null)
                    {
                        continue;
                    }
                    if (GUIHelpers.DoTriggerButton(new UFStyle(viewBase.Identifier + ": " + viewBase.GetType().Name,
                                                               ElementDesignerStyles.EventButtonStyleSmall, null, null, null, false,
                                                               TextAnchor.MiddleCenter)
                    {
                    }))
                    {
                        //var fileStorage = new TextAssetStorage();
                        var stringStorage = new StringSerializerStorage();
                        var stream        = new JsonStream();
                        viewBase.Write(stream);
                        stringStorage.Save(stream);
                        Debug.Log(stringStorage);
                    }
                }
            }
        }

        GUIHelpers.IsInsepctor = false;
    }
        public override void OnInspectorGUI()
        {
            GUIHelpers.IsInspector = true;
            //base.OnInspectorGUI();
            DrawTitleBar("UFrame MVVM Kernel");
            serializedObject.Update();

            if (!EditorBuildSettings.scenes.Any(s => {
                return(s.path.EndsWith("KernelScene.unity"));
            }))
            {
                Warning("Please add this scene to the build settings!");
            }

            if (Application.isPlaying)
            {
                if (!uFrameKernel.IsKernelLoaded)
                {
                    Warning("Kernel is not loaded!");
                }
                if (uFrameKernel.Instance == null)
                {
                    return;
                }

                if (GUIHelpers.DoToolbarEx("Services"))
                {
                    foreach (ISystemService instance in uFrameKernel.Instance.Services)
                    {
                        if (GUIHelpers.DoTriggerButton(new UFStyle {
                            BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall,
                            Label = string.Format("{0}", instance.GetType().Name)
                        }))
                        {
                            Selection.activeGameObject = (instance as MonoBehaviour).gameObject;
                        }
                    }
                }

                if (GUIHelpers.DoToolbarEx("Systems"))
                {
                    foreach (ISystemLoader instance in uFrameKernel.Instance.SystemLoaders)
                    {
                        if (GUIHelpers.DoTriggerButton(new UFStyle {
                            BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall,
                            Label = string.Format("{0}", instance.GetType().Name.Replace("Loader", ""))
                        }))
                        {
                            Selection.activeGameObject = (instance as MonoBehaviour).gameObject;
                        }
                    }
                }

                if (GUIHelpers.DoToolbarEx("Scene Loaders"))
                {
                    if (GUIHelpers.DoTriggerButton(new UFStyle {
                        BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall,
                        Label = string.Format("{0}", "DefaultSceneLoader")
                    }))
                    {
                    }

                    //foreach (var instance in uFrameMVVMKernel.Instance.SceneLoaders)
                    //{
                    //    if (GUIHelpers.DoTriggerButton(new UFStyle()
                    //    {
                    //        BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall,
                    //        Label = string.Format("{0}", instance.GetType().Name)
                    //    }))
                    //    {
                    //        Selection.activeGameObject = (instance as MonoBehaviour).gameObject;
                    //    }
                    //}
                }

                if (GUIHelpers.DoToolbarEx(String.Format("Dependency Container - Instances ({0})", uFrameKernel.Container.Instances.Count), defOn: false, prefsKey: "Dependency Container - Instances"))
                {
                    foreach (KeyValuePair <Tuple <Type, string>, object> instance in uFrameKernel.Container.Instances)
                    {
                        if (GUIHelpers.DoTriggerButton(new UFStyle {
                            Label =
                                string.Format("'{0}': {1}->{2}", instance.Key.Item1, instance.Key.Item2,
                                              instance.Value.GetType().Name),
                            BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall
                        }))
                        {
                            Debug.Log(instance.Value);
                        }
                    }
                }

                if (GUIHelpers.DoToolbarEx(String.Format("Dependency Container - Mappings ({0})", uFrameKernel.Container.Mappings.Count), defOn: false, prefsKey: "Dependency Container - Mappings"))
                {
                    foreach (KeyValuePair <Tuple <Type, string>, Type> instance in uFrameKernel.Container.Mappings)
                    {
                        if (GUIHelpers.DoTriggerButton(new UFStyle {
                            BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall,
                            Label = string.Format("{0}: {1}->{2}", instance.Key.Item2, instance.Key.Item1.Name, instance.Value.Name)
                        }))
                        {
                        }
                    }
                }
            }

            if (serializedObject.ApplyModifiedProperties())
            {
                //var t = Target as GameManager;
                //t.ApplyRenderSettings();
            }
            GUIHelpers.IsInspector = false;
        }
Beispiel #15
0
    public static void uFrameSettings()
    {
        ScrollPosition = EditorGUILayout.BeginScrollView(ScrollPosition);
        var s = InvertGraphEditor.Settings;

        if (s != null)
        {
            if (GUIHelpers.DoToolbarEx("Color Settings"))
            {
                s.BackgroundColor = EditorGUILayout.ColorField("Background Color", s.BackgroundColor);
                EditorGUI.BeginChangeCheck();
                s.TabTextColor     = EditorGUILayout.ColorField("Tab Text Color", s.TabTextColor);
                s.SectionItemColor = EditorGUILayout.ColorField("Item Text Color", s.SectionItemColor);
                //s.SectionItemTypeColor = EditorGUILayout.ColorField("Item Type Text Color", s.SectionItemTypeColor);
                s.SectionTitleColor = EditorGUILayout.ColorField("Section Title Color", s.SectionTitleColor);
                if (EditorGUI.EndChangeCheck())
                {
                    ElementDesignerStyles.TabStyle             = null;
                    ElementDesignerStyles.ItemTextEditingStyle = null;
                    ElementDesignerStyles.HeaderStyle          = null;
                    ElementDesignerStyles.GraphTitleLabel      = null;
                }
                s.UseGrid = EditorGUILayout.BeginToggleGroup("Grid", s.UseGrid);

                s.GridLinesColor          = EditorGUILayout.ColorField("Grid Lines Color", s.GridLinesColor);
                s.GridLinesColorSecondary = EditorGUILayout.ColorField("Grid Lines Secondary Color",
                                                                       s.GridLinesColorSecondary);
                EditorGUILayout.EndToggleGroup();


                //s.AssociationLinkColor = EditorGUILayout.ColorField("Association Link Color", s.AssociationLinkColor);
                //s.DefinitionLinkColor = EditorGUILayout.ColorField("Definition Link Color", s.DefinitionLinkColor);
                //s.InheritanceLinkColor = EditorGUILayout.ColorField("Inheritance Link Color", s.InheritanceLinkColor);
                //s.SubSystemLinkColor = EditorGUILayout.ColorField("SubSystem Link Color", s.SubSystemLinkColor);
                //s.TransitionLinkColor = EditorGUILayout.ColorField("Transition Link Color", s.TransitionLinkColor);
                //s.ViewLinkColor = EditorGUILayout.ColorField("View Link Color", s.ViewLinkColor);
            }
        }
        else
        {
            EditorGUILayout.HelpBox("Settings not available.", MessageType.Info);
        }

        //if (GUIHelpers.DoToolbarEx("Plugins - Enabled"))
        //{
        foreach (
            var plugin in InvertApplication.Plugins.Where(p => !p.Required && !p.Ignore).OrderBy(p => p.Title))     //
        {
            //  var totalLoadTime = (plugin.InitializeTime);

            //EditorGUILayout.LabelField("Initializing Time", string.Format("{0} Seconds {1} Milliseconds" ,totalLoadTime.Seconds,totalLoadTime.Milliseconds));
            //EditorGUILayout.LabelField("Load Time", string.Format("{0} Seconds {1} Milliseconds" ,plugin.LoadTime.Seconds,plugin.LoadTime.Milliseconds));
            DoPlugin(plugin);
        }
        //}
        //if (GUIHelpers.DoToolbarEx("Plugins - Disabled"))
        //{
        //    foreach (
        //        var plugin in InvertApplication.Plugins.Where(p => !p.Required && !p.Enabled).OrderBy(p => p.LoadPriority))
        //    {
        //        DoPlugin(plugin);
        //    }
        //}
        //if (GUIHelpers.DoToolbarEx("Registered Nodes"))
        //{
        //    foreach (var plugin in InvertGraphEditor.Container.ResolveAll<NodeConfigBase>())
        //    {
        //        GUIHelpers.DoTriggerButton(new UFStyle(plugin.Name + " : " + plugin.NodeType.Name,
        //            ElementDesignerStyles.EventButtonStyleSmall)
        //        {
        //            IsWindow = true,
        //            FullWidth = true
        //        });
        //    }
        //}
        //if (GUIHelpers.DoToolbarEx("Loaded Assemblies"))
        //{
        //    foreach (var plugin in InvertApplication.CachedAssemblies)
        //    {
        //        GUIHelpers.DoTriggerButton(new UFStyle(plugin.FullName, ElementDesignerStyles.EventButtonStyleSmall)
        //        {
        //            IsWindow = true,
        //            FullWidth = true
        //        });
        //    }
        //}
        EditorGUILayout.EndScrollView();
    }
Beispiel #16
0
    private void DrawPlayModeGui()
    {
        if (EditorApplication.isPlaying)
        {
            var t = target as ViewBase;
            if (t != null && t.ViewModelObject != null)
            {
                if (GUIHelpers.DoToolbarEx("View Model Properties"))
                {
                    EditorGUILayout.Space();
                    EditorGUILayout.LabelField("Id", t.ViewModelObject.Identifier);
                    EditorGUILayout.LabelField("# References", t.ViewModelObject.References.ToString());
                    DoViewModelGUI(t.ViewModelObject);

                    //foreach (var p in t.ViewModelObject.Properties)
                    //{
                    //    var serialized = p.Value.Serialize().ToString();
                    //    if (serialized.Length > 100)
                    //    {
                    //        serialized = serialized.Substring(0, 100);
                    //    }
                    //    EditorGUILayout.LabelField(p.Key.Replace("_", "").Replace("Property", ""), serialized);
                    //    //if (p.Value.ValueType.IsPrimitive)
                    //    //{
                    //    //    EditorGUILayout.LabelField(p.Key, p.Value.ObjectValue.ToString());
                    //    //}
                    //    //else
                    //    //{
                    //    //    EditorGUILayout.LabelField(p.Key, p.Value.Serialize());
                    //    //}
                    //}
                }

                if (Commands != null)
                {
                    if (GUIHelpers.DoToolbarEx("Commands"))
                    {
                        foreach (var command in Commands)
                        {
                            var type = command.ParameterType;

                            if (type != null && type != typeof(void))
                            {
                                EditorGUI.BeginChangeCheck();
                                object newValue     = null;
                                object currentValue = ((IParameterCommand)command.Command).Parameter ?? GetDefaultValue(type);//Activator.CreateInstance(type);

                                var propertyName = "Parameter";
                                var isEnum       = false;
                                newValue = DoTypeInspector(type, propertyName, currentValue, isEnum);

                                if (EditorGUI.EndChangeCheck())
                                {
                                    ((IParameterCommand)command.Command).Parameter = newValue;
                                }
                            }
                            if (GUI.Button(GUIHelpers.GetRect(ElementDesignerStyles.ButtonStyle), command.Name,
                                           ElementDesignerStyles.ButtonStyle))
                            {
                                GameManager.CommandDispatcher.ExecuteCommand(command.Command, ((IParameterCommand)command.Command).Parameter);
                            }
                        }
                        //foreach (var command in Commands)
                        //{
                        //    if (GUI.Button(GUIHelpers.GetRect(ElementDesignerStyles.ButtonStyle), command.Key,
                        //        ElementDesignerStyles.ButtonStyle))
                        //    {
                        //        var commandWith = command.Value as ICommandWith<object>;



                        //        Target.ExecuteCommand(command.Value);
                        //    }
                        //}
                    }
                }
                //if (t.ViewModelObject != null)
                //{
                //    foreach (var item in t.ViewModelObject.Bindings)
                //    {
                //        if (GUIHelpers.DoToolbarEx(item.Key == -1
                //            ? "Controller"
                //            : EditorUtility.InstanceIDToObject(item.Key).name))
                //        {
                //            foreach (var binding in item.Value)
                //            {

                //                if (GUIHelpers.DoTriggerButton(new UFStyle()
                //                {
                //                    Label = binding.GetType().Name + ": " + binding.ModelMemberName,
                //                    //IconStyle = bi
                //                }))
                //                {

                //                }
                //            }

                //        }


                //    }
                //}
            }
            else
            {
                EditorGUILayout.HelpBox("View Model not initialized yet.", MessageType.Info);
                Repaint();
            }
        }
        Repaint();
        return;
    }
Beispiel #17
0
        private void DrawPlayModeGui()
        {
            if (EditorApplication.isPlaying)
            {
                var t = target as ViewBase;
                if (t != null && t.ViewModelObject != null)
                {
                    if (GUIHelpers.DoToolbarEx("View Model Properties"))
                    {
                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Id", t.ViewModelObject.Identifier);
                        EditorGUILayout.LabelField("# References", t.ViewModelObject.References.ToString());
                        DoViewModelGUI(t.ViewModelObject);
                    }

                    if (Commands != null)
                    {
                        if (GUIHelpers.DoToolbarEx("Commands"))
                        {
                            foreach (var command in Commands)
                            {
                                var type = command.ParameterType;

                                if (type != null && type != typeof(void))
                                {
                                    // TODO REWRITE PARAMETERS
                                    //if (!(command.Command is IParameterCommand)) continue;
                                    //EditorGUI.BeginChangeCheck();
                                    //object newValue = null;
                                    //object currentValue = ((IParameterCommand)command.Command).Parameter ?? GetDefaultValue(type);//Activator.CreateInstance(type);

                                    //var propertyName = "Parameter";
                                    //var isEnum = false;
                                    //newValue = DoTypeInspector(type, propertyName, currentValue, isEnum);

                                    //if (EditorGUI.EndChangeCheck())
                                    //{
                                    //    ((IParameterCommand) command.Command).Parameter = newValue;
                                    //}
                                }
                                if (GUI.Button(GUIHelpers.GetRect(ElementDesignerStyles.ButtonStyle), command.Name,
                                               ElementDesignerStyles.ButtonStyle))
                                {
                                    command.Signal.Publish();
                                }
                            }
                            //foreach (var command in Commands)
                            //{
                            //    if (GUI.Button(GUIHelpers.GetRect(ElementDesignerStyles.ButtonStyle), command.Key,
                            //        ElementDesignerStyles.ButtonStyle))
                            //    {
                            //        var commandWith = command.Value as ICommandWith<object>;



                            //        Target.ExecuteCommand(command.Value);
                            //    }
                            //}
                        }
                    }
                    //if (t.ViewModelObject != null)
                    //{
                    //    foreach (var item in t.ViewModelObject.Bindings)
                    //    {
                    //        if (GUIHelpers.DoToolbarEx(item.Key == -1
                    //            ? "Controller"
                    //            : EditorUtility.InstanceIDToObject(item.Key).name))
                    //        {
                    //            foreach (var binding in item.Value)
                    //            {

                    //                if (GUIHelpers.DoTriggerButton(new UFStyle()
                    //                {
                    //                    Label = binding.GetType().Name + ": " + binding.ModelMemberName,
                    //                    //IconStyle = bi
                    //                }))
                    //                {

                    //                }
                    //            }

                    //        }


                    //    }
                    //}
                }
                else
                {
                    EditorGUILayout.HelpBox("View Model not initialized yet.", MessageType.Info);
                    Repaint();
                }
            }
            Repaint();
            return;
        }
Beispiel #18
0
        public override void OnGUI()
        {
            base.OnGUI();

            if (GUIHelpers.DoToolbarEx("Framework Packages"))
            {
                mRootLayout.OnGUI();

                GUILayout.BeginVertical("box");

                mFrameworkInfoLayout.OnGUI();

                // 这里开始具体的内容
                GUILayout.BeginHorizontal("box");
                GUILayout.Label("Package", GUILayout.Width(150));
                GUILayout.Label("Server", GUILayout.Width(80));
                GUILayout.Label("Local", GUILayout.Width(80));
                GUILayout.Label("Access Right", GUILayout.Width(80));
                GUILayout.Label("Doc", new GUIStyle {
                    alignment = TextAnchor.MiddleCenter, fixedWidth = 40f
                });
                GUILayout.Label("Action", new GUIStyle {
                    alignment = TextAnchor.MiddleCenter, fixedWidth = 100f
                });
                GUILayout.Label("Release Note", new GUIStyle {
                    alignment = TextAnchor.MiddleCenter, fixedWidth = 100f
                });
                GUILayout.EndHorizontal();

                GUILayout.BeginVertical("box");

                mScrollPos = GUILayout.BeginScrollView(mScrollPos, false, true, GUILayout.Height(240));

                foreach (var packageData in SelectedPackageType)
                {
                    GUILayout.Space(2);
                    GUILayout.BeginHorizontal();
                    GUILayout.Label(packageData.Name, GUILayout.Width(150));
                    GUILayout.Label(packageData.Version, GUILayout.Width(80));
                    var installedPackage = InstalledPackageVersions.FindVersionByName(packageData.Name);
                    GUILayout.Label(installedPackage != null ? installedPackage.Version : " ", GUILayout.Width(80));
                    GUILayout.Label(packageData.AccessRight.ToString(), GUILayout.Width(80));

                    if (packageData.DocUrl.IsNotNullAndEmpty())
                    {
                        if (GUILayout.Button("Doc", GUILayout.Width(40)))
                        {
                            Application.OpenURL(packageData.DocUrl);
                        }
                    }
                    else
                    {
                        GUILayout.Space(40);
                    }

                    if (installedPackage == null)
                    {
                        if (GUILayout.Button("Import", GUILayout.Width(90)))
                        {
                            EditorActionKit.ExecuteNode(new InstallPackage(packageData));

                            PackageApplication.Container.Resolve <PackageKitWindow>().Close();
                        }
                    }
                    else if (installedPackage != null && packageData.VersionNumber > installedPackage.VersionNumber)
                    {
                        if (GUILayout.Button("Update", GUILayout.Width(90)))
                        {
                            var path = Application.dataPath.Replace("Assets", packageData.InstallPath);

                            if (Directory.Exists(path))
                            {
                                Directory.Delete(path, true);
                            }

                            EditorActionKit.ExecuteNode(new InstallPackage(packageData));

                            PackageApplication.Container.Resolve <PackageKitWindow>().Close();
                        }
                    }
                    else if (installedPackage.IsNotNull() &&
                             packageData.VersionNumber == installedPackage.VersionNumber)
                    {
                        if (GUILayout.Button("Reimport", GUILayout.Width(90)))
                        {
                            var path = Application.dataPath.Replace("Assets", packageData.InstallPath);

                            if (Directory.Exists(path))
                            {
                                Directory.Delete(path, true);
                            }

                            EditorActionKit.ExecuteNode(new InstallPackage(packageData));
                            PackageApplication.Container.Resolve <PackageKitWindow>().Close();
                        }
                    }
                    else if (installedPackage != null)
                    {
                        GUILayout.Space(94);
                    }

                    if (GUILayout.Button("Release Notes", GUILayout.Width(100)))
                    {
                        ReadmeWindow.Init(packageData.readme, packageData.PackageVersions.First());
                    }

                    GUILayout.EndHorizontal();
                }

                GUILayout.EndScrollView();
                GUILayout.EndVertical();
                GUILayout.EndVertical();
            }
        }
Beispiel #19
0
    public void DrawInspector(Object target)
    {
        GUIHelpers.IsInsepctor = true;
        var entityComponent = target as Entity;

        if (entityComponent != null)
        {
            //if (Repository != null)
            //{
            //    EditorGUILayout.HelpBox("0 = Auto Assign At Runtime", MessageType.Info);

            //}
            //if (GUILayout.Button("Create New Component"))
            //{
            //    if (TreeModel == null)
            //    {
            //        TreeModel = new TreeViewModel()
            //        {
            //            Data = Container.Resolve<IRepository>().AllOf<ModuleNode>().Select(item=>new SelectionMenuItem(item,
            //                () =>
            //                {


            //                })).Cast<IItem>().ToList()
            //        };
            //    }
            //    else
            //    {
            //        TreeModel = null;
            //    }

            //}
            //if (TreeModel != null)
            //{
            //     var lastRect = GUILayoutUtility.GetLastRect();
            //    var rect = GUILayoutUtility.GetRect(lastRect.x, lastRect.y, 300, 500);

            //    Signal<IDrawTreeView>(_=>_.DrawTreeView(rect,TreeModel,(p,x)=>{
            //      var item = (x as SelectionMenuItem).DataObject as IDiagramNode;
            //        Execute(new NavigateToNodeCommand()
            //        {
            //            Node = item as IDiagramNode
            //        });
            //        Execute(new CreateNodeCommand()
            //        {
            //            NodeType = typeof(ComponentNode),
            //            GraphData = InvertGraphEditor.CurrentDiagramViewModel.GraphData,

            //        });
            //        TreeModel = null;
            //    }));
            //}
        }
        var component = target as EcsComponent;

        //if (component != null)
        //{


        if (Repository != null)
        {
            var attribute = target.GetType().GetCustomAttributes(typeof(uFrameIdentifier), true).OfType <uFrameIdentifier>().FirstOrDefault();

            if (attribute != null)
            {
                var item = Repository.GetSingle <ComponentNode>(attribute.Identifier);
                if (component != null)
                {
                    var inspectorBounds = new Rect(0, 0, Screen.width, Screen.height);
                    //var iconBounds = new Rect().WithSize(16, 16).InnerAlignWithUpperRight(inspectorBounds);
                    //Drawer.DrawImage(iconBounds,"CommandIcon",true);

                    //if (GUIHelpers.DoToolbarEx("System Handlers"))
                    //{
                    //    foreach (
                    //   var handlerNode in
                    //       Repository.All<HandlerNode>()
                    //           .Where(p => p.EntityGroup != null && p.EntityGroup.Item == item))
                    //    {
                    //        if (GUILayout.Button(handlerNode.Name))
                    //        {
                    //            Execute(new NavigateToNodeCommand()
                    //            {
                    //                Node = handlerNode,
                    //                Select = true
                    //            });
                    //        }

                    //    }
                    //}
                    if (GUIHelpers.DoToolbarEx("uFrame Designer"))
                    {
                        var toolbarButton = ComponentEditorToolbarButtonStyle;

                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label("Serving Handlers:");
                        EditorGUILayout.EndHorizontal();

                        foreach (
                            var handlerNode in
                            Repository.All <HandlerNode>()
                            .Where(p => p.HandlerInputs.Any(x => x.Item != null && x.Item.SelectComponents.Contains(item))))
                        {
                            EditorGUILayout.BeginHorizontal();

                            var text = handlerNode.Name;
                            if (GUILayout.Button(text, toolbarButton))
                            {
                                Execute(new NavigateToNodeCommand()
                                {
                                    Node   = handlerNode,
                                    Select = true
                                });
                            }

                            var descRect = GUILayoutUtility.GetLastRect();


                            //GUILayout.FlexibleSpace();

                            var meta = handlerNode.Meta as EventMetaInfo;
                            if (meta != null && meta.Dispatcher &&
                                component.gameObject.GetComponent(meta.SystemType) == null)
                            {
                                Drawer.DrawImage(new Rect().WithSize(16, 16).InnerAlignWithCenterLeft(descRect).Translate(4, 0), "RedDotIcon", true);

                                var cb = GUI.backgroundColor;
                                GUI.backgroundColor = CachedStyles.GetColor(NodeColor.Carrot);
                                //if (GUILayout.Button("+ " + meta.SystemType.Name,EditorStyles.toolbarButton))
                                if (GUILayout.Button(new GUIContent("Add", string.Format("Add {0} which is used to invoke the corresponding event", meta.SystemType.Name)), EditorStyles.toolbarButton, GUILayout.Width(60)))
                                {
                                    component.gameObject.AddComponent(meta.SystemType);
                                }
                                GUI.backgroundColor = cb;
                            }
                            else
                            {
                                Drawer.DrawImage(new Rect().WithSize(16, 16).InnerAlignWithCenterLeft(descRect).Translate(4, 0), "GreenDotIcon", true);
                            }

                            EditorGUILayout.EndHorizontal();
                        }

                        EditorGUILayout.BeginHorizontal();
                        GUILayout.Label("");
                        EditorGUILayout.EndHorizontal();
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        var cachedBackgroundColor = GUI.backgroundColor;
                        GUI.backgroundColor = CachedStyles.GetColor(NodeColor.SgiTeal);
                        if (GUILayout.Button("Edit In Designer", EditorStyles.toolbarButton))
                        {
                            Execute(new NavigateToNodeCommand()
                            {
                                Node   = item,
                                Select = true
                            });
                        }
                        GUI.backgroundColor = cachedBackgroundColor;
                        EditorGUILayout.EndHorizontal();
                    }
                }
            }
        }

        //}
    }
Beispiel #20
0
    public override void OnInspectorGUI()
    {
        GUIHelpers.IsInsepctor = true;
        //base.OnInspectorGUI();
        DrawTitleBar("Game Manager");
        serializedObject.Update();

        if (Application.isPlaying)
        {
            if (GUIHelpers.DoToolbarEx("Dependency Container - Instances"))
            {
                foreach (var instance in GameManager.Container.Instances)
                {
                    if (GUIHelpers.DoTriggerButton(new UFStyle()
                    {
                        Label =
                            string.Format("'{0}': {1}->{2}", instance.Name, instance.Base.Name,
                                          instance.Instance.GetType().Name),
                        BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall
                    }))
                    {
                        Debug.Log(instance.Instance);
                    }
                }
            }

            if (GUIHelpers.DoToolbarEx("Dependency Container - Mappings"))
            {
                foreach (var instance in GameManager.Container.Mappings)
                {
                    if (GUIHelpers.DoTriggerButton(new UFStyle()
                    {
                        BackgroundStyle = ElementDesignerStyles.EventButtonStyleSmall,
                        Label = string.Format("{0}: {1}->{2}", instance.Name, instance.From.Name, instance.To.Name)
                    }))
                    {
                    }
                }
            }
        }
        else
        {
            EditorGUILayout.HelpBox("The View to load when the scene starts.", MessageType.None);
            var p = serializedObject.FindProperty("_Start");
            if (p.objectReferenceValue == null)
            {
                EditorGUILayout.HelpBox("Error start scene manager is not set.", MessageType.Error);
            }
            EditorGUILayout.PropertyField(p);
            EditorGUILayout.HelpBox("The loading scene that will be used when switching scenes via GameManager.SwitchSceneAndLevel<View>().", MessageType.None);
            p = serializedObject.FindProperty("_LoadingLevel");
            EditorGUILayout.PropertyField(p);
            EditorGUILayout.HelpBox("Pro Users: Will use non asynchronous loading.", MessageType.None);
            p = serializedObject.FindProperty("_DontUseAsyncLoading");
            EditorGUILayout.PropertyField(p);
            p = serializedObject.FindProperty("_ShowLogs");
            EditorGUILayout.PropertyField(p);

            EditorGUILayout.HelpBox("The render settings that will apply when the scene loads.", MessageType.None);
            //_RenderSettingsOpen = Toggle("Render Settings", _RenderSettingsOpen);
            if (GUIHelpers.DoToolbarEx("Render Settings"))
            {
                p = serializedObject.FindProperty("_Fog");
                EditorGUILayout.PropertyField(p);
                p = serializedObject.FindProperty("_FogColor");
                EditorGUILayout.PropertyField(p);
                p = serializedObject.FindProperty("_FogMode");
                EditorGUILayout.PropertyField(p);
                p = serializedObject.FindProperty("_FogDensity");
                EditorGUILayout.PropertyField(p);
                p = serializedObject.FindProperty("_LinearFogStart");
                EditorGUILayout.PropertyField(p);
                p = serializedObject.FindProperty("_LinearFogEnd");
                EditorGUILayout.PropertyField(p);
                p = serializedObject.FindProperty("_AmbientLight");
                EditorGUILayout.PropertyField(p);
                p = serializedObject.FindProperty("_SkyboxMaterial");
                EditorGUILayout.PropertyField(p);
                p = serializedObject.FindProperty("_HaloStrength");
                EditorGUILayout.PropertyField(p);
                p = serializedObject.FindProperty("_FlareStrength");
                EditorGUILayout.PropertyField(p);
                if (GUILayout.Button("Load From Scene"))
                {
                    var t = Target as GameManager;
                    t.LoadRenderSettings();
                }
            }
        }

        if (serializedObject.ApplyModifiedProperties())
        {
            //var t = Target as GameManager;
            //t.ApplyRenderSettings();
        }
        GUIHelpers.IsInsepctor = false;
    }