コード例 #1
0
    private void Start()
    {
        settings = new MaterialSettings[materials.Length];

        for (int materialIndex = 0; materialIndex < materials.Length; ++materialIndex)
        {
            Material material = materials[materialIndex];
            settings[materialIndex].material = material;

            if (material != null)
            {
                settings[materialIndex].originalSourceBlend = material.HasProperty("_SRCBLEND") ? material.GetInt("_SRCBLEND") : -1;
                settings[materialIndex].originalDestinationBlend = material.HasProperty("_DSTBLEND") ? material.GetInt("_DSTBLEND") : -1;
            }
            else
            {
                Debug.LogWarning("MaterialsFader: Material #" + materialIndex + " of '" + name + "' is missing - delete from list.");
            }
        }
    }
コード例 #2
0
    private void Start()
    {
        SharedMaterial = new MaterialSettings[1];

        Fader[] childrenFaders = GetComponentsInChildren<Fader>(true);
        Renderer[] renderers = GetComponentsInChildren<Renderer>(true);
        foreach (Renderer renderer in renderers)
        {
            if (CanAddMaterialsFromRenderer(renderer, childrenFaders))
            {
                if (SharedMaterial[0].material == null)
                {
                    SharedMaterial[0].material = renderer.material;
                    SharedMaterial[0].originalSourceBlend = renderer.material.HasProperty("_SRCBLEND") ? renderer.material.GetInt("_SRCBLEND") : -1;
                    SharedMaterial[0].originalDestinationBlend = renderer.material.HasProperty("_DSTBLEND") ? renderer.material.GetInt("_DSTBLEND") : -1;
                }

                renderer.material = SharedMaterial[0].material;
            }
        }
    }
コード例 #3
0
ファイル: Fader.cs プロジェクト: Ronmenator/GalaxyExplorer
    private void Start()
    {
        int materialCount = 0;

        Fader[] childrenFaders = GetComponentsInChildren<Fader>(true);
        Renderer[] renderers = GetComponentsInChildren<Renderer>(true);
        foreach (Renderer renderer in renderers)
        {
            if (CanAddMaterialsFromRenderer(renderer, childrenFaders))
            {
                materialCount += renderer.materials.Length;
            }
        }

        currentMaterials = new MaterialSettings[materialCount];

        int materialIndex = 0;
        foreach (Renderer renderer in renderers)
        {
            if (CanAddMaterialsFromRenderer(renderer, childrenFaders))
            {
                foreach (Material rendererMaterial in renderer.materials)
                {
                    currentMaterials[materialIndex].material = rendererMaterial;
                    currentMaterials[materialIndex].renderer = renderer;
                    currentMaterials[materialIndex].originalSourceBlend = rendererMaterial.HasProperty("_SRCBLEND") ? rendererMaterial.GetInt("_SRCBLEND") : -1;
                    currentMaterials[materialIndex].originalDestinationBlend = rendererMaterial.HasProperty("_DSTBLEND") ? rendererMaterial.GetInt("_DSTBLEND") : -1;
                    ++materialIndex;
                }
            }
        }
    }