예제 #1
0
    void Update()
    {
        // Check if there were any objects hit by our reticle-ray cast in the scene. If so, check whether or not
        // it has a TextureCycler component.
        if (Raycaster.getInstance().anythingHitByRay())
        {
            GameObject objHitByRay = Raycaster.getInstance().getObjectHitByRay();
            string     objHitTag   = objHitByRay.tag;

            Debug.Log(objHitTag);

            // Check that there was a valid object hit by the raycast. Raycaster.getInstance().getObjectHitByRay()
            // returns null if no objects were hit by ray cast on this frame. Objects responding to input must have
            // one of the increment/decrement/slideshow tags set to be affected and cycled by raycast.
            if (objHitByRay != null && isTagValidButton(objHitTag))
            {
                if (TextureObject != null)
                {
                    for (int i = 0; i < TextureObject.Length; ++i)
                    {
                        TextureCycler objToCycleCycler = TextureObject[i].GetComponent <TextureCycler>();

                        // Cycle the textures on it!
                        if (objToCycleCycler != null)
                        {
                            if (ButtonsDefineCyclerMode)
                            {
                                objToCycleCycler.setTextureCycleMode(mapTagToModeIndex(objHitTag));
                            }

                            objToCycleCycler.cycleTextures();
                        }
                    }
                }
            }
            else if (mapTagToModeIndex(objHitTag) == 2)
            {
                togglePause();
            }
            else if (mapTagToModeIndex(objHitTag) == 3)
            {
                Debug.Log("Restart clicked");
                Application.LoadLevel(Application.loadedLevel);
            }
        }

        if (ScreenFaderSphere.getInstance() && !mFirstTextureReady && TextureLoader.getInstance().isFinishedLoadingFirstTexture())
        {
            mFirstTextureReady = true;
            ScreenFaderSphere.getInstance().fadeToTransparent();
        }
    }
        //Handle the Click event
        private void HandleClick()
        {
            Debug.Log("Show click state");
            m_Renderer.material = m_ClickedMaterial;

            for (int i = 0; i < TextureObject.Length; ++i)
            {
                TextureCycler objToCycleCycler = TextureObject[i].GetComponent <TextureCycler>();

                // Cycle the textures on it!
                if (objToCycleCycler != null)
                {
                    if (ButtonsDefineCyclerMode)
                    {
                        objToCycleCycler.setTextureCycleMode(0);
                    }

                    objToCycleCycler.cycleTextures();
                }
            }
        }