playMaker

Author Topic: SetParent Canvas Issue (and alternative action)  (Read 694 times)

Thore

  • Sr. Member
  • ****
  • Posts: 260
    • View Profile
SetParent Canvas Issue (and alternative action)
« on: September 22, 2018, 02:14:21 PM »
Hello,

When using "Set Parent" on objects within the canvas, Unity will throw the error notification shown below. It still lets you play, but there are scaling issues.

Code: [Select]
Parent of RectTransform is being set with parent property. Consider using the SetParent method instead, with the worldPositionStays argument set to false. This will retain local orientation and scale rather than world orientation and scale, which can prevent common UI scaling issues.
UnityEngine.Transform:set_parent(Transform)
HutongGames.PlayMaker.Actions.SetParent:OnEnter() (at Assets/PlayMaker/Actions/GameObject/SetParent.cs:38)
HutongGames.PlayMaker.FsmState:ActivateActions(Int32) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:205)
HutongGames.PlayMaker.FsmState:OnEnter() (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/FsmState.cs:175)
HutongGames.PlayMaker.Fsm:EnterState(FsmState) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2767)
HutongGames.PlayMaker.Fsm:SwitchState(FsmState) (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2714)
HutongGames.PlayMaker.Fsm:UpdateStateChanges() (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:2642)
HutongGames.PlayMaker.Fsm:Start() (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/Classes/Fsm.cs:1925)
PlayMakerFSM:Start() (at C:/Projects/Playmaker_1.9.0/Projects/Playmaker.source.unity/Assets/PlayMaker/PlayMakerFSM.cs:548)

Though I have no idea what I am doing, I somehow created an action using the suggested SetParent method which works and doesn't throw errors. I named it SetParent3 (there is already a second one in Ecosystem).

This action will do the (basic) trick, however, it currently has no other parameters (I have no clue how/what). If a regular wants to complete it, and upload it to ecosystem, you're super welcome. It would be best, I guess, when the default "Set Parent" works universally.

Cheers.
 




jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14237
  • Official Playmaker Support
    • View Profile
Re: SetParent Canvas Issue (and alternative action)
« Reply #1 on: October 18, 2018, 01:02:31 AM »
Hi,

 you need to use SetTransformParent for this :)

 Bye,

 Jean

Alatriste

  • Full Member
  • ***
  • Posts: 180
    • View Profile
Re: SetParent Canvas Issue (and alternative action)
« Reply #2 on: December 20, 2018, 06:11:16 AM »
How do you access the Left, Top, Right and Bottom variables?
In my case, the object is being created with wrong values, even when the prefab has the 0,0,0,0 set.  ???

Alatriste

  • Full Member
  • ***
  • Posts: 180
    • View Profile
Re: SetParent Canvas Issue (and alternative action)
« Reply #3 on: December 20, 2018, 06:34:36 AM »
I answer myself: I made it work using the ecosystem action "Set Transform Parent".