// Start is called before the first frame update protected void Awake() { if (oneTime) { messages = new SortedList(); scriptEnabled = true; packageIndex = 0; if (gameObjectSpecificPrefix) { Vector3 position = gameObject.transform.position; Vector3 rotation = gameObject.transform.rotation.eulerAngles; Vector3 scale = gameObject.transform.lossyScale; Vector3 index = position + scale + rotation; prefix = prefix + gameObject.name + (gameObject.transform.childCount + index.magnitude).ToString(); } if (!UDPConnectionManager.CheckIfPrefixExist(prefix)) { UDPConnectionManager.AddPrefix(prefix); } UDPConnectionManager.AddToMessageHandler(prefix, this); oneTime = false; } }
public void RestoreToState() { if (state != null && state.StateIsSaved()) { List <object> variables = state.GetVariables(); SortedList coping = (SortedList)variables[0]; SortedList copy = new SortedList(coping); messages = copy; scriptEnabled = (bool)variables[1]; prefix = (string)variables[2]; packageIndex = (int)variables[3]; if (!UDPConnectionManager.CheckIfPrefixExist(prefix)) { UDPConnectionManager.AddPrefix(prefix); } UDPConnectionManager.AddToMessageHandler(prefix, this); } }