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 https://www.youtube.com/watch?v=bMuYUOIAdnc
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
add an fsm to the image with 4 states and add the global events, I name the states the same as the events
on begin 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
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.