Created
January 2, 2014 09:04
-
-
Save TAK-EMI/8216635 to your computer and use it in GitHub Desktop.
Unityで、GameObject中心ではなく、スクリプト中心に考えるためのコード。
いちいちPrefab作らなくても済む。
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class LineEdit : MonoBehaviour | |
{ | |
private Rect frame; | |
private string text; | |
static public LineEdit makeLineEdit(string name, Rect frame) | |
{ | |
GameObject go = new GameObject(name); | |
LineEdit le = go.AddComponent<LineEdit>(); | |
le.setText(""); | |
le.setFrame(frame); | |
return le; | |
} | |
public void setFrame(Rect frame) | |
{ | |
this.frame = frame; | |
return; | |
} | |
public void setText(string str) | |
{ | |
this.text = str; | |
return; | |
} | |
void OnGUI() | |
{ | |
this.text = GUI.TextField(this.frame, this.text); | |
return; | |
} | |
void Start() | |
{ | |
return; | |
} | |
void Update() | |
{ | |
return; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment