private void PopulateScriptIconFromType(Assembly assembly, Type type, string iconPath, int priority,
                                                Dictionary <Type, ScriptIcon> scriptIconByType)
        {
            var ignored = type.GetCustomAttribute(typeof(IgnoreScriptIconAttribute), true) != null;

            if (scriptIconByType.TryGetValue(type, out var scriptIcon) && scriptIcon.priority <= priority)
            {
                scriptIcon.ignored = ignored;
                scriptIcon.SetValid();
                return;
            }

            if (scriptIcon == null)
            {
                scriptIcon = new ScriptIcon();
            }

            scriptIcon.SetAssembly(assembly);
            scriptIcon.SetType(type);

            scriptIcon.icon     = EditorDrawUtility.GetTexture(iconPath);
            scriptIcon.priority = priority;

            scriptIcon.ignored = ignored;
            scriptIcon.SetValid();

            scriptIconByType[type] = scriptIcon;
        }
Exemplo n.º 2
0
        private void PopulateScriptIcon(MightyType mightyType, ScriptIconAttribute attribute)
        {
            var type    = mightyType.MemberInfo;
            var ignored = type.GetCustomAttribute(typeof(IgnoreScriptIconAttribute), true) != null;
            var target  = attribute.Target;

            var priority = GetPriority(mightyType, target, attribute);
            var icon     = GetTexture(mightyType, target, attribute);

            if (m_scriptIconByType.TryGetValue(type, out var scriptIcon) && scriptIcon.IsIconValid && scriptIcon.priority >= priority)
            {
                scriptIcon.ignored = ignored;
                if (scriptIcon.icon == icon)
                {
                    scriptIcon.SetUsed();
                }

                scriptIcon.SetValid();

                return;
            }

            if (scriptIcon == null)
            {
                scriptIcon = new ScriptIcon();
            }

            scriptIcon.SetAssembly(mightyType.Assembly);
            scriptIcon.SetType(type);

            scriptIcon.icon     = icon;
            scriptIcon.priority = priority;

            scriptIcon.ignored = ignored;
            scriptIcon.SetValid();

            m_scriptIconByType[type] = scriptIcon;
        }