2016年12月8日 星期四

三原色

using UnityEngine;

using System.Collections;


using UnityEngine.UI;
public class NewBehaviourScript : MonoBehaviour
{


    // Use this for initialization


    void Start()
    {


    }



    // Update is called once per frame


    void Update()
    {


        myfun();
    }


    public void myfun()

    {

float num = 0;

num = GameObject.Find("Slider").GetComponent<Slider>().value;

Text mytxt = GameObject.Find("Text").GetComponent<Text>();

mytxt.text = num.ToString();

Image img = GameObject.Find("Image").GetComponent<Image>();

img.color = new Color(num,0.0F,0.0F,1.0F);


float num2 = 0;

num2 = GameObject.Find("Slider2").GetComponent<Slider>().value;

Text mytxt2 = GameObject.Find("Text2").GetComponent<Text>();

mytxt2.text = num2.ToString();

Image img2 = GameObject.Find("Image2").GetComponent<Image>();

img2.color = new Color(0.0F,num2,0.0F,1.0F);


float num3 = 0;

num3 = GameObject.Find("Slider3").GetComponent<Slider>().value;

Text mytxt3 = GameObject.Find("Text3").GetComponent<Text>();

mytxt3.text = num3.ToString();

Image img3 = GameObject.Find("Image3").GetComponent<Image>();

img3.color = new Color(0.0F,0.0F,num3,1.0F);

Image img4 = GameObject.Find("Image4").GetComponent<Image>();

img4.color = new Color(num,num2,num3,1.0F);
    }
}

沒有留言:

張貼留言