Example #1
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     else
     {
         Destroy(gameObject);
     }
 }
Example #2
0
    public InstantiateObjectInfo(byte[] bytes)
    {
        var ms = new MemoryStream(bytes);
        var br = new BinaryReader(ms);

        GameObject  = OnlinePrefabs.GetPrefabBy(br.ReadString());
        Position    = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
        Rotation    = new Quaternion(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
        Id          = br.ReadInt32();
        PlayerOwner = (OnlinePlayerId)br.ReadInt32();

        br.Close();
        ms.Close();
    }
Example #3
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Alpha0))
        {
            if (!OnlineManager.IsHost() && clientPanel != null)
            {
                clientPanel.gameObject.SetActive(!clientPanel.gameObject.activeSelf);
            }
            if (OnlineManager.IsHost() && serverPanel != null)
            {
                serverPanel.gameObject.SetActive(!serverPanel.gameObject.activeSelf);
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            this.OnlineInstantiate(OnlinePrefabs.GetPrefabBy("Sphere"), Vector3.zero, Quaternion.identity, OnlineManager.GetPlayerId());
        }
    }