コード例 #1
0
ファイル: ModelFixer.cs プロジェクト: OpenMLTD/LeadActress
        public void FixAllMaterials([NotNull] GameObject prefab, [NotNull] GameObject instance, [NotNull] ModelFixerOptions options)
        {
            var oldRenderers  = prefab.GetComponentsInChildren <SkinnedMeshRenderer>();
            var newRenderers  = instance.GetComponentsInChildren <SkinnedMeshRenderer>();
            var rendererCount = oldRenderers.Length;

            for (var i = 0; i < rendererCount; i += 1)
            {
                FixMaterials(oldRenderers[i], newRenderers[i], options);
            }
        }
コード例 #2
0
ファイル: ModelFixer.cs プロジェクト: OpenMLTD/LeadActress
        private void FixMaterials([NotNull] SkinnedMeshRenderer prefabRenderer, [NotNull] SkinnedMeshRenderer instanceRenderer, [NotNull] ModelFixerOptions options)
        {
            var oldMaterials  = prefabRenderer.sharedMaterials;
            var newMaterials  = instanceRenderer.materials;
            var materialCount = oldMaterials.Length;

            for (var i = 0; i < materialCount; i += 1)
            {
                var oldMaterial = oldMaterials[i];
                var newMaterial = newMaterials[i];

                if (oldMaterial.name.Contains("skin"))
                {
                    newMaterial = Instantiate(skinMaterial);
                    ApplyNewMaterial(oldMaterial, newMaterial);
                    newMaterials[i] = newMaterial;
                }
                else if (oldMaterial.name.Contains("face"))
                {
                    newMaterial = Instantiate(skinMaterialNoShade);
                    ApplyNewMaterial(oldMaterial, newMaterial);
                    newMaterials[i] = newMaterial;
                }
                else if (oldMaterial.name.EndsWith("cut"))
                {
                    // newMaterial.shader = Shader.Find("Unlit/Transparent Cutout");
                    newMaterial = Instantiate(cutoutMaterial);
                    ApplyNewMaterial(oldMaterial, newMaterial);
                    newMaterials[i] = newMaterial;
                }
                else if (oldMaterial.name.Contains("eyel") || oldMaterial.name.Contains("eyer"))
                {
                    if (options.EyesHighlights)
                    {
                        newMaterial.shader = Shader.Find("Unlit/Dual");
                    }
                    else
                    {
                        newMaterial.shader = Shader.Find("Unlit/Texture");
                    }
                }
                else if (oldMaterial.name.Contains("hair"))
                {
                    if (options.HairHighlights)
                    {
                        newMaterial.shader = Shader.Find("Unlit/Dual");
                    }
                    else
                    {
                        newMaterial.shader = Shader.Find("Unlit/Texture");
                    }
                }
                else
                {
                    // newMaterial.shader = Shader.Find("Unlit/Texture");
                    newMaterial = Instantiate(clothesMaterial);
                    ApplyNewMaterial(oldMaterial, newMaterial);
                    newMaterials[i] = newMaterial;
                }
            }

            instanceRenderer.materials = newMaterials;
        }