Ejemplo n.º 1
0
    /// <summary>
    /// Create the specified game object on all connected clients.
    /// Note that the object must be present in the TNManager's list of objects.
    /// </summary>

    static public void Create(GameObject go, bool persistent)
    {
        if (mInstance != null)
        {
            int index = mInstance.IndexOf(go);

            if (index != -1)
            {
                if (mInstance.mClient.isConnected)
                {
                    BinaryWriter writer = mInstance.mClient.BeginSend(Packet.RequestCreate);
                    writer.Write((ushort)index);
                    writer.Write(GetFlag(go, persistent));
                    writer.Write((byte)0);
                    mInstance.mClient.EndSend();
                    return;
                }
            }
            else
            {
                Debug.LogError("You must add the object you're trying to create to the TNManager's list of objects", go);
            }
        }
        Instantiate(go);
    }