public override string ToString() { StringBuilder sb = new StringBuilder(); sb.Append(base.ToString()); sb.AppendFormat("ProtocolVersion : {0}\r\n", ProtocolVersion); sb.AppendFormat("TalktoMe: {0} [{1}]\r\n", TalkToMe, TalkToMe.ToTalkToMeString()); sb.AppendFormat("Priority: {0}\r\n", Priority); return(sb.ToString()); }
Spinner cubeRightGo; //for example two, see Start() void Start () { // this first bit is for the method initialization and call examples int answer = AddTwoNumbers (number1, number2) + AddTwoNumbers (number2, number3) + AddTwoNumbers (number3, number1); //note that int answer's statement is 4 lines long! DisplayResult (answer); //This bit is for the Dot Syntax examples Debug.Log ("for the Dot Syntax example, press the return key"); otherComponent = GetComponent<TalkToMe> (); //assigns the instance of component TalkToMe on this GameObject to otherComponent //This bit of code is for Dot Syntax, talking with other GameObjects //It works in conjunction with the Spinner script Debug.Log ("Use left/right arrow keys to rotate each of the onjects"); cubeLeftGo = GameObject.Find ("Cube Left"); //example one: initialize a GameObject variable. You will have to then GetComponent on this variable cubeRightGo = GameObject.Find ("Cube Right").GetComponent<Spinner>(); //example two: initialized as a class, it still needs to find the Game Object //but because cubeRightGo is a class type, we cannot initialise to a GameObject. We had to get it's Script/class }
void OnDestroy () { instance = null; }
// Use this for initialization void Awake () { instance = this; gameObject.SetActive(false); }
public void OnTalkToMe(string message) => TalkToMe?.Invoke(this, new TalkEventArgs(message));