playMaker

Author Topic: hide/show prefab object  (Read 3551 times)

pakmafia

  • Playmaker Newbie
  • *
  • Posts: 6
hide/show prefab object
« on: September 15, 2014, 07:04:55 AM »
I have a prefab object that i would like to hide/show controlled by 2 gui buttons (show and Hide)
i have tried using actions activate game object and set object visable but no success.
when using activate game object it hides everything including the gui buttons but instead it should give me the gui show button but it doesnot.
set object visable action untick visable not do anything.

Thanks n advance for your help.

pakmafia

  • Playmaker Newbie
  • *
  • Posts: 6
Re: hide/show prefab object
« Reply #1 on: September 15, 2014, 08:21:10 AM »
Just to add.
Did a little experiment using a cube instead and used action set visabilty and it worked but when i change the object to my prefab it gives me error "gameobject requires renderer component {click to add render component} i clicked error goes away but it doesnt work

pakmafia

  • Playmaker Newbie
  • *
  • Posts: 6
Re: hide/show prefab object
« Reply #2 on: September 16, 2014, 12:07:00 AM »
can any one help?

jess84

  • Hero Member
  • *****
  • Posts: 515
Re: hide/show prefab object
« Reply #3 on: September 16, 2014, 12:35:34 AM »
Use a 'Enable Behaviour' action in an FSM on the object you want to make invisible. In the object field, drag the component of your object on to the action. (e.g. Mesh Renderer, or whatever you're trying to hide).  Uncheck the 'enable' checkbox so it's set to disable the component.

On your buttons, when clicked, trigger a Send Event action and set it to Broadcast All. Create an Event (e.g "Hide Object") and click on the left checkbox to make it a global. Set that global event as the event you're sending

On your object you want to make invisible, right click on your action that disables your component and choose Global Transition. Select the one that you created in the step above.

Duplicate the above steps for your other button, but have your Enable Behaviour action 'enable' instead of disable.

So you'll have target object with 1 FSM containing 2 States with a 2 different global transitions going to them. 2 buttons, each with an FSM that detects your click and sends the appropriate event to your object.

pakmafia

  • Playmaker Newbie
  • *
  • Posts: 6
Re: hide/show prefab object
« Reply #4 on: September 16, 2014, 01:39:38 AM »
thanks jess i will try that.