playMaker

Author Topic: UGUI and perfabs  (Read 3032 times)

smdxxx

  • Playmaker Newbie
  • *
  • Posts: 2
UGUI and perfabs
« on: December 21, 2015, 05:07:28 AM »
Hello,

I cant believe it but it is true until this point I have learned everything I know from reading these forums. everything from programming to animation. So thank you all, after about 2 years and it is time for my first question.

I was following the tutorial I made it to part 2 about half way in and noticed some funny results as the host is using C# and I am using playmaker. I think I might have made it from noob to beginner but i am stumped.

I have a basic scene

Canvass with an image and a panel parented to the canvass

 set the panel's rect transform to cover the bottom quarter of the canvass size the image to be slightly shorter than the panel

   say
         panel
          height 110

         image
         height 100
         width 75

 add an fsm to the image with 4 states and add the global events, I name the states the same as the events

   UGUI
      on begin drag
      on drag
      on end drag

In the on drag state add the two actions get mouse position ( custom action in ecosystem ) and set position. 

   Set bools in get mouse position every frame and from screen center true
   set every frame true in set position action    

   add a Vector 3 variable "mouse pos"

   add the variable in the actions in the Vector 3 drop down in both actions

Add component to panel Horizontal Layout Group
   Set bools on component to false  -  width and height

add component to Image

   Playmaker Ugui Drag Event
   Layout element
      set bools preferred with and height true and the values the same as the width and height in the rect transform
      set bools flexible with and height true and the values to 0

when you press play button and let the scene run the image will react as the player clicks the image and drags it around the image will follow the mouse. A normal desired set up.

however if I parent the image to the panel I do not receive the same results. the fsm is firing appropriately but the image will not move during play mode.
         
      
*********my question is why is the behavior different when the image is parented to the panel.
I guess i don't understand why the Image is not responding to the players input if the Image is parented to another component under the canvas.

or is the layout group components giving me the undesired results?

Or did i miss something completely?

In the video when he sets the images as a child of the panel runs play mode the image is still interactive while still a child of the panel.


This must have been answered before but i cant seem to find reference on ugui objects in the forums or does it not matter what kind of game object is a prefab ( UI, 3d, Light, ect.)

if I make the Image a prefab and remove the image from the scene.
then place the Image(prefab) as a child of the panel the action set parent on the prefab of the image i cannot add scene objects to the action set parent just prefabs.

I have found a way to make it work where I set the parent back to the canvas in the on begin drag state without using prefabs but why do you have to change the parent to make the player interact with the image.

I might want to have the image a child of the panel until the fsm hits the on drag end state. but i am not having any success with this.


i didnt know if there was a way to use a mouse pick and allow the image to be selected and still be a child of the panel?



now you can probably tell i defiantly want the image to be a prefab and not a scene object.


if i want to set the image to be a child of the canvass I would have to make the canvass a prefab and I didn't know if I was going in the right direction with this or will making the canvass a prefab make further complications later on that are unforeseen with my level of experience?

or should I make an empty game object and say it acted as a host to the canvass.
 make the empty game object a prefab and make the panel prefab and a child of the empty game object (host) so I do not have to make the canvass a prefab?
      
I would assume it might be bad to prefab the canvass because of the event system referencing it in the hierarchy and vice versa.

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: UGUI and perfabs
« Reply #1 on: December 21, 2015, 06:40:13 AM »
Hi,

Your initial words are very nice, Indeed I also think that forums and similar information sources are critical for learning new software these days, unless unlimited budget is allocated to documentation...

 Before I try to replicate this, have you checked the drag and drop examples on the Ecosystem?



 I don't see any reason for a child of UI element not respond to drag and drop, UNLESS :

-- one of it's parent has "Interactable" disabled
-- RayCast blocked.
-- you are not repsonding to drag and drop calls quite simply.

 so double check thiese points first.

 Bye,

 Jean

smdxxx

  • Playmaker Newbie
  • *
  • Posts: 2
Re: UGUI and perfabs
« Reply #2 on: December 21, 2015, 10:40:51 PM »
Ok jean

I am going to go thru the steps you have provided me.

I have done the examples and have been able to recreate what you have done on my own. However this is my first time implicating what i had learned in the examples. I have been able to understand it because of the notes in the system.

 I possibly have put something where it doesent belong. And i should google raycasting before i go further. Thank you

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: UGUI and perfabs
« Reply #3 on: January 13, 2016, 02:21:01 AM »
Hi,

 I don't think it will help to google for raycasting.

 the problem you are likely facing is that the parent panl is blocking raycast, make sure this is not that problem.

 in the uGuiDragAndDrop, I do have draggable panel as childs of panels and it works.

Study how I work with panels using PlayMaker uGui CanvasRacast component, it could be the missing trick for you.

Bye

 Jean

GayanJayasund

  • Playmaker Newbie
  • *
  • Posts: 3
Re: UGUI and perfabs
« Reply #4 on: March 18, 2017, 12:46:26 AM »
Hi.........

I add 3 Drag Panel and 3 Drop Panel in my scene. I want to set "Drag Panel 1" Match only "Drop Panel 1" it Drag and Drop Action.When User Drop "Drag Panel 1" on the Drop Panel 2 or 3 it come its Start position.

Thanks

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: UGUI and perfabs
« Reply #5 on: March 20, 2017, 01:35:34 AM »
Hi,

 When the user starts dragging a given drag panel, you know already which drop target is ok or not, it's the right time to set all drop target data so that react or not to the current drag panel being dragged.

So I would broadcast a global event "ON DRAGGING STARTED" from the drag panel being dragged, all drop targets catched this global event, check who sent it and based on that enable or disable drop reception.

In the drag and drop example provided in the Ecosystem, each drop target have an enabled flag, you need to control this flag using an fsm rather than with a user Interface check box, that's all.

 Bye,

 Jean