Пример #1
0
        void OnGUI()
        {
            this.scaledSize = style.normal.background.GetScaleSize(this.transform.localScale);
            if (this.overrideWidth > 0f || this.overrideHeight > 0f)
            {
                this.scaledSize = GUIScale.RectScaleSize(this.overrideWidth, this.overrideHeight, this.transform.localScale);
            }

            float screenW = (float)(Screen.width) / 2f - Camera.main.pixelWidth / 2;
            float screenH = (float)(Screen.height) / 2f - Camera.main.pixelHeight / 2;

            this.pos = new Vector2
                       (
                screenW + this.transform.position.x * (Camera.main.pixelWidth - this.scaledSize.Width),
                screenH + this.transform.position.y * (Camera.main.pixelHeight - this.scaledSize.Height)
                       );

            var area = new Rect(this.pos.x, this.pos.y, scaledSize.Width, scaledSize.Height);

            float finalSize = Mathf.Min(scaledSize.Width, scaledSize.Height) * this.fontSizeRatio;

            this.style.fontSize = (int)finalSize;

            this.style.contentOffset = new Vector2(
                scaledSize.Width * this.textOffsetRatio.x,
                scaledSize.Height * this.textOffsetRatio.y);

            GUI.depth = this.guiDepth;
            GUI.Label(area, this.title, this.style);
        }
Пример #2
0
 void Start()
 {
     Screen.orientation = ScreenOrientation.LandscapeLeft;
     Gameoptions.Start();
     Debug.Log("Startup Complete");
     GUIScale.SetAspectRatio();
     GUIScale.SetGuiMatrix();
 }
Пример #3
0
    void OnGUI()
    {
        RectSize scaledSize = GUIScale.RectScaleSize(this.orginalWidth, this.orginalHeight, this.scaleRatio);

        float x = -(scaledSize.Width / 2);
        float y = -(scaledSize.Height / 2);

        guiTexture.pixelInset = new Rect(x, y, scaledSize.Width, scaledSize.Height);
    }
Пример #4
0
        public static RectSize GetScaleSize(this Texture texture, Vector2 scaleRatio)
        {
            float textureHeight = 0f;
            float textureWidth  = 0f;

            if (texture != null)
            {
                textureHeight = (float)texture.height;
                textureWidth  = (float)texture.width;
            }

            return(GUIScale.RectScaleSize(textureWidth, textureHeight, scaleRatio));
        }
Пример #5
0
    public static GameObject ShowText(string name, string text, float time, TextAlignment alignment, TextAnchor anchor, float x, float y)
    {
        LoadFonts();

        // Destroy old object if existent
        GameObject textObject = GameObject.Find(PREFIX + name);

        MonoBehaviour.Destroy(textObject);

        textObject = new GameObject(PREFIX + name);

        textObject.AddComponent <OutlineText>().thickness = 2;

        TutorialText textBehaviour = textObject.GetComponent <TutorialText>();

        if (textBehaviour == null)
        {
            textBehaviour = textObject.AddComponent <TutorialText>();
        }

        GUIScale textScaler = textObject.GetComponent <GUIScale>();
        GUIText  guitext    = textObject.GetComponent <GUIText>();

        guitext.enabled = true;

        textObject.transform.position = new Vector3(x, y, 0);

        guitext.text      = text;
        guitext.anchor    = anchor;
        guitext.alignment = alignment;
        //guitext.font = bigFont;
        //guitext.material = bigMat;
        //guitext.fontSize = 48;

        if (time > 0)
        {
            textBehaviour.DestroyIn(time);
        }

        return(textObject);
    }
Пример #6
0
    void OnGUI()
    {
        GUIScale.SetGuiMatrix();
        GUI.skin.label.fontSize  = 36;
        GUI.skin.button.fontSize = 48;
        GUI.skin.box.fontSize    = 64;

        GUI.Box(new Rect(GUIScale.virtualWidth * .10f, GUIScale.virtualHeight * .10f, GUIScale.virtualWidth * .80f, GUIScale.virtualHeight * .82f), "Select Gametype");

        if (GUI.Button(new Rect(GUIScale.virtualWidth * .20f, GUIScale.virtualHeight * .30f, GUIScale.virtualWidth * .60f, GUIScale.virtualHeight * .10f), "Free Play"))
        {
            Gameoptions.TypeGame = 0;
            Gameoptions.SaveOptions();
            Application.LoadLevel(1);
        }

        if (GUI.Button(new Rect(GUIScale.virtualWidth * .20f, GUIScale.virtualHeight * .45f, GUIScale.virtualWidth * .60f, GUIScale.virtualHeight * .10f), "Colors"))
        {
            Gameoptions.TypeGame = 1;
            Gameoptions.SaveOptions();
            Gameoptions.LoadOptions();
            Application.LoadLevel(1);
        }

        if (GUI.Button(new Rect(GUIScale.virtualWidth * .20f, GUIScale.virtualHeight * .60f, GUIScale.virtualWidth * .60f, GUIScale.virtualHeight * .10f), "Cinema"))
        {
            Gameoptions.TypeGame = 2;
            Gameoptions.SaveOptions();
            Application.LoadLevel(1);
        }

        if (GUI.Button(new Rect(GUIScale.virtualWidth * .20f, GUIScale.virtualHeight * .75f, GUIScale.virtualWidth * .60f, GUIScale.virtualHeight * .10f), "Counting"))
        {
            Gameoptions.TypeGame = 3;
            Gameoptions.SaveOptions();
            Application.LoadLevel(1);
        }
    }
Пример #7
0
    void OnGUI()
    {
        GUIScale.SetGuiMatrix();
        // Make a background box

        /*
         * switch (GUIScale.aspect_ratio)
         * {
         * case ASPECT_RATIO.SIXTEENTONINE:
         *
         */
        GUI.skin.label.fontSize  = 36;
        GUI.skin.button.fontSize = 48;
        GUI.skin.box.fontSize    = 64;
        GUI.Box(new Rect(GUIScale.virtualWidth * .10f, GUIScale.virtualHeight * .10f, GUIScale.virtualWidth * .80f, GUIScale.virtualHeight * .62f), "Welcome to Toy Chest: Fireworks");

        // Make the first button. If it is pressed, Application.Loadlevel (1) will be executed
        if (GUI.Button(new Rect(GUIScale.virtualWidth * .20f, GUIScale.virtualHeight * .30f, GUIScale.virtualWidth * .60f, GUIScale.virtualHeight * .10f), "Start"))
        {
            Application.LoadLevel(3);
        }

        // Make the second button.
        if (GUI.Button(new Rect(GUIScale.virtualWidth * .20f, GUIScale.virtualHeight * .45f, GUIScale.virtualWidth * .60f, GUIScale.virtualHeight * .10f), "Options"))
        {
            Application.LoadLevel(2);
        }

        if (GUI.Button(new Rect(GUIScale.virtualWidth * .20f, GUIScale.virtualHeight * .60f, GUIScale.virtualWidth * .60f, GUIScale.virtualHeight * .10f), "Exit"))
        {
            Application.Quit();
        }

        /*
         *      break;
         * }
         */
    }
Пример #8
0
    void OnGUI()
    {
        GUIScale.SetGuiMatrix();
        GUI.skin.label.fontSize  = 36;
        GUI.skin.button.fontSize = 48;
        GUI.skin.box.fontSize    = 64;

        if (Gameoptions.TypeGame == 0)
        {
            _typeText = "Gametype: Free Play";
        }
        else if (Gameoptions.TypeGame == 1)
        {
            _typeText = "Gametype: Colors";
        }
        else if (Gameoptions.TypeGame == 2)
        {
            _typeText = "Gametype: Cinema";
        }
        else if (Gameoptions.TypeGame == 3)
        {
            _typeText = "Gametype: Count";
        }

        if (Gameoptions.Repeat == 0)
        {
            _repeatText = "Repeat: Off";
        }
        else
        {
            _repeatText = "Repeat: On";
        }

        _colorsText = "Number Colors: " + Gameoptions.NumColors.ToString();

        if (Gameoptions.ParentalLock == 0)
        {
            _lockText = "Parent Lock: Off";
        }
        else
        {
            _lockText = "Parent Lock: On";
        }

        _detailText = "Detail: " + Gameoptions.FireworkDetail.ToString();


        GUI.Box(new Rect(GUIScale.virtualWidth * .03f, GUIScale.virtualHeight * .10f, GUIScale.virtualWidth * .94f, GUIScale.virtualHeight * .85f), "Game Options");



        if (GUI.Button(new Rect(GUIScale.virtualWidth * .08f, GUIScale.virtualHeight * .20f, GUIScale.virtualWidth * .37f, GUIScale.virtualHeight * .10f), "Test"))
        {
            testAudioClip = Microphone.Start(null, false, 4, 44100);
        }

        if (GUI.Button(new Rect(GUIScale.virtualWidth * .55f, GUIScale.virtualHeight * .20f, GUIScale.virtualWidth * .37f, GUIScale.virtualHeight * .10f), "Save"))
        {
            SavWav.Save("myfile", testAudioClip);
        }


        if (GUI.Button(new Rect(GUIScale.virtualWidth * .08f, GUIScale.virtualHeight * .40f, GUIScale.virtualWidth * .37f, GUIScale.virtualHeight * .10f), "Play"))
        {
            this.audio.clip = testAudioClip;
            audio.Play();
        }

        if (GUI.Button(new Rect(GUIScale.virtualWidth * .55f, GUIScale.virtualHeight * .40f, GUIScale.virtualWidth * .37f, GUIScale.virtualHeight * .10f), _lockText))
        {
            Gameoptions.IncrementParentalLock();
        }

        if (GUI.Button(new Rect(GUIScale.virtualWidth * .55f, GUIScale.virtualHeight * .60f, GUIScale.virtualWidth * .37f, GUIScale.virtualHeight * .10f), _detailText))
        {
            Gameoptions.IncrementFireworkDetail();
        }


        if (GUI.Button(new Rect(GUIScale.virtualWidth * .20f, GUIScale.virtualHeight * .80f, GUIScale.virtualWidth * .60f, GUIScale.virtualHeight * .10f), "Back"))
        {
            Gameoptions.SaveOptions();
            Application.LoadLevel(0);
        }

        //GUI.Label(new Rect(5, 5, 100, 100), ChildLock.isEnabled().ToString());
    }
Пример #9
0
    void OnGUI()
    {
        GUIScale.SetGuiMatrix();
        GUI.skin.label.fontSize  = 72;
        GUI.skin.button.fontSize = 48;
        GUI.skin.box.fontSize    = 36;


        if (Gameoptions.TypeGame == 1)
        {
            for (int i = 0; i < Gameoptions.NumColors; i++)
            {
                if (_gameState != EDU_GAMESTATES.WAIT)
                {
                    GUI.enabled = false;
                }
                if (GUI.Button(new Rect((GUIScale.virtualWidth / Gameoptions.NumColors) * i,
                                        GUIScale.virtualHeight * 0.85f,
                                        (GUIScale.virtualWidth / Gameoptions.NumColors),
                                        GUIScale.virtualHeight * 0.15f),
                               GetColorString(i)) && _gameState == EDU_GAMESTATES.WAIT)
                {
                    if (_color == i)
                    {
                        _gameState      = EDU_GAMESTATES.CORRECT;
                        _gameStateTimer = 0;
                        _stateStart     = true;
                    }
                    else
                    {
                        _gameState      = EDU_GAMESTATES.INCORRECT;
                        _gameStateTimer = 0;
                        _stateStart     = true;
                    }
                }
            }

            GUI.enabled = true;

            if (_gameState == EDU_GAMESTATES.PROMPT)
            {
                GUI.skin.box.fontSize = 72;
                GUI.Box(new Rect(GUIScale.virtualWidth * 0.2f, GUIScale.virtualHeight * 0.3f, GUIScale.virtualWidth * 0.6f, 86), "Guess the Color!");
            }
            else if (_gameState == EDU_GAMESTATES.CORRECT)
            {
                GUI.skin.box.fontSize = 72;
                GUI.Box(new Rect(GUIScale.virtualWidth * 0.2f, GUIScale.virtualHeight * 0.3f, GUIScale.virtualWidth * 0.6f, 86), "Thats Right!");
            }
            else if (_gameState == EDU_GAMESTATES.INCORRECT)
            {
                GUI.skin.box.fontSize = 72;
                GUI.Box(new Rect(GUIScale.virtualWidth * 0.2f, GUIScale.virtualHeight * 0.3f, GUIScale.virtualWidth * 0.6f, 86), "Not Quite! Guess again!");
            }
        }

        if (Gameoptions.TypeGame == 3)
        {
            for (int i = 0; i < _countList.Length; i++)
            {
                if (_gameState != EDU_GAMESTATES.WAIT)
                {
                    GUI.enabled = false;
                }
                if (GUI.Button(new Rect((GUIScale.virtualWidth / _countList.Length) * i,
                                        GUIScale.virtualHeight * 0.85f,
                                        (GUIScale.virtualWidth / _countList.Length),
                                        GUIScale.virtualHeight * 0.15f),
                               GetArrayString(i)) && _gameState == EDU_GAMESTATES.WAIT)
                {
                    if (_countList[i] == countTarget)
                    {
                        _gameState      = EDU_GAMESTATES.CORRECT;
                        _gameStateTimer = 0;
                        _stateStart     = true;
                    }
                    else
                    {
                        _gameState      = EDU_GAMESTATES.INCORRECT;
                        _gameStateTimer = 0;
                        _stateStart     = true;
                    }
                }
            }

            GUI.enabled = true;

            if (_gameState == EDU_GAMESTATES.PROMPT)
            {
                GUI.skin.box.fontSize = 72;
                GUI.Box(new Rect(GUIScale.virtualWidth * 0.2f, GUIScale.virtualHeight * 0.3f, GUIScale.virtualWidth * 0.6f, 86), "Count the Fireworks!");
            }
            else if (_gameState == EDU_GAMESTATES.CORRECT)
            {
                GUI.skin.box.fontSize = 72;
                GUI.Box(new Rect(GUIScale.virtualWidth * 0.2f, GUIScale.virtualHeight * 0.3f, GUIScale.virtualWidth * 0.6f, 86), "Thats Right!");
            }
            else if (_gameState == EDU_GAMESTATES.INCORRECT)
            {
                GUI.skin.box.fontSize = 72;
                GUI.Box(new Rect(GUIScale.virtualWidth * 0.2f, GUIScale.virtualHeight * 0.3f, GUIScale.virtualWidth * 0.6f, 86), "Not Quite!");
            }
        }
    }