當前位置: 首頁>>代碼示例>>C#>>正文


C# Material.SetColor方法代碼示例

本文整理匯總了C#中UnityEngine.Material.SetColor方法的典型用法代碼示例。如果您正苦於以下問題:C# Material.SetColor方法的具體用法?C# Material.SetColor怎麽用?C# Material.SetColor使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在UnityEngine.Material的用法示例。


在下文中一共展示了Material.SetColor方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: GenerateWireframeMeshsAndMaterials

	private void GenerateWireframeMeshsAndMaterials() {
		foreach (MeshNMaterial subObj in subObjects) {
			//添加AmazingWireframeGenerator
			subObj.gameObject.AddComponent<TheAmazingWireframeGenerator>();
			for (int i = 0;i < subObj.originalMaterials.Length;i++) {
				Material wireframeNoTexMat = new Material(
					Shader.Find("VacuumShaders/The Amazing Wireframe/Unlit/NoTex"));
				wireframeNoTexMat.SetColor("_Color", subObj.originalMaterials[i].GetColor("_Color"));
				wireframeNoTexMat.EnableKeyword("V_WIRE_ANTIALIASING_ON");
				wireframeNoTexMat.EnableKeyword("V_WIRE_LIGHT_ON");
				subObj.wireframeNoTexMaterials[i] = wireframeNoTexMat;
				Material wireframeTexMat = new Material(
						Shader.Find("VacuumShaders/The Amazing Wireframe/Deferred/Bumped Specular"));
				wireframeTexMat.SetColor("_Color", subObj.originalMaterials[i].GetColor("_Color"));
				if (subObj.originalMaterials[i].HasProperty("_SpecColor"))
					wireframeTexMat.SetColor("_SpecColor", subObj.originalMaterials[i].GetColor("_SpecColor"));
				if (subObj.originalMaterials[i].HasProperty("_Shininess"))
					wireframeTexMat.SetFloat("_Shininess", subObj.originalMaterials[i].GetFloat("_Shininess"));
				wireframeTexMat.SetTexture("_MainTex", subObj.originalMaterials[i].GetTexture("_MainTex"));
				if (subObj.originalMaterials[i].HasProperty("_BumpMap"))
					wireframeTexMat.SetTexture("_BumpMap", subObj.originalMaterials[i].GetTexture("_BumpMap"));
				wireframeTexMat.EnableKeyword("V_WIRE_ANTIALIASING_ON");
				wireframeTexMat.EnableKeyword("V_WIRE_LIGHT_ON");
				subObj.wireframeTexMaterials[i] = wireframeTexMat;
			}
		}
	}
開發者ID:AmaranthYan,項目名稱:theArena,代碼行數:27,代碼來源:FocusableWeaponComponent.cs

示例2: PathController

        public PathController(QueryTool tool)
        {
            queryTool = tool;
            currentHighlightType = HighlightType.None;

            Config.instance.eventConfigChanged += () => { OnConfigChanged(); };

            Log.info("Load Line Material...");

            Color red = new Color(1, 0, 0);
            Color gold = new Color(1, 0.9f, 0);

            string lineShader = ResourceLoader.loadResourceString("Materials/Shaders/TransparentVertexLit.shader");

            lineMaterial = new Material(lineShader);
            lineMaterial.color = red;
            lineMaterial.SetColor("_Emission", red);
            lineMaterial.SetColor("_SpecColor", Color.black); //Disable shine effect
            lineMaterial.mainTexture = ResourceLoader.loadTexture("Materials/NewSkin.png");
            lineMaterial.renderQueue = 100;

            lineMaterialHighlight = new Material(lineMaterial);
            lineMaterialHighlight.color = gold;
            lineMaterialHighlight.SetColor("_Emission", gold);
            lineMaterial.renderQueue = 101;

            Texture pin = ResourceLoader.loadTexture("Materials/Pin.png");

            activeSegmentIndicator = Billboard.Create(Billboard.CreateSpriteMaterial(pin, Color.green));
            vehicleIndicator = Billboard.CreateSpriteMaterial(pin, red);
            vehicleIndicatorHighlight = Billboard.CreateSpriteMaterial(pin, gold);

            Log.debug("PathController initialized");
        }
開發者ID:akira-ishizaki,項目名稱:TrafficReport,代碼行數:34,代碼來源:PathController.cs

示例3: Awake

 void Awake()
 {
     material = new Material(Shader.Find("Hidden/ChannelMixer"));
     material.SetColor("_R", RGB[0, 0]);
     material.SetColor("_G", RGB[0, 1]);
     material.SetColor("_B", RGB[0, 2]);
 }
開發者ID:Nachtrind,項目名稱:Fungus,代碼行數:7,代碼來源:ColorBlindFilter.cs

示例4: Start

    void Start()
    {
        var granny = GameObject.Find("Granny");

        if (granny != null)
        {
            grannyCollider = granny.GetComponent<Collider2D>();
            itemUse = granny.GetComponent<ItemUse>();
        }

        var spriteRenderer = GetComponent<SpriteRenderer>();

        if (materials == null)
        {
            var effectsCount = Enum.GetNames(typeof(Effect)).Length;

            materials = new Material[effectsCount];

            materials[0] = spriteRenderer.material;

            for (int i = 1; i < effectsCount; i++)
            {
                var randomMaterial = new Material(spriteRenderer.material);

                randomMaterial.SetColor("_ColorR", Utils.RandomHueColor());
                randomMaterial.SetColor("_ColorG", Utils.RandomHueColor());
                randomMaterial.SetColor("_ColorB", Color.white);

                materials[i] = randomMaterial;
            }
        }

        spriteRenderer.material = getMaterial(PillEffect);
    }
開發者ID:samowski,項目名稱:SuperGameProjectofAwesome,代碼行數:34,代碼來源:Pill.cs

示例5: Awake

 void Awake()
 {
     material = new Material( Shader.Find("Hidden/Gradient") );
     material.SetColor("_ColorA", colorA);
     material.SetColor("_ColorB", colorB);
     material.SetColor("_ColorC", colorC);
 }
開發者ID:leon196,項目名稱:UnityVJ,代碼行數:7,代碼來源:GradientFilter.cs

示例6: Start

	void Start () {

		if(PlayerPrefs.GetInt(Application.loadedLevelName + "Door" + id) == 0){
			open = false;
		}else{
			open = true;
		}

		mat = GetComponent<MeshRenderer>().material;

		if(bodenschalter.Length == 1){
			onColor = bodenschalter[0].onColor;
			offColor = bodenschalter[0].offColor;
		}

		if(open){
			mat.SetColor("_Color", onColor);
		}else{
			mat.SetColor("_Color", offColor);
		}

		switch(openDirection){
			case DoorDirection.UP: endpos = transform.position + transform.up*openDistance*5.5f; break;
			case DoorDirection.DOWN: endpos = transform.position - transform.up*openDistance*5.5f; break;
			case DoorDirection.LEFT: endpos = transform.position - transform.right*openDistance*5.5f; break;
			case DoorDirection.FWD: endpos = transform.position + transform.forward*openDistance*5.5f; break;
			case DoorDirection.BWD: endpos = transform.position - transform.forward*openDistance*5.5f; break;
			default: endpos = transform.position + transform.right*openDistance*5.5f; break;
		}

		startpos = transform.position;
	
	}
開發者ID:yzeal,項目名稱:Weltenseele2,代碼行數:33,代碼來源:Door.cs

示例7: Start

    // Use this for initialization
    void Start()
    {
        //countdown = transform.parent.parent.GetComponent<Countdown>();

        countdown = transform.parent.GetComponent<Countdown>();

        renderer = GetComponent<Renderer>();
        material = renderer.material;

        if (red) {
            material.SetColor("_EmissionColor", Color.grey);
            myColor = Color.red;
            signal = Countdown.signal.RED;
        }
        if (yellow) {
            material.SetColor("_EmissionColor", Color.grey);
            myColor = Color.yellow;
            signal = Countdown.signal.YELLOW;
        }
        if (green) {
            material.SetColor("_EmissionColor", Color.grey);
            myColor = Color.green;
            signal = Countdown.signal.GREEN;
        }
        material.SetFloat("_EmissionScaleUI", 0.1f);
    }
開發者ID:Rarau,項目名稱:racing_game,代碼行數:27,代碼來源:OnLight.cs

示例8: BallDestroy

    //ball is destoryed because it got stuck in the wall
    void BallDestroy()
    {
        Material particleColor = new Material(shotColor);
        if (colorShot == 0)//if ball is green increase greenshots by one
        {
            gVar.greenShots++;
            particleColor.SetColor("_EmissionColor", GREEN);
        }
        else if (colorShot == 1)
        {
            gVar.redShots++;
            particleColor.SetColor("_EmissionColor", RED);
        }
        else if (colorShot == 2)
        {
            gVar.blueShots++;
            particleColor.SetColor("_EmissionColor", BLUE);
        }
        else if (colorShot == 3)
        {
            gVar.purpleShots++;
            particleColor.SetColor("_EmissionColor", PURPLE);
        }

        GameObject particles = (GameObject)Instantiate(ballParticleSystem, this.GetComponent<Transform>().position, Quaternion.identity);
        particles.GetComponent<Renderer>().material = particleColor;
        Destroy(particles, 0.5f);
        Destroy(gameObject);
    }
開發者ID:rebeccaansems,項目名稱:Alieball,代碼行數:30,代碼來源:Rocket.cs

示例9: Test

	IEnumerator Test( Material mat, Color newColor )
	{
		Color orgColor = mat.GetColor("_EmissionColor");
		mat.SetColor("_EmissionColor", newColor);
		yield return new WaitForSeconds(0.5f);
		mat.SetColor("_EmissionColor", orgColor);
	}
開發者ID:frzpop,項目名稱:RubberHookshot,代碼行數:7,代碼來源:InputManager.cs

示例10: ChangeColor

    /// <summary>
    /// Changes the color of the given material
    /// </summary>
    /// <param name="material"></param>
    /// <param name="color"></param>
    public IEnumerator ChangeColor(Material material, Color color, float seconds)
    {
        Color currentColor = material.GetColor("_EmissionColor");
        material.SetColor("_EmissionColor", color);
        yield return new WaitForSeconds(seconds);

        // Reset color to initial one
        if (seconds > 0) { material.SetColor("_EmissionColor", currentColor); }
    }
開發者ID:FeedJonathanFoundation,項目名稱:ubisoft-game-lab,代碼行數:14,代碼來源:MaterialExtensions.cs

示例11: Start

 public void Start()
 {
     fxRes = GetComponent<IndieEffects>();
     mat = new Material(shader);
     mat.SetColor("_Lift", Lift);
     mat.SetFloat("_LiftB", Mathf.Clamp(LiftBright, 0f, 2f));
     mat.SetColor("_Gamma", Gamma);
     mat.SetFloat("_GammaB", Mathf.Clamp(GammaBright, 0f, 2f));
     mat.SetColor("_Gain", Gain);
     mat.SetFloat("_GainB", Mathf.Clamp(GainBright, 0f, 2f));
 }
開發者ID:GreatArcStudios,項目名稱:UnityIndieEffects,代碼行數:11,代碼來源:ColorBalance.cs

示例12: attackobject

	// Update is called once per frame
	IEnumerator attackobject() {
        yield return new WaitForEndOfFrame();
       mat = transform.GetChild(0).gameObject.GetComponent<MeshRenderer>().material;
        while (true)
        {
            mat.SetColor("_TintColor",new Color(0.3f,0.3f,0.3f));
            yield return new WaitForSeconds(Random.value/10);
            mat.SetColor("_TintColor", new Color(0.5f, 0.5f, 0.5f));
            yield return new WaitForSeconds(Random.value);
        }
	
	}
開發者ID:MilindNilekani,項目名稱:Athena,代碼行數:13,代碼來源:attackenemyui.cs

示例13: Start

	void Start () {

		mat = GetComponentInChildren<MeshRenderer>().material;

		if(bodenschalter.Length > 0){
			onColor = bodenschalter[0].onColor;
			offColor = bodenschalter[0].offColor;
		}

		if(on){
			mat.SetColor("_Color", onColor);
		}else{
			mat.SetColor("_Color", offColor);
		}
	}
開發者ID:yzeal,項目名稱:Weltenseele2,代碼行數:15,代碼來源:Hinweis.cs

示例14: FadeIn

    //fades the buttons in as well
    IEnumerator FadeIn(Material material, float fadeSpeed)
    {
        Color tempColor = material.color;
          tempColor.a = 0;
          material.SetColor ("_Color", tempColor);

          while (material.color.a < 1) {

        tempColor.a += fadeSpeed;
        material.SetColor ("_Color", tempColor);

        yield return null;

          }
    }
開發者ID:connor-a-smith,項目名稱:VR-Hub,代碼行數:16,代碼來源:MainEyeButton.cs

示例15: _FadeOut

 protected IEnumerator _FadeOut(Material m, float time)
 {
     var c = m.GetColor(Outline);
     var startAlpha = c.a;
     var start = Time.time;
     var end = start + time;
     while(Time.time <= end) {
         var progress = Mathf.InverseLerp(start, end, Time.time);
         var alpha = Mathf.Lerp(startAlpha, 0, progress);
         m.SetColor(Outline, SetAlpha(c, alpha));
         yield return new WaitForEndOfFrame();
     }
     m.SetColor(Outline, SetAlpha(c, 0));
     _fadingOut.Remove(m);
 }
開發者ID:nkf,項目名稱:gamedev2014_20minexp,代碼行數:15,代碼來源:InvokableAction.cs


注:本文中的UnityEngine.Material.SetColor方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。