1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
| using System.Collections; using System.Collections.Generic; using UnityEngine;
public class Control : MonoBehaviour { public Obj m_obj; void Start() {
}
void Update() { }
private void OnGUI() { if (GUI.Button(new Rect(0, 0, 100, 100), "m_obj name")) { m_obj.name = "name" + Random.Range(1,1000); } if (GUI.Button(new Rect(100, 0, 100, 100), "m_obj str")) { m_obj.str = "testobj" + Random.Range(1, 1000); } if (GUI.Button(new Rect(200, 0, 100, 100), "m_obj setstr2")) { m_obj.setstr2("testobj" + Random.Range(1, 1000)); } if (GUI.Button(new Rect(0, 100, 100, 100), "m_obj.GetHashCode()")) { Debug.Log(m_obj.GetHashCode()); } }
if (GUI.Button(new Rect(100, 100, 100, 100), "m_obj.name")) { Debug.Log(m_obj.name); } if (GUI.Button(new Rect(200, 100, 100, 100), "m_obj.str")) { Debug.Log(m_obj.str); } if (GUI.Button(new Rect(300, 100, 100, 100), "m_obj.getstr2()")) { Debug.Log(m_obj.getstr2()); }
if (GUI.Button(new Rect(400, 100, 100, 100), "m_obj == null")) { Debug.Log(m_obj== null); }
if (GUI.Button(new Rect(500, 100, 100, 100), "m_obj==true")) { Debug.Log(m_obj==true); }
if (GUI.Button(new Rect(100,200,100,100),"Destroy GameObject")) { Destroy(m_obj.gameObject);
}
if (GUI.Button(new Rect(200, 200, 100, 100), "Destroy Script not m_obj = null")) { Destroy(m_obj); }
if (GUI.Button(new Rect(300, 200, 100, 100), "Destroy Script and m_obj = null")) { Destroy(m_obj); m_obj = null; } } }
|