Example #1
0
 void Start()
 {
     if (ScreenFaderSphere.getInstance())
     {
         ScreenFaderSphere.getInstance().setAlpha(1.0f);
     }
 }
Example #2
0
    // Use this for initialization
    void Awake()
    {
        Application.targetFrameRate = 60;
        //OVRModeParms.setCpuGpuLevels( 2, 2 );

        if (ScreenFaderSphere.getInstance())
        {
            mFadeToBlackDuration = ScreenFaderSphere.getInstance().fadeToBlackDuration;
        }
    }
Example #3
0
    void Update()
    {
        // This mFirstTextureReady flag is only used to check the first texture loading.
        // Once the textures are loaded we mark a flag so that this only executes once.
        if (!mFirstTextureReady && TextureLoader.getInstance().isFinishedLoadingFirstTexture())
        {
            mFirstTextureReady = true;

            // Make sure the texture index is in the right bounds.
            if (mStartingTextureIndex >= TextureLoader.getInstance().getTextureCount() || mStartingTextureIndex < 0)
            {
                mStartingTextureIndex = 0;
            }

            mCurrentTextureIndex = mStartingTextureIndex;

            // Only apply the texture if the application is using the device textures ONLY for start (starting tex == 0)
            // because applyReadyTexture() is already called from the loader.
            if (TextureLoader.getInstance().getStartingTextureCount() > 0)
            {
                applyReadyTexture();
            }
        }

        // If the texture index has changes (cycle called), this will modify the texture object
        // on the material.
        if (mCurrentTextureIndex != mLastTextureIndex)
        {
            mLastTextureIndex = mCurrentTextureIndex;

            float fadeBlackDur = 0.0f;
            if (ScreenFaderSphere.getInstance())
            {
                fadeBlackDur = ScreenFaderSphere.getInstance().fadeToBlackDuration;
                ScreenFaderSphere.getInstance().fadeToBlack();
            }

            Invoke("beginTextureLoading", fadeBlackDur);
        }

        // Responsible for cycling textures every (mCycleDelay) intervals.
        if (mSlideShowStarted && Time.unscaledTime >= mSlideUpdateTime)
        {
            mSlideUpdateTime = Time.unscaledTime + mCycleDelay;

            if (mChangeSlideOnFirstClick || mFirstSlideShown)
            {
                mCurrentTextureIndex = (mDecrementSlides) ? mCurrentTextureIndex - 1 : mCurrentTextureIndex + 1;
            }

            mFirstSlideShown = true;
            resetTextureIndexCheckBounds();
        }
    }
Example #4
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();
        }
    }
Example #5
0
    void Update()
    {
        if (!mFastGpuMode)
        {
            mFastGpuMode = true;
        }

        if (!mTransitionStarted && Time.time >= timeFadeShouldStart())
        {
            if (ScreenFaderSphere.getInstance())
            {
                ScreenFaderSphere.getInstance().fadeToBlack();
            }

            mTransitionStarted = true;
        }
    }
Example #6
0
    void Start()
    {
        screenFader = GameObject.Find("Sphere_Inv").GetComponent <ScreenFaderSphere> ();

        canvasTextTag       = GameObject.Find("Text").GetComponent <Text> ();
        canvasTextTag.color = Color.clear;

        camera       = GameObject.Find("MainCamera");
        cameraParent = GameObject.Find("MainCameraParent");

        prevRotation = camera.transform.rotation;

        clickableItems.Add("ClickableDrawing", "Your son’s first drawing. You have cherished this image for as long as you can remember.");
        clickableItems.Add("ClickablePhoto", "Your beautiful family. They have brought you so much joy in your life and have been there whenever you needed them. ");
        clickableItems.Add("ClickableScarf", "Your sister’s scarf. You gave her this scarf as a gift when she graduated university.  She loves you and how you supported her through her difficult time in school.");
        clickableItems.Add("ClickableRing", "Your wedding band. Shouldn’t it be on your finger?  No, wait- they have to remove all jewelry before surgery. You and your spouse are so in love, even after all these years. ");
        clickableItems.Add("ClickableMri", "A scan of your brain. To think just a blink of the eye ago it was perfectly fine. Now it is uncertain whether it will allow you to keep living.");
        FadeText();
        displayInfo = true;
        message     = "Your head hit the ground. The doctors took you into surgery right away. They managed to stop the bleeding in your brain but you never woke up. You slipped into a coma.\n\n The doctors think it is only a matter of time before you pass. Your family is in deep agony. Some have hope you will survive, others are starting to accept you will never be with them again. Maybe if you keep holding on and find memories to give you strength to keep going, you will wake from the coma. ";
    }
Example #7
0
 public void fadeToTransparent()
 {
     ScreenFaderSphere.getInstance().fadeToTransparent();
 }
Example #8
0
 public void fadeToBlack()
 {
     ScreenFaderSphere.getInstance().fadeToBlack();
 }
Example #9
0
    // Used to read and load a texture2D from an Android device - from a specific folder.
    // mCurrTexture is set to null when the index indicates we want to use default textures; in this case
    // we just return the mStartingTexture[mCurrentTextureIndex]. Otherwise, if we are loading a texture from
    // the device, mCurrTexture will be set to the texture read.
    public IEnumerator LoadTextureAtIndex(int textureIndex, bool firstTime, TextureCycler cyclerToCallback)
    {
        if (mAndroidEnvironment && !string.IsNullOrEmpty(mLocalStorageDirPath) && System.IO.Directory.Exists(mLocalStorageDirPath) &&
            (textureIndex >= mStartingTextures.Length &&
             textureIndex < (mTextureFileNames.Count + mStartingTextures.Length)))
        {
            // Append each texture name (as the name appears inside mLocalStoragePath) before each load.
            int    startingTextureOffset = mStartingTextures == null ? 0 : mStartingTextures.Length;
            string currTexturePath       = mLocalStorageDirPath + mTextureFileNames[textureIndex - startingTextureOffset];

            // Add "file:///" to the beginning of the absolute path so the WWW object knows its a file protocol.
            WWW textureWWW = new WWW("file:///" + currTexturePath);

            if (textureWWW.error != null)
            {
                Debug.Log(name + textureWWW.url + " error: " + textureWWW.error);
            }
            else
            {
                // Yield return from the coroutine while the texture is loading.
                while (!textureWWW.isDone)
                {
                    yield return(null);
                }

                // Destroy the old texture member variable before creating a new one to save memory.
                if (mCurrTexture != null)
                {
                    Texture2D.Destroy(mCurrTexture);
                }

                // Create a new texture2D and load the WWW contents into it
                // Note: this call is blocking on the UI thread, so we fade in and out to mask load times.
                mCurrTexture          = new Texture2D(4, 4, TextureFormat.DXT1, false);
                mCurrTexture.wrapMode = TextureWrapMode.Repeat;
                textureWWW.LoadImageIntoTexture(mCurrTexture);

                // Clean up the WWW object and call the GC each time we load a texture from device.
                // This is to avoid memory allocation issues.
                textureWWW.Dispose();
                textureWWW = null;
                System.GC.Collect();

                if (cyclerToCallback != null)
                {
                    cyclerToCallback.applyReadyTexture();
                    ScreenFaderSphere.getInstance().fadeToTransparent();

                    // Check if this is the first texture loaded, if so set this flag so that
                    // the texture cycler can know when it's ready.
                    if (firstTime)
                    {
                        mFinishedFirstTexture = true;
                    }
                }
            }
        }
        else
        {
            mCurrTextureIndex = textureIndex;
            mCurrTexture      = null;
            cyclerToCallback.applyReadyTexture();

            if (ScreenFaderSphere.getInstance())
            {
                ScreenFaderSphere.getInstance().fadeToTransparent();
            }
        }
    }