This is probably known already but I hit an issue using the NguiToolsAddChild action when using it with a UIGrid element. The action sounds like it should be universal, but it only appears to be applicable to regular Widgets and the UITable.
When using it with UIGrid is causes children placed to display incorrectly.
It seems this is because the UITable function mTable.repositionNow is being used instead of the UIGrid function. I changed the code myself and it worked appropriately, so I'm attaching a variation of the AddChild action here.
// (c) Copyright HutongGames, LLC 2010-2013. All rights reserved.
using UnityEngine;
using AnimationOrTween;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory("NGUI Tools")]
[Tooltip("Add a child to a Ngui Grid.")]
public class NguiToolsAddGridChild : FsmStateAction
{
[RequiredField]
[Tooltip("The Parent")]
public FsmOwnerDefault parent;
[RequiredField]
[Tooltip("The GameObject to add")]
public FsmGameObject childReference;
[UIHint(UIHint.Variable)]
public FsmGameObject childInstance;
public override void Reset()
{
parent = null;
childReference = null;
childInstance = null;
}
public override void OnEnter()
{
GameObject _go = Fsm.GetOwnerDefaultTarget(parent);
childInstance.Value = NGUITools.AddChild(_go,childReference.Value);
UIGrid mGrid = NGUITools.FindInParents<UIGrid>(childInstance.Value);
if (mGrid != null) {
mGrid.repositionNow = true;
}
Finish();
}
}
}
Is there a better location for this?
Code look okay to others?
Thanks!