Esempio n. 1
0
    void Start()
    {
        // create a vertical layout to house our buttons
        var vBox = new UIVerticalLayout(10);

        vBox.edgeInsets = new UIEdgeInsets(10, 5, 10, 0);

        // create some buttons to control the positioning. we will add text to them se create the UIText we will use as well
        var text = new UIText(textToolkit, "prototype", "prototype.png");

        var positions = new string[] { "top", "top-left", "top-right", "bottom", "bottom-left", "bottom-right" };

        foreach (var pos in positions)
        {
            // create the button
            var touchable = UIButton.create("emptyUp.png", "emptyDown.png", 0, 0);
            touchable.userData         = pos;
            touchable.onTouchUpInside += onButtonTouched;

            // add the text
            var helloText = text.addTextInstance(pos, 0, 0, 0.5f, -1, Color.white, UITextAlignMode.Center, UITextVerticalAlignMode.Middle);
            helloText.parentUIObject = touchable;
            helloText.positionCenter();

            vBox.addChild(touchable);
        }


        // Scores button. we will use this to demo positioning
        _scoresButton = UIContinuousButton.create(buttonToolkit, "scoresUp.png", "scoresDown.png", 0, 0);
        _scoresButton.positionCenter();
    }
Esempio n. 2
0
    void Start()
    {
        // IMPORTANT: depth is 1 on top higher numbers on the bottom.  This means the lower the number is the closer it gets to the camera.
        var playButton = UIButton.create("playUp.png", "playDown.png", 0, 0);


        // Scores button
        var scores = UIContinuousButton.create("scoresUp.png", "scoresDown.png", 0, 0);


        // Options button
        var optionsButton = UIZoomButton.create("optionsUp.png", "optionsDown.png", 0, 0);

        optionsButton.animationDuration    = 0.2f;
        optionsButton.animationTargetScale = new Vector3(1.4f, 1.4f, 1.4f);


        // Vertical panel
        var vPanel = UIVerticalPanel.create("vertPanelTop.png", "vertPanelMiddle.png", "vertPanelBottom.png");

        vPanel.beginUpdates();
        vPanel.spacing    = 20;
        vPanel.edgeInsets = new UIEdgeInsets(30, 10, 20, 10);
        vPanel.addChild(playButton, scores, optionsButton);
        vPanel.endUpdates();

        vPanel.positionCenter();
    }
Esempio n. 3
0
    void Start()
    {
        // IMPORTANT: depth is 1 on top higher numbers on the bottom.  This means the lower the number is the closer it gets to the camera.
        var playButton = UIButton.create("playUp.png", "playDown.png", 0, 0);

        playButton.highlightedTouchOffsets = new UIEdgeOffsets(30);


        // Scores button
        var scores = UIContinuousButton.create("scoresUp.png", "scoresDown.png", 0, 0);

        scores.highlightedTouchOffsets = new UIEdgeOffsets(30);
        scores.touchDownSound          = scoresSound;


        // Options button
        var optionsButton = UIButton.create("optionsUp.png", "optionsDown.png", 0, 0);

        optionsButton.touchDownSound = optionsSound;


        // Knob
        var knob = UIKnob.create("knobUp.png", "knobDown.png", 0, 0);

        knob.highlightedTouchOffsets = new UIEdgeOffsets(30);
        knob.value = 0.3f;


        // Toggle Button
        var toggleButton = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);

        toggleButton.selected = true;


        // HorizontalLayout
        var hBox = new UIHorizontalLayout(20);

        hBox.addChild(playButton, scores, optionsButton);


        // VerticalLayout
        var vBox = new UIVerticalLayout(20);

        vBox.addChild(knob, toggleButton);
        vBox.matchSizeToContentSize();
        vBox.positionFromTopRight(0, 0);


        // Layouts can be animated like any UIObject
        StartCoroutine(animatePanel(hBox));
    }
Esempio n. 4
0
 void Start()
 {
     joystick = UIJoystick.create("button_control.png", joystickTouchFrame, 120, -280);
     joystick.position = new Vector3(joystick.position.x, joystick.position.y, 10);
     joystick.maxJoystickMovement = 60;
  
     int x, y;
  
     x = Screen.width - 180;
     y = Screen.height - 180;
     missileButton = UIContinuousButton.create("button_missile.png", "button_missile.png", x, y);
     missileButton.normalTouchOffsets = new UIEdgeOffsets(20, 20, 5, 20);
     missileButton.highlightedTouchOffsets = new UIEdgeOffsets(20, 20, 5, 20);
     missileButton.onTouchIsDown += MissileButtonIsDown;
 }
Esempio n. 5
0
    void Start()
    {
        // Scores button
        var scores = UIContinuousButton.create(buttonToolkit, "scoresUp.png", "scoresDown.png", 0, 0);

        scores.positionFromBottomRight(.02f, .02f);
        scores.highlightedTouchOffsets = new UIEdgeOffsets(30);


        // Options button
        var optionsButton = UIButton.create(buttonToolkit, "optionsUp.png", "optionsDown.png", 0, 0);

        optionsButton.positionFromBottomRight(.2f, .02f);


        // Text
        // setup our text instance which will parse our .fnt file and allow us to
        var text = new UIText(textToolkit, "prototype", "prototype.png");

        var helloText = text.addTextInstance("hello man.  I have a line\nbreak", 0, 0);

        helloText.positionFromTopLeft(0.1f, 0.05f);
    }
Esempio n. 6
0
    void Start()
    {
        // Scores button
        var scores = UIContinuousButton.create(buttonToolkit, "scoresUp.png", "scoresDown.png", 0, 0);

        scores.positionFromBottomRight(.02f, .02f);
        scores.highlightedTouchOffsets = new UIEdgeOffsets(30);


        // Options button
        var optionsButton = UIButton.create(buttonToolkit, "optionsUp.png", "optionsDown.png", 0, 0);

        optionsButton.positionFromBottomRight(.2f, .02f);


        // Text
        // setup our text instance which will parse our .fnt file and allow us to
        var text = new UIText(textToolkit, "prototype", "prototype.png");

        var x = UIRelative.xPercentFrom(UIxAnchor.Left, .05f);
        var y = UIRelative.yPercentFrom(UIyAnchor.Top, .1f);

        text.addTextInstance("hello man.  I have a line\nbreak", x, y);
    }
Esempio n. 7
0
    void Start()
    {
        // IMPORTANT: depth is 1 on top higher numbers on the bottom.  This means the lower the number is the closer it gets to the camera.
        var playButton = UIButton.create("playUp.png", "playDown.png", 0, 0);

        playButton.positionFromTopLeft(0.05f, 0f);
        playButton.highlightedTouchOffsets = new UIEdgeOffsets(30);
        playButton.onTouchUpInside        += (sender) => Debug.Log("clicked the button: " + sender);

#if UNITY_EDITOR || UNITY_STANDALONE_OSX || UNITY_STANDALONE_WIN || UNITY_WEBPLAYER
        // hover state example for illustration purposes. the playButton will get the scoresDown image when hovered over
        playButton.hoveredUVframe = UI.firstToolkit.uvRectForFilename("scoresDown.png");
#endif

        // Scores button
        var scores = UIContinuousButton.create("scoresUp.png", "scoresDown.png", 0, 0);
        scores.positionFromTopLeft(.24f, .02f);
        scores.centerize();         // centerize the button so we can scale it from the center
        scores.highlightedTouchOffsets      = new UIEdgeOffsets(30);
        scores.onTouchUpInside             += onTouchUpInsideScoresButton;
        scores.onTouchIsDown               += (sender) => Debug.Log("touch is down: " + Time.time);
        scores.touchDownSound               = scoresSound;
        scores.autoRefreshPositionOnScaling = false;


        // Options button
        var optionsButton = UIButton.create("optionsUp.png", "optionsDown.png", 0, 0);
        optionsButton.positionFromTopLeft(.43f, .02f);
        optionsButton.onTouchUpInside += onTouchUpInsideOptionsButton;
        optionsButton.touchDownSound   = optionsSound;


        // Knob
        var knob = UIKnob.create("knobUp.png", "knobDown.png", 0, 0);
        knob.positionFromTopLeft(.39f, .5f);
        knob.normalTouchOffsets      = new UIEdgeOffsets(10);      // give the knob a bit extra touch area
        knob.highlightedTouchOffsets = new UIEdgeOffsets(30);
        knob.onKnobChanged          += onKnobChanged;
        knob.value = 0.3f;


        // Horizontal Slider
        var hSlider = UISlider.create("sliderKnob.png", "hSlider.png", 0, 0, UISliderLayout.Horizontal);
        hSlider.positionFromTopLeft(.7f, .02f);
        hSlider.highlightedTouchOffsets = new UIEdgeOffsets(30, 20, 30, 20);
        hSlider.onChange += (sender, val) => Debug.Log(val);
        hSlider.value     = 0.6f;


        // Vertical Slider
        var vSlider = UISlider.create("vSliderKnob.png", "vSlider.png", 0, 0, UISliderLayout.Vertical);
        vSlider.positionFromTopRight(.17f, .05f);
        vSlider.highlightedTouchOffsets = new UIEdgeOffsets(20, 30, 20, 30);
        vSlider.continuous = true;
        vSlider.onChange  += (sender, val) => Debug.Log(val);
        vSlider.value      = 0.3f;


        // Toggle Button
        var toggleButton = UIToggleButton.create("cbUnchecked.png", "cbChecked.png", "cbDown.png", 0, 0);
        toggleButton.positionFromTopRight(.3f, .2f);
        toggleButton.onToggle += (sender, newValue) => hSlider.hidden = !newValue;
        toggleButton.selected  = true;


        // Progress/Health bar
        var progressBar = UIProgressBar.create("progressBar.png", 0, 0);
        progressBar.positionFromBottomLeft(.05f, .02f);
        progressBar.resizeTextureOnChange = true;
        progressBar.value = 0.4f;


        // animated sprite
        var animatedSprite = UI.firstToolkit.addSprite("Gai_1.png", 0, 0, 1);
        var anim           = animatedSprite.addSpriteAnimation("anim", 0.15f, "Gai_1.png", "Gai_2.png", "Gai_3.png", "Gai_4.png", "Gai_5.png", "Gai_6.png", "Gai_7.png", "Gai_8.png", "Gai_9.png", "Gai_10.png", "Gai_11.png", "Gai_12.png");
        animatedSprite.positionFromBottomRight(.0f, .25f);
        anim.loopReverse = true;         // optinally loop in reverse
        animatedSprite.playSpriteAnimation("anim", 5);


        // Test movement
        StartCoroutine(marqueePlayButton(playButton));
        StartCoroutine(animateProgressBar(progressBar));
        StartCoroutine(pulseOptionButton(optionsButton));


        // UIObjects can be used like panels to group other UIObjects
        var panel = new UIObject();
        scores.parentUIObject        = panel;
        optionsButton.parentUIObject = panel;

        StartCoroutine(animatePanel(panel));
    }
Esempio n. 8
0
    void Start()
    {
        text        = new UIText(textToolkit, "GhoulishFont", "GhoulishFont_0.png");
        startScript = FindObjectOfType(typeof(StartScript)) as StartScript;
        loader      = FindObjectOfType(typeof(loadingScript)) as loadingScript;
        character   = FindObjectOfType(typeof(CharacterMaster)) as CharacterMaster;
        //DontDestroyOnLoad(this.gameObject);



        AmmoText     = text.addTextInstance("Bullets: " + startScript.Ammunition.ToString(), 0, 0, textScaleFactor, 2, Color.white, UITextAlignMode.Left, UITextVerticalAlignMode.Middle);
        PickupAmount = text.addTextInstance("+20", 0, 0, textScaleFactor * 5, 2, Color.white, UITextAlignMode.Left, UITextVerticalAlignMode.Middle);
        PickupAmount.alphaTo(0.1f, 0, Easing.Quartic.easeIn);
        PickupAmount.hidden = true;

        LevelInstruc = text.addTextInstance("" + LvlInstructions, 0, 0, textScaleFactor, 2, Color.white, UITextAlignMode.Center, UITextVerticalAlignMode.Middle);
        LevelInstruc.positionCenter();
        LevelInstruc.alphaTo(0.01f, 0, Easing.Quartic.easeIn);

        StartCoroutine(StartLvlInstruction());
        // buttons ------------------------------------


        PauseBtn = UIButton.create(buttonUI, "PauseBtn.png", "PauseBtn.png", 0, 0, 10);
        PauseBtn.positionFromTopLeft(0.035f, 0.045f);
        PauseBtn.onTouchUpInside += onTouchPauseBtn;
        PauseBtn.touchDownSound   = buttonSound;
        PauseBtn.hidden           = false;

        PlayBtn = UIButton.create(buttonUI, "PlayBtn.png", "PlayBtn.png", 0, 0, 10);
        PlayBtn.positionFromCenter(0.2f, -0.21f);
        PlayBtn.onTouchUpInside += onTouchPlayBtn;
        PlayBtn.touchDownSound   = buttonSound;
        PlayBtn.hidden           = true;

        RetryBtn = UIButton.create(buttonUI, "RetryBtn.png", "RetryBtn.png", 0, 0, 10);
        RetryBtn.positionFromCenter(0.2f, -0.07f);
        RetryBtn.onTouchUpInside += onTouchRetryBtn;
        RetryBtn.touchDownSound   = buttonSound;
        RetryBtn.hidden           = true;

        QuitBtn = UIButton.create(buttonUI, "QuitBtn.png", "QuitBtn.png", 0, 0, 10);
        QuitBtn.positionFromCenter(0.2f, 0.07f);
        QuitBtn.onTouchUpInside += onTouchQuitBtn;
        QuitBtn.touchDownSound   = buttonSound;
        QuitBtn.hidden           = true;

        //------TOGGLE BTNS-------------------------------


        AudioBtn = UIToggleButton.create(buttonUI, "AudioOffBtn.png", "AudioBtn.png", "AudioOffBtn.png", 0, 0, 10);
        AudioBtn.positionFromCenter(0.2f, 0.21f);
        AudioBtn.onToggle += onTouchAudioBtn;
        AudioBtn.hidden    = true;
        if (PlayerPrefs.GetInt("volume") == 1)
        {
            AudioBtn.selected = true;
        }

        //-------------------HEALTH METER--------------------------------------


        HealthBG = buttonUI.addSprite("HealthBG.png", 0, 0, 10);
        HealthBG.positionFromCenter(-0.41f, 0.0f);


        HealthBar = UIProgressBar.create(buttonUI, "HealthBar.png", 0, 0, false, 5, false);
        Vector2 tempVec;

        tempVec            = new Vector2(HealthBG.position.x + 95, HealthBG.position.y - 10);
        HealthBar.position = tempVec;

        HealthBar.value = 1;


        //----------------------PICKUPS-------------------------



        HealthPickup = buttonUI.addSprite("HeartPickup.png", 0, 0, 10);
        HealthPickup.positionFromCenter(-0.0f, 0.0f);
        HealthPickup.alphaTo(0.1f, 0, Easing.Quartic.easeIn);
        HealthPickup.hidden = true;

        AmmoPickup = buttonUI.addSprite("AmmoPickup.png", 0, 0, 10);
        AmmoPickup.positionFromCenter(-0.0f, 0.0f);
        AmmoPickup.alphaTo(0.1f, 0, Easing.Quartic.easeIn);
        AmmoPickup.hidden = true;


        //-----------------------------CONTROLS------------------------------------------


        LToggle          = UIJoystick.create(buttonUI, "LToggle.png", new Rect(Screen.width * 0.01f, Screen.height * 0.45f, Screen.width * 0.4f, Screen.height * 0.6f), Screen.width * 0.175f, Screen.height * -0.3f);
        LToggle.deadZone = new Vector2(0.8f, 0.8f);
        //LToggle.setJoystickHighlightedFilename( "LToggleT.png" );
        AttackBtn = UIContinuousButton.create("AttackBtn.png", "AttackBtn.png", 0, 0);
        AttackBtn.positionFromBottomRight(0.05f, 0.05f);
        AttackBtn.centerize();         // centerize the button so we can scale it from the center
        AttackBtn.highlightedTouchOffsets = new UIEdgeOffsets(30);
        AttackBtn.onTouchIsDown          += onTouchAttackBtn;
        AttackBtn.onTouchUpInside        += onTouchAttackBtnUp;



        if (loader != null)
        {
            if (loader.ControllerCount > 0)
            {
                LToggle.hidden   = true;
                AttackBtn.hidden = true;
            }
        }
    }