Ejemplo n.º 1
0
        public static void DrawGUI()
        {
#if UNITY_2018_3_OR_NEWER
            using (new GUILayout.HorizontalScope()) {
                if (GUILayout.Button("add"))
                {
                    var m    = new GenericMenu();
                    var list = AssemblieUtils.SubclassesOf <EditorWindow>()
                               .OrderBy(x => x.Assembly.FullName)
                               .ThenBy(x => x.FullName);
                    foreach (var p in list)
                    {
                        var asmName = p.Assembly.FullName.Split(',')[0];
                        m.AddItem($"{asmName[ 0 ]}/{asmName}/{p.Name}", reg, p);
                    }
                    m.DropDownAtMousePosition();
                    void reg(object context)
                    {
                        var t = (Type)context;

                        if (E.i.utilityWindowSettingsData.Find(x => x.TypeFullName == t.FullName) == null)
                        {
                            E.i.utilityWindowSettingsData.Add(new UtilityWindowSettingsData {
                                Enable = true, TypeFullName = t.FullName
                            });
                        }
                        CheckNullType();
                        E.Save();
                    }
                }

                if (GUILayout.Button("remove"))
                {
                    E.i.utilityWindowSettingsData = new List <UtilityWindowSettingsData>();
                }
            }


            UtilityWindowSettingsData _remove = null;

            foreach (var p in E.i.utilityWindowSettingsData)
            {
                EditorGUI.BeginChangeCheck();
                p.Enable = HEditorGUILayout.ToggleBox($"{p.GetUtilityType().FullName}", p.Enable, EditorIcon.minus, OnButton);
                if (EditorGUI.EndChangeCheck())
                {
                    E.Save();
                }
                void OnButton()
                {
                    _remove = p;
                }
            }
            if (_remove != null)
            {
                E.i.utilityWindowSettingsData.Remove(_remove);
                E.Save();
            }
#endif
        }
Ejemplo n.º 2
0
        /////////////////////////////////////////

        public static void CallEvent(Type tt)
        {
            foreach (var func in AssemblieUtils.GetAllMethodsWithAttribute(tt))
            {
                func.Invoke(null, null);
            }
        }
Ejemplo n.º 3
0
 public static void DrawGUI()
 {
     if (method1 == null)
     {
         method1 = AssemblieUtils.GetAllMethodsWithAttribute <Hananoki_BuildStartProcess>().ToArray();
         method2 = AssemblieUtils.GetAllMethodsWithAttribute <Hananoki_BuildPreProcess>().ToArray();
         method3 = AssemblieUtils.GetAllMethodsWithAttribute <Hananoki_BuildPostProcess>().ToArray();
     }
     var _ = new (MethodInfo[], string)[] {
Ejemplo n.º 4
0
        void OnEnable()
        {
            s_instance = this;

            m_HorizontalSplitter = new UnityEditorSplitterState(0.3f, 0.7f);

            m_treeView = new SettingsTreeView();

            var settingsMethods = AssemblieUtils.GetAllMethodsWithAttribute <HananokiSettingsRegister>();

            s_settingsItem = settingsMethods.Select(x => (SettingsItem)x.Invoke(null, null)).ToArray();
            //foreach( var p in settingsMethods ) {
            //	//Debug.Log( p.FullName );
            //}
            //if( s_settingsItem == null ) {
            //	var lst = new System.Collections.Generic.List<SettingsItem>();
            //	var t = typeof( SettingsClass );
            //	foreach( Assembly assembly in AppDomain.CurrentDomain.GetAssemblies() ) {
            //		try {
            //			foreach( Type type in assembly.GetTypes() ) {
            //				try {
            //					if( type.GetCustomAttribute( t ) == null ) continue;
            //					var mm = R.Methods( typeof( SettingsMethod ), type.FullName, assembly.FullName.Split( ',' )[ 0 ] );
            //					//s_localizeEvent.AddRange( mm );
            //					var item = (SettingsItem) mm[ 0 ].Invoke( null, null );
            //					lst.Add( item );
            //				}
            //				catch( Exception ee ) {
            //					Debug.LogException( ee );
            //				}
            //			}
            //		}
            //		catch( ReflectionTypeLoadException ) {
            //		}
            //		catch( Exception e ) {
            //			Debug.LogError( e );
            //		}
            //	}
            //	s_settingsItem = lst.ToArray();
            //}

            if (s_settingsItem != null)
            {
                var tot = s_settingsItem.OrderBy(x => x.displayName).ToArray();
                foreach (var item in tot)
                {
                    m_treeView.AddItem(item);
                }
            }

            m_treeView.ReloadAndSorting();
            //m_treeView.ExpandAll();
            selectionOpen = true;
        }
Ejemplo n.º 5
0
        /////////////////////////////////////////
        static SceneViewTools()
        {
            E.Load();
            SceneViewUtils.AddGUI(OnSceneGUI);
            //SceneView.duringSceneGui -= OnSceneGUI;
            //SceneView.duringSceneGui += OnSceneGUI;

            EditorSceneManager.sceneOpened -= OnSceneOpened;
            EditorSceneManager.sceneOpened += OnSceneOpened;

            Selection.selectionChanged -= OnSelectionChanged;
            Selection.selectionChanged += OnSelectionChanged;
            OnSelectionChanged();

#if UNITY_2019_1_OR_NEWER
            ToolManager.activeToolChanged += OnActiveToolChanged;
#endif


            m_shortCuts    = new Hashtable();
            m_componetTool = new Hashtable();

            foreach (var minfo in AssemblieUtils.GetAllMethodsWithAttribute <Hananoki_SceneView_ComponentButton>())
            {
                foreach (var cus in minfo.GetCustomAttributes(true))
                {
                    if (typeof(Hananoki_SceneView_ComponentButton) != cus.GetType())
                    {
                        continue;
                    }
                    var atb = (Hananoki_SceneView_ComponentButton)cus;

                    m_shortCuts.Add(atb.type, (Action)Delegate.CreateDelegate(typeof(Action), null, minfo));
                    break;
                }
            }
            foreach (var type in AssemblieUtils.GetAllTypesWithAttribute <Hananoki_SceneView_ComponentTool>())
            {
                foreach (var cAtb in type.GetCustomAttributes(true))
                {
                    if (typeof(Hananoki_SceneView_ComponentTool) != cAtb.GetType())
                    {
                        continue;
                    }
                    var atb = (Hananoki_SceneView_ComponentTool)cAtb;

                    m_componetTool.Add(atb.type, (SceneViewComponentTool)Activator.CreateInstance(type));
                    break;
                }
            }


            InitDragMouse();
        }
Ejemplo n.º 6
0
        public Type[] GetScriptableObjectTypes()
        {
            var assembliesFindOptions = new AssembliesFindOptions {
                AssembliesPrefixesToSkip = AssembliesPrefixesToSkip
            };
            var assemblies = AssemblieUtils.GetAssemblies(assembliesFindOptions);

            var typeFindOptions = new TypeFindOptions {
                TargetType        = TargetType,
                WrongTypes        = WrongTypes,
                WrongTypePrefixes = WrongTypePrefixes
            };
            var result = TypeUtils.GetAllTypes(assemblies, typeFindOptions);

            return(result);
        }
Ejemplo n.º 7
0
        public static void DrawGUI()
        {
            var method1 = AssemblieUtils.GetAllMethodsWithAttribute <Hananoki_OnOpenAsset>().ToArray();

            Helper.New(ref E.i.m_enableOnOpen);

            foreach (var p in method1)
            {
                var cus = p.GetCustomAttributes(typeof(Hananoki_OnOpenAsset), false).OfType <Hananoki_OnOpenAsset>().ToList();
                //cus.Find(x=>)
                ScopeHorizontal.Begin(EditorStyles.helpBox);
                ScopeVertical.Begin(GUILayout.Height(40), GUILayout.Width(20));
                GUILayout.FlexibleSpace();

                var hash = p.GetHash_OnOpenAsset();
                int idx  = E.i.m_enableOnOpen.IndexOf(hash);

                ScopeChange.Begin();
                var _enable = EditorGUILayout.Toggle(0 <= idx, GUILayout.Width(20));
                if (ScopeChange.End())
                {
                    if (_enable)
                    {
                        E.i.m_enableOnOpen.Add(hash);
                    }
                    else
                    {
                        E.i.m_enableOnOpen.Remove(hash);
                    }
                    E.Save();
                    Association.MakeMethods(true);
                }

                GUILayout.FlexibleSpace();
                ScopeVertical.End();
                ScopeVertical.Begin();


                EditorGUILayout.LabelField(EditorHelper.TempContent($"{p.Name} : { cus[ 0 ].GetName()}", EditorIcon.assetIcon_CsScript));
                EditorGUI.indentLevel++;
                EditorGUILayout.LabelField(EditorHelper.TempContent($"{p.Module.Name}", EditorIcon.icons_processed_assembly_icon_asset));
                EditorGUI.indentLevel--;
                ScopeVertical.End();
                ScopeHorizontal.End();
            }
        }
Ejemplo n.º 8
0
        public static void MakeMethods(bool force = false)
        {
            if (!force)
            {
                if (s_methods != null)
                {
                    return;
                }
            }

            s_methods   = new Hashtable();
            s_methodsOr = new Hashtable();

            var methods = AssemblieUtils.GetAllMethodsWithAttribute <Hananoki_OnOpenAsset>().ToArray();

            foreach (var p in methods)
            {
                var hash = p.GetHash_OnOpenAsset();
                if (E.i.m_enableOnOpen.IndexOf(hash) < 0)
                {
                    continue;
                }

                var atb = p.GetCustomAttributes(typeof(Hananoki_OnOpenAsset), false).OfType <Hananoki_OnOpenAsset>().ToList();

                if (atb[0].type != null)
                {
                    var m = s_methods[atb[0].type];
                    if (m == null)
                    {
                        s_methods.Add(atb[0].type, p);
                    }
                }
                if (atb[0].subClass != null)
                {
                    var m2 = s_methodsOr[atb[0].subClass];
                    if (m2 == null)
                    {
                        s_methodsOr.Add(atb[0].subClass, p);
                    }
                }
            }
        }
Ejemplo n.º 9
0
        public static void LoadLocalize()
        {
            EditorLocalize.Load(Package.name, "95cedfc7731853946b0b3650f175d73a", E.i.LCID);

            if (s_localizeEvent == null)
            {
                s_localizeEvent = new List <MethodInfo>(64);
                s_localizeEvent.AddRange(AssemblieUtils.GetAllMethodsWithAttribute <HananokiEditorLocalizeRegister>());
            }
            foreach (var m in s_localizeEvent)
            {
                try {
                    m.Invoke(null, null);
                }
                catch (Exception) {
                }
            }
            HEditorWindow.RepaintWindow(typeof(EditorWindow));
        }