Exemple #1
0
        private void Update()
        {
            var array  = FindObjectsOfType(UnhollowerRuntimeLib.Il2CppType.Of <Renderer>());
            var ofType = array.Select(x => x.Cast <Renderer>());

            foreach (var renderer in ofType)
            {
                if (!renderer.enabled || !renderer.gameObject.activeSelf)
                {
                    continue;
                }

                if (MozaicTools.IsMozaicName(renderer.name))
                {
                    DumbRendererDemosaicPlugin.Log.LogInfo($"Disabling mozaic renderer {renderer.name}");
                    renderer.enabled = false;
                    renderer.gameObject.SetActive(false);
                }
                else if (MozaicTools.IsMozaicName(renderer.material.name) || MozaicTools.IsMozaicName(renderer.material.shader?.name))
                {
                    DumbRendererDemosaicPlugin.Log.LogInfo($"Removing mozaic material from renderer {renderer.name}");
                    renderer.material = null;
                    renderer.enabled  = false;
                    renderer.gameObject.SetActive(false);
                }
            }
        }
Exemple #2
0
        private void Awake()
        {
            var compType = typeof(Behaviour);
            var matType  = typeof(Material);

            _mozaicTypes = AppDomain.CurrentDomain.GetAssemblies()
                           .SelectMany(
                x =>
            {
                try
                {
                    return(x.GetTypes());
                }
                catch
                {
                    return(new Type[0]);
                }
            })
                           .Where(x => compType.IsAssignableFrom(x) && MozaicTools.IsMozaicName(x.Name))
                           .ToDictionary(x => x, x => x.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Where(y => matType.IsAssignableFrom(y.FieldType)).ToList());

            if (_mozaicTypes.Count == 0)
            {
                Logger.Log(LogLevel.Warning, "No potential mozaic types found! Shutting down");
                enabled = false;
            }
            else
            {
                Logger.Log(LogLevel.Info, $"Found {_mozaicTypes.Count} potential mozaic types");
            }
        }
Exemple #3
0
        private void Update()
        {
            foreach (var renderer in FindObjectsOfType <MeshRenderer>())
            {
                if (MozaicTools.IsMozaicName(renderer.material.name))
                {
                    if (_unlitMaterial == null)
                    {
                        continue;
                    }

                    if (renderer.sharedMaterial != null)
                    {
                        Logger.Log(LogLevel.Info, $"Replacing shared material {renderer.sharedMaterial.name} with {_unlitMaterial.name}");
                        renderer.sharedMaterial = _unlitMaterial;
                    }
                    else
                    {
                        Logger.Log(LogLevel.Info, $"Removing mozaic material from renderer {renderer.transform.name}");
                        renderer.material = _unlitMaterial;
                    }
                }
                else if (_unlitMaterial == null && renderer.material.name.StartsWith("Unlit"))
                {
                    _unlitMaterial = renderer.material;
                }
            }
        }
Exemple #4
0
 private void Update()
 {
     foreach (var renderer in FindObjectsOfType <Renderer>().Where(x => MozaicTools.IsMozaicName(x.material.name) || MozaicTools.IsMozaicName(x.material.shader?.name)))
     {
         Logger.Log(LogLevel.Info, $"Removing mozaic material from renderer {renderer.transform.name}");
         renderer.material = null;
         renderer.enabled  = false;
         renderer.gameObject.SetActive(false);
     }
 }
Exemple #5
0
 public static void DemosaicHook(CubismModel __instance)
 {
     foreach (var renderer in __instance.gameObject.GetComponentsInChildren <MeshRenderer>())
     {
         if (renderer != null && renderer.material != null && MozaicTools.IsMozaicName(renderer.material.name))
         {
             _instance.Logger.Log(LogLevel.Info, $"Removing mozaic material from renderer {renderer.transform.name}");
             renderer.material = null;
             renderer.enabled  = false;
         }
     }
 }
Exemple #6
0
        private void Update()
        {
            foreach (var renderer in FindObjectsOfType <Renderer>())
            {
                if (renderer.materials.Length < 2)
                {
                    continue;
                }

                foreach (var material in renderer.materials.Where(x => MozaicTools.IsMozaicName(x.name) || MozaicTools.IsMozaicName(x.shader?.name)))
                {
                    Logger.Log(LogLevel.Info, $"Removing mozaic from material {material.name} on renderer {renderer.transform.name}");

                    if (_additiveShader != null)
                    {
                        material.shader = _additiveShader;
                    }
                    else
                    {
                        material.shader = _standardShader;
                        material.SetOverrideTag("RenderType", "Transparent");
                        material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha);
                        material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha);
                        material.SetInt("_ZWrite", 0);
                        material.DisableKeyword("_ALPHATEST_ON");
                        material.EnableKeyword("_ALPHABLEND_ON");
                        material.DisableKeyword("_ALPHAPREMULTIPLY_ON");
                        material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent;
                    }

                    material.color       = Color.clear;
                    material.mainTexture = null;
                    material.name        = "[Replaced]";
                }
            }
        }