Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - soulareus

Pages: [1]
1
      

I am trying to create a dynamic health bar using little dots to show health.  I want to use the LayoutContainerSizer.  I am getting an index out of bounds error.  I couldn't find docs on how to do this so I'm working blind.  Anyone have a hint?
thanks!
-Nic

code follows

Code: [Select]
public class UI : MonoBehaviour {
public tk2dUILayoutContainerSizer healthUIContainerSizer;
// Use this for initialization
void Start () {
AddMaxHealth();
}

// Update is called once per frame
void Update () {

}
    void AddMaxHealth()
{
GameObject go = (GameObject)Instantiate(Resources.Load("UI/HealthBarLength"));
tk2dUILayout layout = go.GetComponentInChildren<tk2dUILayout>();
//layout.layoutItems[0];
//tk2dUILayoutItem item = go.GetComponentInChildren<tk2dUILayoutItem>();
healthUIContainerSizer.AddLayoutAtIndex(layout,layout.layoutItems[0],1);
}
}

2
Support / Trouble Centering items in UILayout Container Sizer.
« on: April 03, 2014, 05:54:38 am »
I think the new UILayout Container Sizer is a great idea!  However I am having trouble figuring out how to do two things:

1) I want to use it to dynamically add objects and remove them and have it collapse properly.
2) I want a horizontally aligned list of objects to center when I add or remove items.

I could not find any script reference for this container sizer, and parenting a UILayout does not seem to center the container sizer.  Could someone please let me know if this is possible?  It has implications for a couple of projects I am working on.

Thanks!
-Nic

Pages: [1]