Beispiel #1
0
 // Token: 0x06001D2D RID: 7469 RVA: 0x00095610 File Offset: 0x00093810
 protected override void ChangeToHighlightColor(Color color, float duration = 0f)
 {
     foreach (Renderer renderer in base.GetComponentsInChildren <Renderer>(true))
     {
         string key = renderer.gameObject.GetInstanceID().ToString();
         if (this.originalMaterialPropertyBlocks.ContainsKey(key))
         {
             if (this.faderRoutines.ContainsKey(key) && this.faderRoutines[key] != null)
             {
                 base.StopCoroutine(this.faderRoutines[key]);
                 this.faderRoutines.Remove(key);
             }
             MaterialPropertyBlock materialPropertyBlock = this.highlightMaterialPropertyBlocks[key];
             renderer.GetPropertyBlock(materialPropertyBlock);
             if (this.resetMainTexture)
             {
                 materialPropertyBlock.SetTexture("_MainTex", Texture2D.whiteTexture);
             }
             if (duration > 0f)
             {
                 this.faderRoutines[key] = base.StartCoroutine(this.CycleColor(renderer, materialPropertyBlock, color, duration));
             }
             else
             {
                 materialPropertyBlock.SetColor("_Color", color);
                 materialPropertyBlock.SetColor("_EmissionColor", VRTK_SharedMethods.ColorDarken(color, this.emissionDarken));
                 renderer.SetPropertyBlock(materialPropertyBlock);
             }
         }
     }
 }
        protected override void ChangeToHighlightColor(Color color, float duration = 0f)
        {
            foreach (Renderer renderer in GetComponentsInChildren<Renderer>(true))
            {
                var objectReference = renderer.gameObject.GetInstanceID().ToString();
                if (!originalMaterialPropertyBlocks.ContainsKey(objectReference))
                {
                    continue;
                }

                if (faderRoutines.ContainsKey(objectReference) && faderRoutines[objectReference] != null)
                {
                    StopCoroutine(faderRoutines[objectReference]);
                    faderRoutines.Remove(objectReference);
                }

                var highlightMaterialPropertyBlock = highlightMaterialPropertyBlocks[objectReference];
                renderer.GetPropertyBlock(highlightMaterialPropertyBlock);
                if (resetMainTexture)
                {
                    highlightMaterialPropertyBlock.SetTexture("_MainTex", Texture2D.whiteTexture);
                }

                if (duration > 0f)
                {
                    faderRoutines[objectReference] = StartCoroutine(CycleColor(renderer, highlightMaterialPropertyBlock, color, duration));
                }
                else
                {
                    highlightMaterialPropertyBlock.SetColor("_Color", color);
                    highlightMaterialPropertyBlock.SetColor("_EmissionColor", VRTK_SharedMethods.ColorDarken(color, emissionDarken));
                    renderer.SetPropertyBlock(highlightMaterialPropertyBlock);
                }
            }
        }
        private void ChangeToHighlightColor(Color color, float duration = 0f)
        {
            foreach (Renderer renderer in GetComponentsInChildren <Renderer>(true))
            {
                // alexn: Change to not highlight particles.
                if (renderer.gameObject.layer != LayerMask.NameToLayer("Particles"))
                {
                    var swapCustomMaterials = new Material[renderer.materials.Length];

                    for (int i = 0; i < renderer.materials.Length; i++)
                    {
                        var material = renderer.materials[i];
                        if (customMaterial)
                        {
                            material = customMaterial;
                            swapCustomMaterials[i] = material;
                        }

                        var faderRoutineID = material.GetInstanceID().ToString();

                        if (faderRoutines.ContainsKey(faderRoutineID) && faderRoutines[faderRoutineID] != null)
                        {
                            StopCoroutine(faderRoutines[faderRoutineID]);
                            faderRoutines.Remove(faderRoutineID);
                        }

                        material.EnableKeyword("_EMISSION");

                        if (resetMainTexture && material.HasProperty("_MainTex"))
                        {
                            renderer.material.SetTexture("_MainTex", new Texture());
                        }

                        if (material.HasProperty("_Color"))
                        {
                            if (duration > 0f)
                            {
                                faderRoutines[faderRoutineID] = StartCoroutine(CycleColor(material, material.color, color, duration));
                            }
                            else
                            {
                                material.color = color;
                                if (material.HasProperty("_EmissionColor"))
                                {
                                    material.SetColor("_EmissionColor", VRTK_SharedMethods.ColorDarken(color, emissionDarken));
                                }
                            }
                        }
                    }

                    if (customMaterial)
                    {
                        renderer.materials = swapCustomMaterials;
                    }
                }
            }
        }
Beispiel #4
0
        protected virtual void ChangeToHighlightColor(Color color, float duration = 0f)
        {
            Renderer[] renderers = GetComponentsInChildren <Renderer>(true);
            for (int j = 0; j < renderers.Length; j++)
            {
                Renderer   renderer            = renderers[j];
                Material[] swapCustomMaterials = new Material[renderer.materials.Length];

                for (int i = 0; i < renderer.materials.Length; i++)
                {
                    Material material = renderer.materials[i];
                    if (customMaterial != null)
                    {
                        material = customMaterial;
                        swapCustomMaterials[i] = material;
                    }

                    string faderRoutineID = material.GetInstanceID().ToString();

                    if (faderRoutines.ContainsKey(faderRoutineID) && faderRoutines[faderRoutineID] != null)
                    {
                        StopCoroutine(faderRoutines[faderRoutineID]);
                        faderRoutines.Remove(faderRoutineID);
                    }

                    material.EnableKeyword("_EMISSION");

                    if (resetMainTexture && material.HasProperty("_MainTex"))
                    {
                        renderer.material.SetTexture("_MainTex", new Texture2D(0, 0));
                    }

                    if (material.HasProperty("_Color"))
                    {
                        if (duration > 0f)
                        {
                            faderRoutines[faderRoutineID] = StartCoroutine(CycleColor(material, material.color, color, duration));
                        }
                        else
                        {
                            material.color = color;
                            if (material.HasProperty("_EmissionColor"))
                            {
                                material.SetColor("_EmissionColor", VRTK_SharedMethods.ColorDarken(color, emissionDarken));
                            }
                        }
                    }
                }

                if (customMaterial != null)
                {
                    renderer.materials = swapCustomMaterials;
                }
            }
        }
Beispiel #5
0
        protected virtual void ChangeToHighlightColor(Color color, float duration = 0f)
        {
            foreach (Renderer renderer in GetComponentsInChildren <Renderer>(true))
            {
                var swapCustomMaterials = new Material[renderer.materials.Length];

                for (int i = 0; i < renderer.materials.Length; i++)
                {
                    var material = renderer.materials[i];
                    if (customMaterial)
                    {
                        material = customMaterial;
                        swapCustomMaterials[i] = material;
                    }

                    var faderRoutineID = material.GetInstanceID().ToString();

                    if (faderRoutines.ContainsKey(faderRoutineID) && faderRoutines[faderRoutineID] != null)
                    {
                        StopCoroutine(faderRoutines[faderRoutineID]);
                        faderRoutines.Remove(faderRoutineID);
                    }

                    material.EnableKeyword("_EMISSION");

                    if (resetMainTexture && material.HasProperty("_MainTex"))
                    {
                        throw new System.NotImplementedException("Texture constructor is protected.");
                        ////renderer.material.SetTexture("_MainTex", new Texture());
                    }

                    if (material.HasProperty("_Color"))
                    {
                        if (duration > 0f)
                        {
                            faderRoutines[faderRoutineID] = StartCoroutine(CycleColor(material, material.color, color, duration));
                        }
                        else
                        {
                            material.color = color;
                            if (material.HasProperty("_EmissionColor"))
                            {
                                material.SetColor("_EmissionColor", VRTK_SharedMethods.ColorDarken(color, emissionDarken));
                            }
                        }
                    }
                }

                if (customMaterial)
                {
                    renderer.materials = swapCustomMaterials;
                }
            }
        }
Beispiel #6
0
 // Token: 0x06001D27 RID: 7463 RVA: 0x000952C4 File Offset: 0x000934C4
 protected virtual void ChangeToHighlightColor(Color color, float duration = 0f)
 {
     foreach (Renderer renderer in base.GetComponentsInChildren <Renderer>(true))
     {
         Material[] array = new Material[renderer.materials.Length];
         for (int j = 0; j < renderer.materials.Length; j++)
         {
             Material material = renderer.materials[j];
             if (this.customMaterial)
             {
                 material = this.customMaterial;
                 array[j] = material;
             }
             string key = material.GetInstanceID().ToString();
             if (this.faderRoutines.ContainsKey(key) && this.faderRoutines[key] != null)
             {
                 base.StopCoroutine(this.faderRoutines[key]);
                 this.faderRoutines.Remove(key);
             }
             material.EnableKeyword("_EMISSION");
             if (this.resetMainTexture && material.HasProperty("_MainTex"))
             {
                 renderer.material.SetTexture("_MainTex", new Texture2D(0, 0));
             }
             if (material.HasProperty("_Color"))
             {
                 if (duration > 0f)
                 {
                     this.faderRoutines[key] = base.StartCoroutine(this.CycleColor(material, material.color, color, duration));
                 }
                 else
                 {
                     material.color = color;
                     if (material.HasProperty("_EmissionColor"))
                     {
                         material.SetColor("_EmissionColor", VRTK_SharedMethods.ColorDarken(color, this.emissionDarken));
                     }
                 }
             }
         }
         if (this.customMaterial)
         {
             renderer.materials = array;
         }
     }
 }
        protected virtual IEnumerator CycleColor(Material material, Color startColor, Color endColor, float duration)
        {
            var elapsedTime = 0f;

            while (elapsedTime <= duration)
            {
                elapsedTime += Time.deltaTime;
                if (material.HasProperty("_Color"))
                {
                    material.color = Color.Lerp(startColor, endColor, (elapsedTime / duration));
                }
                if (material.HasProperty("_EmissionColor"))
                {
                    material.SetColor("_EmissionColor", Color.Lerp(startColor, VRTK_SharedMethods.ColorDarken(endColor, emissionDarken), (elapsedTime / duration)));
                }
                yield return(null);
            }
        }
        protected override void ChangeToHighlightColor(Color color, float duration = 0f)
        {
            Renderer[] renderers = objectToAffect.GetComponentsInChildren <Renderer>(true);
            for (int i = 0; i < renderers.Length; i++)
            {
                Renderer renderer       = renderers[i];
                string   faderRoutineID = renderer.gameObject.GetInstanceID().ToString();
                if (VRTK_SharedMethods.GetDictionaryValue(originalMaterialPropertyBlocks, faderRoutineID) == null)
                {
                    continue;
                }

                Coroutine existingFaderRoutine = VRTK_SharedMethods.GetDictionaryValue(faderRoutines, faderRoutineID);
                if (existingFaderRoutine != null)
                {
                    StopCoroutine(existingFaderRoutine);
                    faderRoutines.Remove(faderRoutineID);
                }

                MaterialPropertyBlock highlightMaterialPropertyBlock = highlightMaterialPropertyBlocks[faderRoutineID];
                renderer.GetPropertyBlock(highlightMaterialPropertyBlock);
                if (resetMainTexture)
                {
                    highlightMaterialPropertyBlock.SetTexture("_MainTex", Texture2D.whiteTexture);
                }

                if (duration > 0f)
                {
                    VRTK_SharedMethods.AddDictionaryValue(faderRoutines, faderRoutineID, StartCoroutine(CycleColor(renderer, highlightMaterialPropertyBlock, color, duration)), true);
                }
                else
                {
                    highlightMaterialPropertyBlock.SetColor("_Color", color);
                    highlightMaterialPropertyBlock.SetColor("_EmissionColor", VRTK_SharedMethods.ColorDarken(color, emissionDarken));
                    renderer.SetPropertyBlock(highlightMaterialPropertyBlock);
                }
            }
        }