Exemple #1
0
    // вызывается из потока событий unity
    static private PacketSetcameraReady setcamera(PacketHeader packet)
    {
        PacketSetcamera setcamera = UnityEngine.JsonUtility.FromJson <PacketSetcamera>(packet.json_data);

        setcamera.idname = (setcamera.idname == null) ? activecamera : setcamera.idname;

        if (!idnames.ContainsKey(setcamera.idname))
        {
            return(new PacketSetcameraReady(0));
        }

        int id = idnames[setcamera.idname];

        if (cameras.ContainsKey(id))
        {
            UnityEngine.GameObject obj = cameras[id];

            camera bhv = obj.GetComponent <camera>();

            bhv.targetposition     = new UnityEngine.Vector3(setcamera.x0, setcamera.y0, setcamera.z0);
            obj.transform.position = new UnityEngine.Vector3(setcamera.x1, setcamera.y1, setcamera.z1);

            bhv.Init();

            return(new PacketSetcameraReady(1));
        }

        return(new PacketSetcameraReady(0));
    }