コード例 #1
0
        private void Awake()
        {
            Instance = this;
            Logger   = base.Logger;
            Directory.CreateDirectory(ExportPath);

            UIScale = Config.Bind("Config", "UI Scale", 1.75f, new ConfigDescription("Controls the size of the window.", new AcceptableValueRange <float>(1f, 3f), new ConfigurationManagerAttributes {
                Order = 5
            }));
            UIWidth = Config.Bind("Config", "UI Width", 0.3f, new ConfigDescription("Controls the size of the window.", new AcceptableValueRange <float>(0f, 1f), new ConfigurationManagerAttributes {
                Order = 4, ShowRangeAsPercent = false
            }));
            UIHeight = Config.Bind("Config", "UI Height", 0.3f, new ConfigDescription("Controls the size of the window.", new AcceptableValueRange <float>(0f, 1f), new ConfigurationManagerAttributes {
                Order = 3, ShowRangeAsPercent = false
            }));
            WatchTexChanges = Config.Bind("Config", "Watch File Changes", true, new ConfigDescription("Watch for file changes and reload textures on change. Can be toggled in the UI.", null, new ConfigurationManagerAttributes {
                Order = 2
            }));
            ShaderOptimization = Config.Bind("Config", "Shader Optimization", true, new ConfigDescription("Replaces every loaded shader with the MaterialEditor copy of the shader. Reduces the number of copies of shaders loaded which reduces RAM usage and improves performance.", null, new ConfigurationManagerAttributes {
                Order = 1
            }));

            UIScale.SettingChanged            += MaterialEditorUI.UISettingChanged;
            UIWidth.SettingChanged            += MaterialEditorUI.UISettingChanged;
            UIHeight.SettingChanged           += MaterialEditorUI.UISettingChanged;
            WatchTexChanges.SettingChanged    += WatchTexChanges_SettingChanged;
            ShaderOptimization.SettingChanged += ShaderOptimization_SettingChanged;

            ResourceRedirection.RegisterAssetLoadedHook(HookBehaviour.OneCallbackPerResourceLoaded, AssetLoadedHook);
            LoadXML();
        }
コード例 #2
0
 public override void Initialize(IEnumerable <Mod> mods)
 {
     base.Initialize(mods);
     // Ensure materials are handled before textures
     ResourceRedirection.RegisterAssetLoadedHook(HookBehaviour.OneCallbackPerResourceLoaded, 100,
                                                 PatchLoadedAsset);
 }
コード例 #3
0
 void Awake()
 {
     ResourceRedirection.RegisterAssetLoadedHook(
         behaviour: HookBehaviour.OneCallbackPerResourceLoaded,
         priority: 0,
         action: AssetLoaded);
 }
コード例 #4
0
 public override void Initialize(IEnumerable <Mod> mods)
 {
     base.Initialize(mods);
     ResourceRedirection.RegisterAssetLoadedHook(HookBehaviour.OneCallbackPerResourceLoaded, PatchLoadedAsset);
     ResourceRedirection.RegisterResourceLoadedHook(HookBehaviour.OneCallbackPerResourceLoaded,
                                                    PatchLoadedResource);
 }
コード例 #5
0
        private void Awake()
        {
            textureStorePath = Config.Bind("Paths", "TexturesStore", "GunSkins", "Path where textures are stored.");
            textureStorePath.SettingChanged += (sender, args) => InitWatcher();
            InitWatcher();

            ResourceRedirection.RegisterAssetLoadedHook(HookBehaviour.OneCallbackPerResourceLoaded, ReplaceTextures);
        }
コード例 #6
0
        internal void Main()
        {
            Logger = base.Logger;
            Directory.CreateDirectory(ExportPath);

            MakerAPI.MakerExiting += (s, e) => UI.Visible = false;
            CharacterApi.RegisterExtraBehaviour <MaterialEditorCharaController>(GUID);
            AccessoriesApi.SelectedMakerAccSlotChanged += AccessoriesApi_SelectedMakerAccSlotChanged;
            AccessoriesApi.AccessoryKindChanged        += AccessoriesApi_AccessoryKindChanged;
            AccessoriesApi.AccessoryTransferred        += AccessoriesApi_AccessoryTransferred;
#if KK
            AccessoriesApi.AccessoriesCopied += AccessoriesApi_AccessoriesCopied;
#endif

            UIScale = Config.Bind("Config", "UI Scale", 1.75f, new ConfigDescription("Controls the size of the window.", new AcceptableValueRange <float>(1f, 3f), new ConfigurationManagerAttributes {
                Order = 5
            }));
            UIWidth = Config.Bind("Config", "UI Width", 0.3f, new ConfigDescription("Controls the size of the window.", new AcceptableValueRange <float>(0f, 1f), new ConfigurationManagerAttributes {
                Order = 4, ShowRangeAsPercent = false
            }));
            UIHeight = Config.Bind("Config", "UI Height", 0.3f, new ConfigDescription("Controls the size of the window.", new AcceptableValueRange <float>(0f, 1f), new ConfigurationManagerAttributes {
                Order = 3, ShowRangeAsPercent = false
            }));
            WatchTexChanges = Config.Bind("Config", "Watch File Changes", true, new ConfigDescription("Watch for file changes and reload textures on change. Can be toggled in the UI.", null, new ConfigurationManagerAttributes {
                Order = 2
            }));
            ShaderOptimization = Config.Bind("Config", "Shader Optimization", true, new ConfigDescription("Replaces every loaded shader with the MaterialEditor copy of the shader. Reduces the number of copies of shaders loaded which reduces RAM usage and improves performance.", null, new ConfigurationManagerAttributes {
                Order = 1
            }));
            WatchTexChanges.SettingChanged += WatchTexChanges_SettingChanged;

            var harmony = Harmony.CreateAndPatchAll(typeof(Hooks));

#if KK || EC
            //Hooks for transfering accessories (MoreAccessories compatibility)
            foreach (var method in typeof(ChaCustom.CvsAccessoryChange).GetMethods(AccessTools.all).Where(x => x.Name.Contains("<Start>m__4")))
            {
                harmony.Patch(method, new HarmonyMethod(typeof(Hooks).GetMethod(nameof(Hooks.AccessoryTransferHook), AccessTools.all)));
            }
#elif AI || HS2
            //Hooks for changing clothing pattern
            foreach (var method in typeof(CharaCustom.CustomClothesPatternSelect).GetMethods(AccessTools.all).Where(x => x.Name.Contains("<ChangeLink>")))
            {
                harmony.Patch(method, new HarmonyMethod(typeof(Hooks).GetMethod(nameof(Hooks.ClothesColorChangeHook), AccessTools.all)));
            }

            //hooks for changing clothing color
            foreach (var method in typeof(CharaCustom.CustomClothesColorSet).GetMethods(AccessTools.all).Where(x => x.Name.StartsWith("<Initialize>")))
            {
                harmony.Patch(method, new HarmonyMethod(typeof(Hooks).GetMethod(nameof(Hooks.ClothesColorChangeHook), AccessTools.all)));
            }
#endif
            StartCoroutine(LoadXML());
            StartCoroutine(GetUncensorSelectorParts());

            ResourceRedirection.RegisterAssetLoadedHook(HookBehaviour.OneCallbackPerResourceLoaded, AssetLoadedHook);
        }
コード例 #7
0
        public virtual void Awake()
        {
            Instance = this;
            Logger   = base.Logger;
            Directory.CreateDirectory(ExportPath);

            UIScale = Config.Bind("Config", "UI Scale", 1.75f, new ConfigDescription("Controls the size of the window.", new AcceptableValueRange <float>(1f, 3f), new ConfigurationManagerAttributes {
                Order = 5
            }));
            UIWidth = Config.Bind("Config", "UI Width", 0.3f, new ConfigDescription("Controls the size of the window.", new AcceptableValueRange <float>(0f, 1f), new ConfigurationManagerAttributes {
                Order = 4, ShowRangeAsPercent = false
            }));
            UIHeight = Config.Bind("Config", "UI Height", 0.3f, new ConfigDescription("Controls the size of the window.", new AcceptableValueRange <float>(0f, 1f), new ConfigurationManagerAttributes {
                Order = 3, ShowRangeAsPercent = false
            }));
            WatchTexChanges = Config.Bind("Config", "Watch File Changes", true, new ConfigDescription("Watch for file changes and reload textures on change. Can be toggled in the UI.", null, new ConfigurationManagerAttributes {
                Order = 2
            }));
            ShaderOptimization = Config.Bind("Config", "Shader Optimization", true, new ConfigDescription("Replaces every loaded shader with the MaterialEditor copy of the shader. Reduces the number of copies of shaders loaded which reduces RAM usage and improves performance.", null, new ConfigurationManagerAttributes {
                Order = 1
            }));
            ExportBakedMesh = Config.Bind("Config", "Export Baked Mesh", false, new ConfigDescription("When enabled, skinned meshes will be exported in their current state with all customization applied as well as in the current pose.", null, new ConfigurationManagerAttributes {
                Order = 1
            }));
            ExportBakedWorldPosition = Config.Bind("Config", "Export Baked World Position", false, new ConfigDescription("When enabled, objects will be exported with their position changes intact so that, i.e. when exporting two objects they retain their position relative to each other.\nOnly works when Export Baked Mesh is also enabled.", null, new ConfigurationManagerAttributes {
                Order = 1
            }));
            ConfigExportPath = Config.Bind("Config", "Export Path Override", "", new ConfigDescription($"Textures and models will be exported to this folder. If empty, exports to {ExportPathDefault}", null, new ConfigurationManagerAttributes {
                Order = 1
            }));

            UIScale.SettingChanged            += MaterialEditorUI.UISettingChanged;
            UIWidth.SettingChanged            += MaterialEditorUI.UISettingChanged;
            UIHeight.SettingChanged           += MaterialEditorUI.UISettingChanged;
            WatchTexChanges.SettingChanged    += WatchTexChanges_SettingChanged;
            ShaderOptimization.SettingChanged += ShaderOptimization_SettingChanged;
            ConfigExportPath.SettingChanged   += ConfigExportPath_SettingChanged;
            SetExportPath();

            ResourceRedirection.RegisterAssetLoadedHook(HookBehaviour.OneCallbackPerResourceLoaded, AssetLoadedHook);
            LoadXML();
        }
コード例 #8
0
 /// <summary>
 /// Constructs the resource redirection handler.
 /// </summary>
 public AssetLoadedHandlerBase()
 {
     ResourceRedirection.RegisterAssetLoadedHook(HookBehaviour.OneCallbackPerResourceLoaded, 0, HandleAsset);
     ResourceRedirection.RegisterResourceLoadedHook(HookBehaviour.OneCallbackPerResourceLoaded, 0, HandleResource);
 }