Beispiel #1
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;
        //}
    }
    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;
        //}
      
    }