示例#1
0
 public static List <Type> GetEditoeAssemblyInstance <Type>()
 {
     return(EditorAssembly
            // 获取所有的编辑器环境中的类型
            .GetTypes()
            // 过滤掉抽象类型(接口/抽象类)、和未实现 Type 的类型
            .Where(type => typeof(Type).IsAssignableFrom(type) && !type.IsAbstract)
            // 获取类型的构造创建实例
            .Select(type => type.GetConstructors().First().Invoke(null))
            // 转换成 List<Type>
            .ToList()
            .OfType <Type>()
            .ToList());
 }
        protected override IEnumerable <Patch> GetPatches()
        {
            var labelGUIType       = EditorAssembly.GetType("UnityEditor.LabelGUI");
            var assetBundleGUIType = EditorAssembly.GetType("UnityEditor.AssetBundleNameGUI");

            var onLabelGUI           = AccessTools.Method(labelGUIType, "OnLabelGUI");
            var onAssetBundleGUI     = AccessTools.Method(assetBundleGUIType, "OnAssetBundleNameGUI");
            var drawPreviewAndLabels = AccessTools.Method(PropertyEditorRef.type, "DrawPreviewAndLabels");

            yield return(new Patch(onLabelGUI, nameof(_OnLabelGUI)));

            yield return(new Patch(onAssetBundleGUI, nameof(_OnAssetBundleNameGUI), apply: Apply.OnGUI));

            yield return(new Patch(drawPreviewAndLabels, nameof(DrawPreviewAndLabels_), apply: Apply.OnGUI));
        }
        protected override IEnumerable <Patch> GetPatches()
        {
            var attributeType = EditorAssembly.GetType("UnityEditor.EditorHeaderItemAttribute");

            foreach (var method in TypeCache.GetMethodsWithAttribute(attributeType))
            {
                var name = method.Name;

                if (name == "HelpIconButton")
                {
                    yield return(new Patch(method, nameof(_HelpIconButton), apply: Apply.OnGUI));
                }

                if (name == "DrawPresetButton")
                {
                    yield return(new Patch(method, nameof(_DrawPresetButton), apply: Apply.OnGUI));
                }
            }
        }
        protected override IEnumerable <Patch> GetPatches()
        {
            var type = EditorAssembly.GetType("UnityEditor.InspectorWindowUtils");

            yield return(new Patch(AccessTools.Method(type, "DrawAddedComponentBackground"), nameof(_DrawAddedComponentBackground)));
        }
示例#5
0
        protected override IEnumerable <Patch> GetPatches()
        {
            var type = EditorAssembly.GetType("UnityEditor.GenericInspector");

            yield return(new Patch(AccessTools.Method(type, "GetOptimizedGUIBlock"), nameof(_GetOptimizedGUIBlock)));
        }