playMaker

Author Topic: NGUI Add Child Issue  (Read 3934 times)

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 296
    • View Profile
NGUI Add Child Issue
« on: February 27, 2014, 04: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.



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!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14059
  • Official Playmaker Support
    • View Profile
Re: NGUI Add Child Issue
« Reply #1 on: March 04, 2014, 04: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

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14059
  • Official Playmaker Support
    • View Profile
Re: NGUI Add Child Issue
« Reply #2 on: April 11, 2014, 11:02:57 AM »
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

jamdalu

  • Playmaker Newbie
  • *
  • Posts: 10
    • View Profile
Re: NGUI Add Child Issue
« Reply #3 on: September 09, 2015, 07:26:02 AM »
Where do I find this action?  Searching NGUI on the ecosystem yields no results.

artician

  • 1.2 Beta
  • Sr. Member
  • *
  • Posts: 296
    • View Profile
Re: NGUI Add Child Issue
« Reply #4 on: September 09, 2015, 07: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


jamdalu

  • Playmaker Newbie
  • *
  • Posts: 10
    • View Profile
Re: NGUI Add Child Issue
« Reply #5 on: September 09, 2015, 07:36:23 AM »
Thanks!!!

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 14059
  • Official Playmaker Support
    • View Profile
Re: NGUI Add Child Issue
« Reply #6 on: September 09, 2015, 10:44:49 PM »
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