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 ); // Layouts can be animated like any UIObject StartCoroutine( animatePanel( hBox ) ); }
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(); }
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(); }
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)); }
// Build Main Menu private void BuildMenu() { var brickum = UIButton.create("brickum.png", "brickum.png", 0, 0); brickum.scale *= menuScale; var buttonCampaign = UIButton.create("button_campaign.png", "button_campaign_down.png", 0, 0); buttonCampaign.scale *= menuScale; buttonCampaign.onTouchUpInside += (sender) => ButtonCampaign(); var buttonFreeplay = UIButton.create("button_freeplay.png", "button_freeplay_down.png", 0, 0); buttonFreeplay.scale *= menuScale; buttonFreeplay.onTouchUpInside += (sender) => ButtonFreePlay(); var buttonKidmode = UIButton.create("button_kidmode.png", "button_kidmode_down.png", 0, 0); buttonKidmode.scale *= menuScale; buttonKidmode.onTouchUpInside += (sender) => ButtonKidMode(); containerMenu = new UIVerticalLayout(5); containerMenu.addChild(brickum, buttonCampaign, buttonFreeplay, buttonKidmode); containerMenu.matchSizeToContentSize(); containerMenu.positionCenter(); tipText = textSmall.addTextInstance("Tip: Tips go here", 0, 0); tipText.text = "Tip: " + gameSetup.GetTip(); tipText.scale *= menuScale; tipText.positionFromBottom(0.03f, 0); // Options Button buttonOptions = UIButton.create("options_up.png", "options_down.png", 0, 0); buttonOptions.scale *= menuScale; buttonOptions.onTouchUpInside += (sender) => ButtonOptions(); buttonOptions.positionFromTopRight(0, 0); buttonOptions.alphaTo(1, 0.3f, Easing.Linear.easeOut); }