/// <summary>
        /// Call this when the object is highlighted, this will switch all the material parameters to make it glow
        /// </summary>
        public void Highlight()
        {
            if (m_Renderers == null)
            {
                SetUpGlow();
            }

            for (int i = 0; i < m_Renderers.Length; ++i)
            {
                var rend = m_Renderers[i];

                if (rend == null)
                {
                    continue;
                }

                rend.GetPropertyBlock(m_PropertyBlock);

                m_PropertyBlock.SetColor(m_RimColorID, m_OriginalRimColor[i]);
                m_PropertyBlock.SetFloat(m_RimPowID, m_PropertyBlock.GetFloat(m_RimPowID) * 0.25f);

                m_SavedRimIntensity[i] = m_PropertyBlock.GetFloat(m_RimIntensityID);
                m_PropertyBlock.SetFloat(m_RimIntensityID, 1.0f);

                rend.SetPropertyBlock(m_PropertyBlock);
            }
        }
示例#2
0
    private void setupSkinProperties(Transform target)
    {
        Renderer[] componentsInChildren = target.GetComponentsInChildren <Renderer>();
        Renderer   renderer             = null;

        foreach (Renderer renderer2 in componentsInChildren)
        {
            MeshFilter component = renderer2.GetComponent <MeshFilter>();
            if (component && component.mesh.name.Contains("Head"))
            {
                renderer = renderer2;
            }
        }
        if (renderer)
        {
            Material[] materials = renderer.materials;
            materials[0]       = this._sourceSkinRenderer.material;
            renderer.materials = materials;
            MaterialPropertyBlock materialPropertyBlock = new MaterialPropertyBlock();
            this._sourceSkinRenderer.GetPropertyBlock(materialPropertyBlock);
            MaterialPropertyBlock materialPropertyBlock2 = new MaterialPropertyBlock();
            renderer.GetPropertyBlock(materialPropertyBlock2);
            materialPropertyBlock2.SetFloat("_Damage1", materialPropertyBlock.GetFloat("_Damage1"));
            materialPropertyBlock2.SetFloat("_Damage2", materialPropertyBlock.GetFloat("_Damage2"));
            materialPropertyBlock2.SetFloat("_Damage3", materialPropertyBlock.GetFloat("_Damage3"));
            materialPropertyBlock2.SetFloat("_Damage4", materialPropertyBlock.GetFloat("_Damage4"));
            renderer.SetPropertyBlock(materialPropertyBlock2);
        }
    }
示例#3
0
    public void changeAnimation(string animationName, float off = 0, bool needBlend = false)
    {
        animationData         data  = dic[animationName];
        MaterialPropertyBlock block = new MaterialPropertyBlock();

        render.GetPropertyBlock(block);
        nowTime = -Time.timeSinceLevelLoad;
        float startNum = data.startNum;
        float endNum   = data.endNum;

        maxTime = endNum - startNum;
        isLoop  = data.isLoop;
        if (needBlend)
        {
            float oldAnimStart = block.GetFloat("_AnimStart");
            float oldAnimEnd   = block.GetFloat("_AnimEnd");
            float oldAnimOff   = block.GetFloat("_AnimOff");
            block.SetFloat("_OldAnimStart", oldAnimStart);
            block.SetFloat("_OldAnimEnd", oldAnimEnd);
            block.SetFloat("_OldAnimOff", oldAnimOff);
            block.SetFloat("_Blend", 0f);
            isBlend = true;
        }
        block.SetFloat("_AnimStart", startNum);
        block.SetFloat("_AnimEnd", endNum);
        block.SetFloat("_AnimOff", nowTime + off);
        render.SetPropertyBlock(block);
    }
示例#4
0
    public virtual void Flip(float end, float duration)
    {
        //first need to make sure the object isn't already selected before starting any transition
        //objects that are selected will be flipped and shouldn't have any animation, but should change their parent gameobject

        mRenderer.GetPropertyBlock(_propBlock);

        float start = _propBlock.GetFloat("_TransitionState");      //material.GetFloat("_TransitionState");



        //start new direction from where we've left off but in the direction we've specified with "end"
        if (!Toolbox.Instance.EqualToHeld(this.gameObject) && CoreParentHeldCheck())
        {
            flipTransition = flipTransitionRoutine(start, end, duration / ScaleSpeed);
            StartCoroutine(flipTransition);
        }

        if (transitionAllChildren)
        {
            foreach (Transition transition in childrenTransitions)
            {
                if (!transition.gameObject.Equals(this.gameObject) && !Toolbox.Instance.EqualToHeld(transition.gameObject))
                {
                    transition.StopAllCoroutines();
                    transition.Flip(end, duration);
                }
            }
        }
    }
示例#5
0
    public void goRagdoll()
    {
        if (this.ragdollSpawned)
        {
            return;
        }
        this.ragdollSpawned = true;
        Transform transform = this.ragdoll.metgoragdoll(default(Vector3));

        if (PoolManager.Pools["creatures"].IsSpawned(this.rootTr))
        {
            this.spawnFunctions.despawn();
        }
        else
        {
            UnityEngine.Object.Destroy(base.gameObject);
        }
        CoopMutantDummyToken  coopMutantDummyToken  = new CoopMutantDummyToken();
        MaterialPropertyBlock materialPropertyBlock = new MaterialPropertyBlock();

        this.skinRenderer.GetPropertyBlock(materialPropertyBlock);
        coopMutantDummyToken.skinDamage1 = materialPropertyBlock.GetFloat("_Damage1");
        coopMutantDummyToken.skinDamage2 = materialPropertyBlock.GetFloat("_Damage2");
        coopMutantDummyToken.skinDamage3 = materialPropertyBlock.GetFloat("_Damage3");
        coopMutantDummyToken.skinDamage4 = materialPropertyBlock.GetFloat("_Damage4");
        if (BoltNetwork.isRunning)
        {
            BoltNetwork.Attach(transform.gameObject, coopMutantDummyToken);
        }
    }
示例#6
0
        public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property)
        {
            if (Host == null)
            {
                return(new InteractableThemePropertyValue());
            }

            InteractableThemePropertyValue start = new InteractableThemePropertyValue();
            string propId = property.GetShaderPropId();

            switch (property.Type)
            {
            case InteractableThemePropertyValueTypes.Color:
                start.Color = propertyBlock.GetVector(propId);
                break;

            case InteractableThemePropertyValueTypes.ShaderFloat:
                start.Float = propertyBlock.GetFloat(propId);
                break;

            case InteractableThemePropertyValueTypes.shaderRange:
                start.Float = propertyBlock.GetFloat(propId);
                break;

            default:
                break;
            }

            return(start);
        }
示例#7
0
        public override InteractableThemePropertyValue GetProperty(InteractableThemeProperty property)
        {
            if (Host == null)
            {
                return(emptyValue);
            }

            renderer.GetPropertyBlock(propertyBlock);

            startValue.Reset();

            int propId = property.GetShaderPropertyId();

            switch (property.Type)
            {
            case InteractableThemePropertyValueTypes.Color:
                startValue.Color = propertyBlock.GetVector(propId);
                break;

            case InteractableThemePropertyValueTypes.ShaderFloat:
                startValue.Float = propertyBlock.GetFloat(propId);
                break;

            case InteractableThemePropertyValueTypes.shaderRange:
                startValue.Float = propertyBlock.GetFloat(propId);
                break;

            default:
                break;
            }

            return(startValue);
        }
示例#8
0
    private void copyBloodAndSkin()
    {
        this.skin.sharedMaterial = this.targetSkin.sharedMaterial;
        this.block = new MaterialPropertyBlock();
        MaterialPropertyBlock materialPropertyBlock = new MaterialPropertyBlock();

        this.targetSkin.GetPropertyBlock(materialPropertyBlock);
        this.skin.GetPropertyBlock(this.block);
        this.block.SetFloat("_Damage1", materialPropertyBlock.GetFloat("_Damage1"));
        this.block.SetFloat("_Damage2", materialPropertyBlock.GetFloat("_Damage2"));
        this.block.SetFloat("_Damage3", materialPropertyBlock.GetFloat("_Damage3"));
        this.block.SetFloat("_Damage4", materialPropertyBlock.GetFloat("_Damage4"));
        this.skin.SetPropertyBlock(this.block);
    }
示例#9
0
 private void scrollOutAnimation()
 {
     model.SetActive(false);
     title.SetActive(false);
     highScoreText.enabled = false;
     _mushRen.GetPropertyBlock(_mushPropBlock);
     shaderPara -= .05f;
     _mushPropBlock.SetFloat("_PageCurl_movement_1", shaderPara);
     _mushRen.SetPropertyBlock(_mushPropBlock);
     if (_mushPropBlock.GetFloat("_PageCurl_movement_1") <= -.5f)
     {
         _scrollOut = false;
         intro.SetActive(true);
     }
 }
示例#10
0
    private void Update()
    {
        if (isFrezz)
        {
            render.GetPropertyBlock(frezzblock);
            float _AnimOff = frezzblock.GetFloat("_AnimOff");
            _AnimOff -= Time.deltaTime;
            frezzblock.SetFloat("_AnimOff", _AnimOff);
            render.SetPropertyBlock(frezzblock);
        }

        if (isBlend)
        {
            render.GetPropertyBlock(blendblock);
            float _Blend = blendblock.GetFloat("_Blend");
            _Blend += Time.deltaTime * blendSpeed;
            if (_Blend >= 1)
            {
                _Blend  = 1;
                isBlend = false;
            }
            blendblock.SetFloat("_Blend", _Blend);
            render.SetPropertyBlock(blendblock);
        }
    }
示例#11
0
        void DoGetMaterialFloat()
        {
            string _propertyName = propertyName.Value;

            if (_propertyName == "")
            {
                _propertyName = "_Glossiness";
            }

            var go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (!UpdateCache(go))
            {
                return;
            }

            if (renderer.material == null)
            {
                LogError("Missing Material!");
                return;
            }

            renderer.GetPropertyBlock(_propBlock);
            floatValue.Value = _propBlock.GetFloat(_propertyName);
        }
 private void ChangeFade(Renderer renderer)
 {
     try
     {
         renderer.GetPropertyBlock(propertyStorage);
     }
     catch (NullReferenceException)
     {
         // epic 3
         FadeEmptyChests.Log(LogLevel.Warning,
                             "GetPropertyBlock failed, refreshing reference to renderers");
         RefreshRenderers();
         return;
     }
     if (gameObject.name == "mdlBarrel1")
     {
         propertyStorage.SetFloat("_Fade", currentFade);
     }
     else
     {
         float oldFade = propertyStorage.GetFloat("_Fade");
         propertyStorage.SetFloat("_Fade", oldFade * currentFade);
     }
     renderer.SetPropertyBlock(propertyStorage);
 }
示例#13
0
    static int GetFloat(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        Type[] types0 = { typeof(MaterialPropertyBlock), typeof(int) };
        Type[] types1 = { typeof(MaterialPropertyBlock), typeof(string) };

        if (count == 2 && LuaScriptMgr.CheckTypes(L, types0, 1))
        {
            MaterialPropertyBlock obj = LuaScriptMgr.GetNetObject <MaterialPropertyBlock>(L, 1);
            int   arg0 = (int)LuaScriptMgr.GetNumber(L, 2);
            float o    = obj.GetFloat(arg0);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else if (count == 2 && LuaScriptMgr.CheckTypes(L, types1, 1))
        {
            MaterialPropertyBlock obj = LuaScriptMgr.GetNetObject <MaterialPropertyBlock>(L, 1);
            string arg0 = LuaScriptMgr.GetString(L, 2);
            float  o    = obj.GetFloat(arg0);
            LuaScriptMgr.Push(L, o);
            return(1);
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: MaterialPropertyBlock.GetFloat");
        }

        return(0);
    }
示例#14
0
        /// <inheritdoc />
        public override ThemePropertyValue GetProperty(ThemeStateProperty property)
        {
            if (renderer == null)
            {
                return(null);
            }

            renderer.GetPropertyBlock(propertyBlock);

            startValue.Reset();

            int propId = property.GetShaderPropertyId();

            switch (property.Type)
            {
            case ThemePropertyTypes.Color:
                startValue.Color = propertyBlock.GetVector(propId);
                break;

            case ThemePropertyTypes.Texture:
                startValue.Texture = propertyBlock.GetTexture(propId);
                break;

            case ThemePropertyTypes.ShaderFloat:
            case ThemePropertyTypes.ShaderRange:
                startValue.Float = propertyBlock.GetFloat(propId);
                break;

            default:
                break;
            }

            return(startValue);
        }
    public static object GetRuntimeProperty(this Renderer render, int materialIndex, int propertyIndex)
    {
        MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();

        render.GetPropertyBlock(propertyBlock);

        Material material = render.materials[materialIndex];
        string   name     = material.GetPropertyName(propertyIndex);
        int      type     = material.GetPropertyType(propertyIndex);

        switch (type)
        {
        case 0:
            return(propertyBlock.GetColor(name));

        case 1:
            return(propertyBlock.GetVector(name));


        case 2:
        case 3:
            return(propertyBlock.GetFloat(name));

        case 4:
            return(propertyBlock.GetTexture(name));
        }
        return(null);
    }
示例#16
0
    void Update()
    {
        if (null != puzzleObject)
        {
            objectMat.SetColor(propColor, Color.Lerp(objectMat.GetColor(propColor), new Color(1f, 1f, 1f, objectAlpha), Time.deltaTime * fadeSpeed));
            finishedMat.SetColor(propColor, Color.Lerp(finishedMat.GetColor(propColor), new Color(1f, 1f, 1f, finishedAlpha), Time.deltaTime * fadeSpeed));

            wireframeObject.Renderer.GetPropertyBlock(materialPropertyBlock);
            materialPropertyBlock.SetFloat(propAlpha, Mathf.Lerp(materialPropertyBlock.GetFloat(propAlpha), wireframeAlpha, Time.deltaTime * fadeSpeed));
            wireframeObject.Renderer.SetPropertyBlock(materialPropertyBlock);
        }

        if (outOfBounds.Count > 0)
        {
            for (int i = outOfBounds.Count - 1; i >= 0; --i)
            {
                var obd = outOfBounds[i];
                var pos = obd.target.position;
                pos = Vector3.Lerp(pos, obd.inboundPos, Time.deltaTime * moveSpeed);
                if (Vector3.Distance(pos, obd.inboundPos) < 0.1f)
                {
                    pos = obd.inboundPos;
                    obd.target.GetComponent <Collider>().enabled = true;
                    outOfBounds.RemoveAt(i);
                }
                obd.target.position = pos;
            }
        }

        UpdaetProgress();
        stateMachine.Update();
    }
示例#17
0
        private void DamageTransition()
        {
            _renderer.GetPropertyBlock(_propBlock);
            float xScale = Mathf.Lerp(_propBlock.GetFloat("_HealthAmount"), health.currentHealthInMPropertyValue, healthLerpSpeed * Time.deltaTime);

            _propBlock.SetFloat("_HealthAmount", xScale);
            _renderer.SetPropertyBlock(_propBlock);
        }
示例#18
0
    public void changeSpeed(float s)
    {
        MaterialPropertyBlock block = new MaterialPropertyBlock();

        render.GetPropertyBlock(block);
        float start    = block.GetFloat("_AnimStart");
        float end      = block.GetFloat("_AnimEnd");
        float off      = block.GetFloat("_AnimOff");
        float speed    = block.GetFloat("_Speed");
        float _AnimLen = (end - start);
        float f        = (off + Time.timeSinceLevelLoad * speed) / _AnimLen;
        float newf     = (off + Time.timeSinceLevelLoad * s) / _AnimLen;
        float diff     = newf - f;

        off = off + diff * _AnimLen;
        block.SetFloat("_AnimOff", off);
        block.SetFloat("_Speed", s);
    }
示例#19
0
        protected override void OnTweenBegin()
        {
            _CachedTarget = _Target.value as Renderer;
            if (_CachedTarget == null && _Target.type == FlexibleType.Constant)
            {
                if (_MyRenderer == null)
                {
                    _MyRenderer = GetComponent <Renderer>();
                }

                _CachedTarget = _MyRenderer;
            }

            if (_CachedTarget == null)
            {
                return;
            }

            _CachedPropertyName = _PropertyName.value;

            _CachedFromValue = _From.value;
            _CachedToValue   = _To.value;

            if (_Block == null)
            {
                _Block = new MaterialPropertyBlock();
            }

            _CachedTarget.GetPropertyBlock(_Block);

            float startValue = 0.0f;

            if (_Block.isEmpty)
            {
                startValue = _CachedTarget.sharedMaterial.GetFloat(_CachedPropertyName);
            }
            else
            {
                startValue = _Block.GetFloat(_CachedPropertyName);
            }

            switch (_TweenMoveType)
            {
            case TweenMoveType.Absolute:
                break;

            case TweenMoveType.Relative:
                _CachedFromValue += startValue;
                _CachedToValue   += startValue;
                break;

            case TweenMoveType.ToAbsolute:
                _CachedFromValue = startValue;
                break;
            }
        }
示例#20
0
 private void Update()
 {
     if (t)
     {
         _time1 += Time.deltaTime;
         if (_time1 > duration)
         {
             if (BoxCol.enabled == true)  //取消碰撞体
             {
                 BoxCol.enabled = false;
             }
             MaterialPropertyBlock block = new MaterialPropertyBlock();
             SR.GetPropertyBlock(block);
             if (block.GetFloat("_BurnScale") >= 1)
             {
                 _time2 += Time.deltaTime;
                 if (_time2 > DisappearTime)  //开始恢复
                 {
                     isRecovery     = true;
                     t              = false;
                     _time1         = 0;
                     _time2         = 0;
                     BurnScale_time = 0;
                 }
             }
             else   //开始消融
             {
                 BurnScale_time += Time.deltaTime;
                 MaterialPropertyBlock t_block = new MaterialPropertyBlock();
                 t_block.SetTexture("_MainTex", SR.sprite.texture);
                 t_block.SetFloat("_BurnScale", Mathf.Lerp(0, 1, BurnScale_time / ablationTime));
                 SR.SetPropertyBlock(t_block);
             }
         }
     }
     if (isRecovery)  //恢复
     {
         MaterialPropertyBlock block = new MaterialPropertyBlock();
         SR.GetPropertyBlock(block);
         if (block.GetFloat("_BurnScale") > 0)
         {
             BurnScale_time += Time.deltaTime;
             MaterialPropertyBlock t_block = new MaterialPropertyBlock();
             t_block.SetTexture("_MainTex", SR.sprite.texture);
             t_block.SetFloat("_BurnScale", Mathf.Lerp(1, 0, BurnScale_time / ablationTime));
             SR.SetPropertyBlock(t_block);
         }
         else
         {
             BoxCol.enabled = true;
             isRecovery     = false;
             BurnScale_time = 0;
         }
     }
 }
        public static float GetFloat(GameObject host, int propId)
        {
            if (host == null)
            {
                return(0);
            }

            MaterialPropertyBlock block = InteractableThemeShaderUtils.GetPropertyBlock(host);

            return(block.GetFloat(propId));
        }
示例#22
0
        /// <summary>
        /// Updates the visualization of the health
        /// </summary>
        /// <param name="value">IProperty</param>
        private void UpdateValue(IProperty value)
        {
            m_Bar?.GetPropertyBlock(m_Props);

            if (!float.Equals(m_Props.GetFloat("_Cutoff"), value.Normalize))
            {
                m_Props.SetFloat("_Cutoff", value.Normalize);
                m_Bar?.SetPropertyBlock(m_Props);
            }
            SetVisible(showWhenFull || value.Normalize < 1.0f);
        }
示例#23
0
    // Update is called once per frame
    void Update()
    {
        if (eaten)
        {
            transform.localScale = transform.localScale + new Vector3(growingSpeed, growingSpeed, growingSpeed);
            transform.position  += new Vector3(0, verticalSpeed, 0);

            //Making It Transparent
            _renderer.GetPropertyBlock(propBlock);
            Debug.Log(propBlock.GetFloat("_Alpha"));
            propBlock.SetFloat("_Alpha", Mathf.Lerp(propBlock.GetFloat("_Alpha"), 0, dissapearingSpeed * Time.deltaTime));

            if (propBlock.GetFloat("_Alpha") <= 0.005f)
            {
                Destroy(gameObject);
            }

            _renderer.SetPropertyBlock(propBlock);
        }
    }
示例#24
0
        public static void OnFixAnimationTime()
        {
            var pb = new MaterialPropertyBlock();

            var objs = Object.FindObjectsOfType <Animator>();

            foreach (var animator in objs)
            {
                var acs = AnimationUtility.GetAnimationClips(animator.gameObject);
                foreach (var animationClip in acs)
                {
                    animationClip.SampleAnimation(animator.gameObject, 0.0f);
                }

                var render = animator.gameObject.GetComponent <Renderer>();
                if (render == null)
                {
                    continue;
                }
                render.GetPropertyBlock(pb);

                var shader = render.material.shader;
                for (int i = 0; i < shader.GetPropertyCount(); i++)
                {
                    var type = shader.GetPropertyType(i);
                    switch (type)
                    {
                    case ShaderPropertyType.Color:
                        render.material.SetColor(i, pb.GetColor(i));
                        break;

                    case ShaderPropertyType.Vector:
                        render.material.SetVector(i, pb.GetVector(i));
                        break;

                    case ShaderPropertyType.Float:
                        render.material.SetFloat(i, pb.GetFloat(i));
                        break;

                    case ShaderPropertyType.Range:

                        break;

                    case ShaderPropertyType.Texture:
                        render.material.SetTexture(i, pb.GetTexture(i));
                        break;

                    default:
                        throw new ArgumentOutOfRangeException();
                    }
                }
            }
        }
示例#25
0
 public float GetFloat(
     int propertyId)
 {
     if (instancedProperties.Contains(propertyId))
     {
         return(materialPropertyBlock.GetFloat(propertyId));
     }
     else
     {
         return(material.GetFloat(propertyId));
     }
 }
        /// <inheritdoc />
        public override ThemePropertyValue GetProperty(ThemeStateProperty property)
        {
            var result = new ThemePropertyValue();

            int propId = property.GetShaderPropertyId();

            if (renderer != null)
            {
                renderer.GetPropertyBlock(propertyBlock);
                switch (property.Type)
                {
                case ThemePropertyTypes.Color:
                    result.Color = propertyBlock.GetVector(propId);
                    break;

                case ThemePropertyTypes.Texture:
                    result.Texture = propertyBlock.GetTexture(propId);
                    break;

                case ThemePropertyTypes.ShaderFloat:
                case ThemePropertyTypes.ShaderRange:
                    result.Float = propertyBlock.GetFloat(propId);
                    break;

                default:
                    break;
                }
            }
            else if (graphic != null)
            {
                switch (property.Type)
                {
                case ThemePropertyTypes.Color:
                    result.Color = graphic.material.GetVector(propId);
                    break;

                case ThemePropertyTypes.Texture:
                    result.Texture = graphic.material.GetTexture(propId);
                    break;

                case ThemePropertyTypes.ShaderFloat:
                case ThemePropertyTypes.ShaderRange:
                    result.Float = graphic.material.GetFloat(propId);
                    break;

                default:
                    break;
                }
            }
            return(result);
        }
        public bool Render(Material decalMaterial, MaterialPropertyBlock partMPB, Camera camera)
        {
            if (_projectionEnabled)
            {
                _decalMPB.SetFloat(PropertyIDs._RimFalloff, partMPB.GetFloat(PropertyIDs._RimFalloff));
                _decalMPB.SetColor(PropertyIDs._RimColor, partMPB.GetColor(PropertyIDs._RimColor));

                Graphics.DrawMesh(_targetMesh, target.localToWorldMatrix, decalMaterial, 0, camera, 0, _decalMPB, ShadowCastingMode.Off, true);

                return(true);
            }

            return(false);
        }
示例#28
0
        /// <summary>
        /// Updates the visualization of the health
        /// </summary>
        /// <param name="value">IProperty</param>
        public void UpdateHealth(IProperty value)
        {
            if (m_Value != null)
            {
                m_Value.text = $"{Mathf.Ceil(value.Value)}";
            }

            m_Bar?.GetPropertyBlock(m_Props);
            if (!float.Equals(m_Props.GetFloat("_Cutoff"), value.Normalize))
            {
                m_Props.SetFloat("_Cutoff", value.Normalize);
                m_Bar?.SetPropertyBlock(m_Props);
            }
            SetVisible(showWhenFull || value.Normalize < 1.0f);
        }
示例#29
0
        /// <summary>
        /// Applies material overrides to a ring renderer.
        /// </summary>
        /// <param name="ringRenderer">Renderer using an MRTK/Standard material with the round corner feature enabled.</param>
        /// <param name="deltaTime">Scaled or unscaled delta time.</param>
        /// <param name="distance">Distance between the ring and surface.</param>
        /// <param name="visible">Should the ring be visible?</param>
        protected virtual void UpdateVisuals(Renderer ringRenderer, float deltaTime, float distance, bool visible)
        {
            ringRenderer.GetPropertyBlock(materialPropertyBlock);

            float t = Mathf.Clamp(distance, 0.0f, alignWithSurfaceDistance) / alignWithSurfaceDistance;

            materialPropertyBlock.SetFloat(roundCornerMarginID, Mathf.Lerp(nearAlignWithSurfaceMargin, farAlignWithSurfaceMargin, t));
            materialPropertyBlock.SetFloat(borderWidthID, Mathf.Lerp(nearAlignWithSurfaceWidth, farAlignWithSurfaceWidth, t));

            float currentAlpha = materialPropertyBlock.GetFloat(borderLightOpaqueAlphaID);

            materialPropertyBlock.SetFloat(borderLightOpaqueAlphaID, Mathf.Lerp(currentAlpha, (visible) ? 1.0f : 0.0f, deltaTime * alphaFadeSpeed));

            ringRenderer.SetPropertyBlock(materialPropertyBlock);
        }
示例#30
0
 private static void SetValues(Material mat, MaterialPropertyBlock block, ShaderValues[] values)
 {
     foreach (var val in values)
     {
         if (val.type == "Float")
         {
             var _float = block.GetFloat(val.value);
             mat.SetFloat(val.value, _float);
         }
         else if (val.type == "Color")
         {
             var _color = block.GetColor(val.value);
             mat.SetColor(val.value, _color);
         }
     }
 }