//Method
public static void AddCheckInButtons(){
for(int i = 0; i < checkInArray.Count; i++){
Debug.Log("--->Start For Loop");
GameObject g = GameObject.Find("CheckIn_Panel");
Debug.Log("--->GameObject");
CheckInButton checkButton = g.AddComponent<CheckInButton>();
Debug.Log("--->CheckIn Button");
checkButton.SetPosition(i);
checkButton.SetCheckInObject(checkInArray[i]);
checkButton.CreateButton();
}
}
//Class
using UnityEngine;
using System.Collections;
public class CheckInButton : MonoBehaviour {
//Properties
string ButtonName {get;set;}
int Position{get;set;}
CheckIn CheckInObject {get;set;}
//Variables
public GameObject uiObject;
float buttonVariance = -45.0f;
void Start(){}
//Creates a button to use with Check In UI
public void CreateButton(){
Debug.Log("--->CreateButton");
GameObject newButton = NGUITools.AddChild(gameObject, uiObject);
Debug.Log("--->GameObject newButton");
UILabel newButtonLabel = newButton.GetComponentInChildren<UILabel>();
Debug.Log("--->UILabel newButtonLabel");
newButtonLabel.text = ButtonName;
newButton
.transform.localPosition = new Vector3
(0
.0f,
((buttonVariance
*Position
)+140
.0f
), 0
.0f
);
}
//Setter for Position
public void SetPosition(int position){
Position = position;
}
//Setter for CheckInObject and ButtonName
public void SetCheckInObject(CheckIn checkIn){
CheckInObject = checkIn;
ButtonName = checkIn.name;
}
}