Skip to content

Instantly share code, notes, and snippets.

@kyubuns
Created May 5, 2014 13:04
Show Gist options
  • Save kyubuns/81491fa74a075989397a to your computer and use it in GitHub Desktop.
Save kyubuns/81491fa74a075989397a to your computer and use it in GitHub Desktop.
// attached this script to root game object of 'Button Prefab' with UIButton(NGUI).
using UnityEngine;
using System.Collections;
public class ButtonText : MonoBehaviour {
[SerializeField] UILabel label;
public string text
{
set {
label.text = value;
}
get {
return label.text;
}
}
}
// attached this script to 'Button1'/'Button2' game object of 'Window Prefab' with PrefabInPrefab.
using UnityEngine;
using System.Collections;
[ExecuteInEditMode]
public class TestButton : MonoBehaviour {
[SerializeField] string text;
[SerializeField] string message;
void Start()
{
var buttonText = GetComponent<ButtonText>();
if(buttonText != null) GetComponent<ButtonText>().text = text;
}
void OnClick()
{
Debug.Log(message);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment