/// <summary> /// Create a packet that will send a custom object creation call. /// It is expected that the first byte that follows will identify which function will be parsing this packet later. /// </summary> static public void CreateEx(int rccID, bool persistent, string path, params object[] objs) { GameObject go = LoadGameObject(path); if (go != null) { if (isConnected) { if (mInstance != null && mInstance.mClient.isSwitchingScenes) { Debug.LogWarning("Trying to create an object while switching scenes. Call will be ignored."); } BinaryWriter writer = mInstance.mClient.BeginSend(Packet.RequestCreate); byte flag = GetFlag(go, persistent); writer.Write((ushort)65535); writer.Write(flag); writer.Write(path); writer.Write((byte)rccID); writer.WriteArray(objs); EndSend(); return; } objs = BinaryExtensions.CombineArrays(go, objs); UnityTools.ExecuteAll(GetRCCs(), (byte)rccID, objs); UnityTools.Clear(objs); } else { Debug.LogError("Unable to load " + path); } }
/// <summary> /// Create a packet that will send a custom object creation call. /// It is expected that the first byte that follows will identify which function will be parsing this packet later. /// </summary> static public void CreateEx(int rccID, bool persistent, GameObject go, params object[] objs) { if (go != null) { int index = IndexOf(go); if (isConnected) { if (index != -1) { BinaryWriter writer = mInstance.mClient.BeginSend(Packet.RequestCreate); writer.Write((ushort)index); writer.Write(GetFlag(go, persistent)); writer.Write((byte)rccID); writer.WriteArray(objs); EndSend(); return; } else { Debug.LogError("\"" + go.name + "\" has not been added to TNManager's list of objects, so it cannot be instantiated.\n" + "Consider placing it into the Resources folder and passing its name instead.", go); } } objs = BinaryExtensions.CombineArrays(go, objs); UnityTools.ExecuteAll(GetRCCs(), (byte)rccID, objs); UnityTools.Clear(objs); } }
/// <summary> /// Invoke the function specified by the function name. /// </summary> public bool Execute(string funcName, params object[] parameters) { if (mParent != null) { return(mParent.Execute(funcName, parameters)); } if (rebuildMethodList) { RebuildMethodList(); } return(UnityTools.ExecuteAll(mRFCs, funcName, parameters)); }
/// <summary> /// Invoke the function specified by the ID. /// </summary> public bool Execute (byte funcID, params object[] parameters) { if (mParent != null) return mParent.Execute(funcID, parameters); if (rebuildMethodList) RebuildMethodList(); return UnityTools.ExecuteAll(mRFCs, funcID, parameters); }