Can you explain it in a lot of detail. I'm very new to playmaker. Thank you
Hi,
I can sure try. But I will also try to keep it simple, like no arrays or anything, just global event sending may be as complicated as it gets.
So lets get cracking lol:
For the Game Object:Create an FSM on the object.
Create two global events in the FSM (create an event and click the global tick box). Call them : "Activate" and "DeActivate".
Now keep the start state blank, dont put any action in it and just create state 2.
Right click on state 2 and choose 'add global transition', then add the 'Activate' global event that you just created.
In state 2, add this action: 'Send Event', choose 'event target' as 'broadcast all' and be sure to tick the 'exclude self' tick box. Choose 'DeActivate' as the event to send.
Next create state 3. Again right click and add the DeActivate global event so it transitions into state 3.
In state 3: add this action: 'Activate Game Object' and leave 'use owner' for 'gameObejct'. Then add a finish event and link it to the start state (state 1- which should have no actions in it or events transitioning out of it).
For the Button:Create a button (GameObject/Create>UI>Button).
Then go here:
https://hutonggames.fogbugz.com/?W1192 and download the "Package for uGUI Proxy With Full set of Actions" (it is the second link under the first image).
Import the downloaded package into unity and this will give you the actions you need to communicate with Unity UI.
Then set up an FSM on the button:
State 1: Add the action "U Gui Button On Click Event" (it comes in the action pack). And for 'Send event:' create something like "button pressed" and add it to the state and then select it. This event should go to state 2.
State 2: Use the action 'Activate Game Object', select specify game object (instead of use owner) and drag the first object into the 'game object' space. Then untick the 'recursive' box.
Use the send event action and set the 'event target' to "game object". Then again, specify game object and drag the first game object into the space. For 'event' chose to send the 'Activate' event, that you created on the game object earlier.
NOW! If you just add a finish event and link back to the first state, you will have made an on button. (So when you press the button the object is activated, every other game object will be disabled, but if you press it again, the button does not turn the object it turned on, back off) Read on if you want to make a toggle (on/off) button. Now copy and paste state 1, to make state 3.
Then link a finish event from state 2 to state 3.
On state 3, right click, chose 'add event', go down to 'custom events' and add the 'DeActivate' event, that you created earlier on the game object, so that it transitions out of 'state 3' into 'state 1'.
Then copy and paste state 2, to make state 4.
Then connect the 'button pressed' event from state 3 into state 4
In State 4: Delete the 'Send Event' Action. Then on the 'activate game object' action, untick 'activate' (this will disable the game object). Add a finished event and link back to the first state.
and voila! If you managed to get through that, youre done!
Now copy and paste, either the button itself, or just the fsm to all the buttons. Then just drag and drop the correct item into all the item boxes. So that each button corresponds to a specific item. Do that 40 times and youre all set.
Here is a video of it in action and a general walk through around the setup:
(Never mind my blue Ethans running around, I just put this together in a middle of a concept scene I was working on- as a means of taking a break lol- also I was talking to the video, but apparently had sound recording turned off lol, so it is just a silent video
)
Good luck with it and I hope this helps!
(PS: this tutorial also should help understand unity ui in playmaker:
)