Playmaker Forum
PlayMaker Help & Tips => PlayMaker Help => Topic started by: artician on February 27, 2014, 06:06:04 AM
-
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.
(http://www.creathcarter.com/site_media/unity/stacking.jpg)
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!
-
Hi,
good. I'll add this to the next bunch of work so that it's in the package. Thanks for looking this up.
https://trello.com/c/ZolaMrzc/47-ngui
bye,
Jean
-
Hi,
ok, grid is now supported as well as table, so the action remains as is to work with.
New packages to download on the wiki page as usual.
bye,
Jean
-
Where do I find this action? Searching NGUI on the ecosystem yields no results.
-
I do not know why this script isn't on the ecosystem, but there are many custom actions that pre-date the ecosystem that you can find on the wiki. In this particular case I think what you're looking for is here:
https://hutonggames.fogbugz.com/default.asp?W1111
-
Thanks!!!
-
Hi,
It's simply that since I created the Ecosystem, I never had time to put all the custom actions in yet :)
I am working atm on new features within the Ecosystem that will make custom actions dedicated to non PlayMaker assets a lot easier to get, so soon you'll be able to type ngui, and find actions, but it goes further, I'll detect that you have ngui and will include the ngui related actions within the scope of search, so searching for "Add child" will return matching ngui related actions if ngui is installed on your project!
Bye,
Jean