当前位置: 首页>>代码示例>>C#>>正文


C# MaterialPropertyBlock.SetColor方法代码示例

本文整理汇总了C#中UnityEngine.MaterialPropertyBlock.SetColor方法的典型用法代码示例。如果您正苦于以下问题:C# MaterialPropertyBlock.SetColor方法的具体用法?C# MaterialPropertyBlock.SetColor怎么用?C# MaterialPropertyBlock.SetColor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.MaterialPropertyBlock的用法示例。


在下文中一共展示了MaterialPropertyBlock.SetColor方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DrawCube

	public static void DrawCube(Vector3 position, Quaternion rotation, float size, Color color, int p_layer = 0)
	{
		Matrix4x4 mat = Matrix4x4.TRS(position, rotation, size * Vector3.one);
		MaterialPropertyBlock block = new MaterialPropertyBlock();
		block.SetColor("_Color", color);
		Graphics.DrawMesh(solidCube, mat, DebugMaterial, p_layer, null, 0, block);
	}
开发者ID:claudia-gp,项目名称:oblivious-oscar,代码行数:7,代码来源:DebugDraw.cs

示例2: DrawSphere

	public static void DrawSphere(Vector3 position, float radius, Color color, int p_layer = 0)
	{
		Matrix4x4 mat = Matrix4x4.TRS(position, Quaternion.identity, radius * Vector3.one);
		MaterialPropertyBlock block = new MaterialPropertyBlock();
		block.SetColor("_Color", color);
		Graphics.DrawMesh(solidSphere, mat, DebugMaterial, p_layer, null, 0, block);
	}
开发者ID:claudia-gp,项目名称:oblivious-oscar,代码行数:7,代码来源:DebugDraw.cs

示例3: UpdateOutline

 void UpdateOutline(bool outline)
 {
     MaterialPropertyBlock mpb = new MaterialPropertyBlock();
     spriteRenderer.GetPropertyBlock(mpb);
     mpb.SetFloat("_Outline", outline ? 1f : 0);
     mpb.SetColor("_OutlineColor", color);
     spriteRenderer.SetPropertyBlock(mpb);
 }
开发者ID:Magicolo,项目名称:PseudoFramework,代码行数:8,代码来源:SpriteOutline.cs

示例4: Evaluate

 /// <summary>
 /// Evaluates the property at "t" and stores its value in the MaterialPropertyBlock.
 /// </summary>
 /// <param name="block"></param>
 /// <param name="t"></param>
 public void Evaluate( MaterialPropertyBlock block, float t )
 {
     if( type == Type.Color )
     {
         block.SetColor( Id, Color.Lerp( from, to, t ) );
     }
     else if( type == Type.Float )
     {
         block.SetFloat( Id, Mathf.Lerp( from.a, to.a, t ) );
     }
 }
开发者ID:kazenotenshi,项目名称:GlobalGameJam2016,代码行数:16,代码来源:TweenShader.cs

示例5: InitializeColorChangeSystem

        private void InitializeColorChangeSystem(GameColor color) {
            Color32 primaryMeshColor = color.ToUnityColor(_primaryMeshAlpha);
            _primaryMeshMPB = new MaterialPropertyBlock();  // default color is black
            _primaryMeshRenderer.GetPropertyBlock(_primaryMeshMPB);
            // renderer's existing MaterialPropertyBlock color is also black, implying that the existing property block is the default, at least wrt color
            _primaryMeshMPB.SetColor(UnityConstants.StdShader_Property_AlbedoColor, primaryMeshColor);
            //D.Log("{0}.PrimaryMeshMPB color after initialization = {1}.", DebugName, _primaryMeshMPB.GetVector(UnityConstants.StdShader_Property_AlbedoColor));

            if (_hiddenMeshMPB == null) {
                _hiddenMeshMPB = new MaterialPropertyBlock();
                _primaryMeshRenderer.GetPropertyBlock(_hiddenMeshMPB);
                _hiddenMeshMPB.SetColor(UnityConstants.StdShader_Property_AlbedoColor, HiddenMeshColor);
            }
        }
开发者ID:Maxii,项目名称:CodeEnv.Master,代码行数:14,代码来源:UnitCmdDisplayManager.cs

示例6: Update

    void Update()
    {
        if (particles == null)
        {
            particles = new LinkedList<float>();
        }

        var interval = 1f / rate;
        var now = Time.time;

        //add new particle each interval
        if (now > lastParticle + interval)
        {
            particles.AddFirst(now);
            lastParticle = now;
        }

        //remove old particles
        while (particles.Last != null && particles.Last.Value + lifetime < now)
        {
            particles.RemoveLast();
        }

        //render particles
        foreach (var particle in particles)
        {
            float age = (now - particle) / lifetime;

            var color = gradient.Evaluate(age);
            var offset = transform.forward * speed * age * transform.localScale.z;

            var pos = transform.position + offset;
            var rot = transform.rotation;
            var scale = transform.localScale;

            var particleMat = Matrix4x4.TRS(pos, rot, scale);

            var matProperties = new MaterialPropertyBlock();
            if (materialTintProperty != null)
            {
                matProperties.SetColor("_TintColor", color);
            }

            if (mesh)
            {
                Graphics.DrawMesh(mesh, particleMat, material, 0, null, 0, matProperties);
            }
        }
    }
开发者ID:spriest487,项目名称:spacetrader-unity,代码行数:49,代码来源:MooringEffect.cs

示例7: DrawLine2D

	public static void DrawLine2D(Vector2 p_initialPosition, Vector2 p_finalPosition, Color p_color, Color p_pointColor, int p_layer = 0)
	{
		Vector2 v_middlePosition = new Vector2( (p_initialPosition.x + p_finalPosition.x)/2.0f, (p_initialPosition.y + p_finalPosition.y)/2.0f);
		Vector2 v_direction = VectorHelper.Direction(p_initialPosition, p_finalPosition);

		float v_distance = Mathf.Abs(Vector2.Distance(p_initialPosition, p_finalPosition));
		float v_angle = Vector2.Angle(new Vector2(1,0), v_direction);
		v_angle = p_finalPosition.y < p_initialPosition.y ? -v_angle : v_angle;

		Quaternion v_quaternion =  Quaternion.identity;
		v_quaternion.eulerAngles = new Vector3(0,0, v_angle);

		Matrix4x4 mat = Matrix4x4.TRS(v_middlePosition, v_quaternion, new Vector3(v_distance*0.5f, 0.003f, 0.003f) );
		MaterialPropertyBlock block = new MaterialPropertyBlock();
		block.SetColor("_Color", p_color);
		Graphics.DrawMesh(solidCube, mat, DebugMaterial, p_layer, null, 0, block);
		//Draw Points
		DrawSphere(p_initialPosition, 0.01f,  p_pointColor, p_layer);
		DrawSphere(p_finalPosition, 0.01f, p_pointColor, p_layer);
	}
开发者ID:claudia-gp,项目名称:oblivious-oscar,代码行数:20,代码来源:DebugDraw.cs

示例8: SetPropertyBlock

        public void SetPropertyBlock(MaterialPropertyBlock block,
                                     Transform modelTransform)
        {
            // model local space to world space matrix
            var l2w = modelTransform.localToWorldMatrix;

            // world space to effector local space matrix
            var w2e = transform.worldToLocalMatrix;

            // effector local space to normalized effector space matrix
            var es = _effectorSize;
            var invs = new Vector3(1.0f / es.x, 1.0f / es.y, 1.0f / es.z);
            var e2n = Matrix4x4.Scale(invs);

            block.SetMatrix("_Effector", e2n * w2e * l2w);

            block.SetVector("_Steepness", new Vector3(
                _transitionSteepness,
                _emissionTransitionSteepness,
                _scaleTransitionSteepness
            ));

            block.SetColor("_InitialEmission", _initialEmission);
            block.SetFloat("_InitialScale", _initialScale);

            if (_effectType == EffectType.Destruction)
                SetDestructionProps(block, modelTransform);
            else
                SetDisintegrationProps(block);
        }
开发者ID:esther5576,项目名称:SW-game-project,代码行数:30,代码来源:ScatterEffector.cs

示例9: doAnimateColor

 /**
 * For all child objects, lerps between the in and out colors based on the animation curve.
 * @since 4.1.4
 */
 protected virtual void doAnimateColor(float interpolationPoint) {
   float influence = ColorCurve.Evaluate(interpolationPoint);
   Transform[] children = RootTransform.gameObject.GetComponentsInChildren<Transform>(true);
   for (int g = 0; g < children.Length; g++) {
     Renderer renderer = children[g].gameObject.GetComponent<Renderer>();
     if (renderer != null) {
       materialProperties = new MaterialPropertyBlock();
       renderer.GetPropertyBlock(materialProperties);
       materialProperties.SetColor(ColorShaderPropertyName, Color.Lerp(renderer.sharedMaterial.color, TransitionColor, influence));
       renderer.SetPropertyBlock(materialProperties);
     }
   }
 }
开发者ID:WilliamRADFunk,项目名称:vedic,代码行数:17,代码来源:Transition.cs

示例10: ChangeColor

    public void ChangeColor(Toggle toggle)
    {
        if (!toggle.isOn) return;

        var colorThingy = toggle.gameObject.GetComponent<ColorThingy>();

        colorThingy.OnValidate(); // TODO Badness searches whole scene each button press, just in case things changed

        foreach (var colorThingThing in colorThingy.things) {

            var colorIntensified = colorThingThing.color*colorThingThing.intensity;

            MaterialPropertyBlock propertyBlock = new MaterialPropertyBlock();
            propertyBlock.SetColor("_EmissionColor", colorIntensified);

            // Debug.Log("Setting color " + color + " on " + renderers.Count + " renderers");

            if (colorThingy.randomDiscoMode) {
                foreach (var thingThing in colorThingy.things) {
                    thingThing.color = colorThingy.randomColors.Evaluate(Random.Range(0f, 1f));
                }
            }

            if (colorThingThing.affectMaterial) {
                foreach (Renderer o in colorThingThing.renderers) {
                    if (o != null) {
                        o.SetPropertyBlock(propertyBlock);
                        //Debug.Log("Material uses: " + renderer.material.GetColor("_EmissionColor"));
                        //Debug.Log("Setting color: " + color);
                        DynamicGI.SetEmissive(o, colorIntensified);
                    }
                }
            }

            foreach (var o in  colorThingThing.lights) {
                if (o != null) o.color = GetColor(colorThingThing);
            }

            foreach (var matprop in  colorThingThing.matProps) {
                if (matprop != null) {
                    matprop._color = new Gradient {
                        colorKeys = new[] {new GradientColorKey(colorThingThing.color, 0), new GradientColorKey(colorThingThing.color, 1)}
                    };
                    matprop.Run();
                }
            }

            foreach (var lightprop in  colorThingThing.lightProps) {
                if (lightprop != null) {
                    lightprop.targetColor = GetColor(colorThingThing);
                    lightprop.Run();
                }
            }

            foreach (var agentprop in  colorThingThing.agentProps) {
                if (agentprop != null) {
                    agentprop.ColorOverride(GetColor (colorThingThing));
                }
            }

        }
    }
开发者ID:zehro,项目名称:Projects,代码行数:62,代码来源:ColorSwatch.cs


注:本文中的UnityEngine.MaterialPropertyBlock.SetColor方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。