Inheritance: MonoBehaviour
示例#1
0
 void OnGUI()
 {
     if (GUI.Button(new Rect(20, 20, 150, 40), "Aircraft On/Off"))
     {
         if (!isOn)
         {
             shaderGlow gls = elCubo.GetComponent <shaderGlow>();
             gls.lightOn();
             isOn = true;
         }
         else
         {
             shaderGlow gls = elCubo.GetComponent <shaderGlow>();
             gls.lightOff();
             isOn = false;
         }
     }
 }
    void Update()
    {
        if (Application.isEditor)
        {
            if (Input.GetMouseButtonDown(0))
            {
                ButtonPressed(Input.mousePosition);
            }
        }
        else
        {
            if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
            {
                ButtonPressed(Input.GetTouch(0).position);
            }
        }

        if (!QuizController.instance.quizStarted)
        {
            return;
        }
        RaycastHit hit;
        Transform  objectHit = null;
        Ray        ray       = ARCamera.ViewportPointToRay(new Vector3(0.5F, 0.5F, 0));

        if (Physics.Raycast(ray, out hit))
        {
            objectHit = hit.transform;
        }
        shaderGlow glowObj = null;

        // I have no idea why i removed this, might be breaking everything by not being there.
        // TODO: check
        if (objectHit != null)
        {
            if (QuizController.instance.questionCurrentlyGoing && objectHit.tag == "QuizObject")
            {
                return;
            }
            if (!QuizController.instance.questionCurrentlyGoing && objectHit.tag == "AnswerObject")
            {
                return;
            }
        }
        if (objectHit != null)
        {
            glowObj = objectHit.GetComponent <shaderGlow>();
        }
        if (currentlyGlowing != glowObj)
        {
            if (currentlyGlowing != null)
            {
                currentlyGlowing.lightOff();
            }
            if (glowObj != null)
            {
                glowObj.lightOn();
            }
        }
        currentlyGlowing = glowObj;
    }