Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
known_issues [09-06-2016 11:30]
46.145.29.233 created
known_issues [19-07-2017 11:20] (current)
185.48.102.186 [How do I create additional screen / screen state / scene?]
Line 1: Line 1:
-**Windows 10 driver** +==== How do I make a replay button? Custom switch of scenes? ==== 
-In Windows 10 there is a very high chance ​of game crashing upon exitif this happens just disconnect ​and re-connect ​the receiver+The simplest way to make a custom scene change ​is by opening ​state prefab. In //​PilloTemplate/​Prefabs/​States//​ you have the prefabs ​of all screen states. So you create a public variable of type //​PT_ScreenState//​ in your class where you want the functionality to happendthen drag and drop your wanted screen state from prefabs and force open it. Code below shows you the implementation. 
-A temporary work-around: switch off every connected pillo manually ​before ​closing the application.+ 
 +<​code>​ 
 + 
 +public PT_ScreenState screen_state_to_open;​ 
 + 
 +void OpenPrefabScreenState() 
 +    { 
 +        //-- force open dragged prefab screen state --// 
 +         
 +        screen_state_to_open.Open(true);​ 
 +    }   
 + 
 +</​code>​ 
 + 
 +==== How do I create additional screen / screen state / scene? ==== 
 +We are going to create a screen for level selection after you press play in main menu, new scene for second level and screen state prefab for it. 
 + 
 +Go to //​MainUIScene//,​ on the scene find //​MainUI/​MainUI//​ object, now you can create the screen from scratch using base button prefab (//​PilloTemplate/​Prefabs/​UI/​BaseButton//​) and //​PT_Screen//​ script, but easier way is just to copy one of the screens we have
 + 
 +Let's copy screen //​MainUI/​MainUI/​Screen_Main//,​ rename it to //​Screen_LevelSelection//,​ delete //​Bt_Highscores,​Bt_Quit//​ and //​Bt_Options//​. Rename //Bt_Play & Bt_Tutorial//​ to //"​Bt_level_1"//​ and //"​Bt_level_2"//,​ change the buttons text accordingly. Next add a back button prefab (//​PilloTemplate/​Prefabs/​UI/​Bt_Back//​) so we have a back option if we want to return to main menu. 
 + 
 +The first level button is already sending us to //​GameScene//,​ so let's create a new scene for second level, as well as, new state prefab for it. 
 + 
 +Got to your scenes folder and create a new scene, name it, I named it //​GameScene_2//​ (also add this scene to your build settings). 
 + 
 +Open //​MainUIScene//,​ find your //States// object, copy //​State_Game//​ and rename it to //​State_Game_2//​. In //​OpenSceneName//​ write how you named your second scene, in my case //​GameScene_2//​. Drag and drop your newly created state, into states prefabs trajectory in //​PilloTemplate/​Prefabs/​States//​ folder. 
 + 
 +Now you can drag your new state into //​Bt_level_2//​ object, so button click will send you to second scene. Drag and drop your //​States/​State_Game_2//​ into //​Bt_level_2/​PT_Screen_Bt_State(script)/​State(variable)//​. 
 + 
 +Next, let's change so our Play button in main menu sends us to elvel selection screen. Go to //​Screen_Main/​Panel/​Bt_Play//​ remove //​PT_Screen_BtState//​ script from button and add //​PT_Screen_Bt_GoTo//​ script in place of it. Drag your //​Screen_LevelSelection//​ screen into //​TargetScreen//​ variable of added script. Last thing you need to do here is add //OnClick// event to the //​Bt_Play//,​ click on you button object, fint //​OnClick()//​ , drag or find the //Bt_Play// object into object category of //​OnClick()//​ event, lastly select funtion to execute ​//​PT_ScreenBt_GoTo.ButtonInteract()//​. 
 + 
 +Now open your //​GameScene_2//,​ drag and drop //​UILoader//​ and //​ManagerSetup//​ prefabs into your scene (//​PilloTemplate/​Prefabs//​),​ click on //​UILoader//​ and drag your //​State_Game_2//​ prefab into //​FirstState//​ variable of //​UILoader//​. 
 + 
 +All done, play your //​MainMenuScene//​and browse through levels. 
 + 
 +==== Main menu buttons or screen states are buggy when browsing in play mode of Unity? ==== 
 +There can be an issue when executing play mode of //​GameScenes// ​before ​//​MainMenuScene//,​ but everything should work after you build your project