Playmaker Forum

PlayMaker Help & Tips => PlayMaker Help => Topic started by: artician on February 27, 2014, 06:06:04 AM

Title: NGUI Add Child Issue
Post 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.

Code: [Select]
// (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!
Title: Re: NGUI Add Child Issue
Post by: jeanfabre on March 04, 2014, 06:49:45 AM
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
Title: Re: NGUI Add Child Issue
Post by: jeanfabre on April 11, 2014, 02:02:57 PM
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
Title: Re: NGUI Add Child Issue
Post by: jamdalu on September 09, 2015, 10:26:02 AM
Where do I find this action?  Searching NGUI on the ecosystem yields no results.
Title: Re: NGUI Add Child Issue
Post by: artician on September 09, 2015, 10:32:09 AM
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

Title: Re: NGUI Add Child Issue
Post by: jamdalu on September 09, 2015, 10:36:23 AM
Thanks!!!
Title: Re: NGUI Add Child Issue
Post by: jeanfabre on September 10, 2015, 01:44:49 AM
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