コード例 #1
0
        public static void ApplyVisibility(GameObject obj, bool inheritVisible = true, string instanceName = "")
        {
            Node           node           = nodes[obj.name];
            CollectionNode collectionNode = node.collectionInstance;

            if (null != collectionNode)
            {
                instanceName = instanceName + "/" + obj.name;
                foreach (Node n in collectionNode.objects)
                {
                    foreach (Tuple <GameObject, string> item in n.instances)
                    {
                        if (item.Item2 == instanceName)
                        {
                            ApplyVisibility(item.Item1, collectionNode.visible && collectionNode.tempVisible && node.visible && node.tempVisible && inheritVisible, item.Item2);
                        }
                    }
                }

                ApplyCollectionVisibility(collectionNode, instanceName, collectionNode.visible && collectionNode.tempVisible && node.visible && node.tempVisible && inheritVisible);
                obj = obj.transform.Find(Utils.blenderCollectionInstanceOffset).gameObject;
            }

            EnableComponents(obj, node.containerVisible & node.visible & node.tempVisible & inheritVisible);

            // Enable/Disable light
            VRtistMixer.SetLightEnabled(obj, node.containerVisible & node.visible & node.tempVisible & inheritVisible);
        }
コード例 #2
0
 public void RemoveInstance(GameObject obj)
 {
     foreach (Tuple <GameObject, string> item in instances)
     {
         if (item.Item1 == obj)
         {
             instances.Remove(item);
             VRtistMixer.OnInstanceRemoved(obj);
             break;
         }
     }
 }
コード例 #3
0
 public static void Rename(string srcName, string dstName)
 {
     if (nodes.ContainsKey(srcName))
     {
         Node node = nodes[srcName];
         node.prefab.name = dstName;
         foreach (Tuple <GameObject, string> obj in node.instances)
         {
             obj.Item1.name = dstName;
             VRtistMixer.OnObjectRenamed(obj.Item1);
         }
         nodes[dstName] = node;
         nodes.Remove(srcName);
     }
 }
コード例 #4
0
        public void JoinRoom(string roomName)
        {
            byte[] nameBuffer         = Converter.StringToBytes(roomName);
            byte[] mockVersionBuffer  = Converter.StringToBytes("ignored");
            byte[] versionCheckBuffer = Converter.BoolToBytes(true);
            byte[] buffer             = Converter.ConcatenateBuffers(new List <byte[]> {
                nameBuffer, mockVersionBuffer, mockVersionBuffer, versionCheckBuffer
            });
            NetCommand command = new NetCommand(buffer, MessageType.JoinRoom);

            AddCommand(command);

            string json = VRtistMixer.CreateClientNameAndColor();

            if (null == json)
            {
                return;
            }
            NetCommand commandClientInfo = new NetCommand(Converter.StringToBytes(json), MessageType.SetClientCustomAttribute);

            AddCommand(commandClientInfo);
        }
コード例 #5
0
        public bool UnpackFromClientId(NetCommand command, ref List <NetCommand> commands)
        {
            int    index    = 0;
            string masterId = Converter.GetString(command.data, ref index);

            // For debug purpose (unity in editor mode when networkSettings.master is empty)
            string currentMasterId = VRtistMixer.GetMasterId();

            if (null == currentMasterId || currentMasterId.Length == 0)
            {
                VRtistMixer.SetMasterId(masterId);
            }

            if (masterId != VRtistMixer.GetMasterId())
            {
                return(false);
            }

            int remainingData = command.data.Length - index;

            while (remainingData > 0)
            {
                int dataLength = Converter.GetInt(command.data, ref index);
                remainingData -= dataLength + sizeof(int);

                dataLength -= sizeof(int);
                int    messageType = Converter.GetInt(command.data, ref index);
                byte[] newBuffer   = new byte[dataLength];

                Buffer.BlockCopy(command.data, index, newBuffer, 0, dataLength);
                index += dataLength;

                NetCommand newCommand = new NetCommand(newBuffer, (MessageType)messageType);
                commands.Add(newCommand);
            }

            return(true);
        }
コード例 #6
0
 public void AddInstance(GameObject obj, string collectionInstanceName = "/")
 {
     instances.Add(new Tuple <GameObject, string>(obj, collectionInstanceName));
     VRtistMixer.OnInstanceAdded(obj);
 }
コード例 #7
0
        public void Connect()
        {
            connected = false;
            string[] args = System.Environment.GetCommandLineArgs();
#if UNITY_EDITOR
            // For debug purpose use the network settings
            VRtistMixer.GetNetworkData(ref hostname, ref room, ref port, ref master, ref userName, ref userColor);
#else
            hostname = null;
#endif

            // Read command line
            for (int i = 0; i < args.Length; i++)
            {
                if (args[i] == "--room")
                {
                    room = args[i + 1];
                }
                if (args[i] == "--hostname")
                {
                    hostname = args[i + 1];
                }
                if (args[i] == "--port")
                {
                    Int32.TryParse(args[i + 1], out port);
                }
                if (args[i] == "--master")
                {
                    master = args[i + 1];
                }
                if (args[i] == "--username")
                {
                    userName = args[i + 1];
                }
                if (args[i] == "--usercolor")
                {
                    ColorUtility.TryParseHtmlString(args[i + 1], out userColor);
                }
            }

#if UNITY_EDITOR
            VRtistMixer.SetNetworkData(room, master, userName, userColor);
#endif

            if (null == hostname)
            {
                return;
            }

            IPAddress ipAddress = GetIpAddressFromHostname(hostname);
            if (null == ipAddress)
            {
                return;
            }

            IPEndPoint remoteEP = new IPEndPoint(ipAddress, port);

            // Create a TCP/IP  socket.
            socket = new Socket(ipAddress.AddressFamily, SocketType.Stream, ProtocolType.Tcp);

            // Connect the socket to the remote endpoint. Catch any errors.
            try
            {
                socket.Connect(remoteEP);
            }
            catch (ArgumentNullException ane)
            {
                Console.WriteLine("ArgumentNullException : {0}", ane.ToString());
                return;
            }
            catch (SocketException se)
            {
                Console.WriteLine("SocketException : {0}", se.ToString());
                return;
            }
            catch (Exception e)
            {
                Console.WriteLine("Unexpected exception : {0}", e.ToString());
                return;
            }

            JoinRoom(room);
            connected = true;

            NetCommand command = new NetCommand(new byte[0], MessageType.ClientId);
            AddCommand(command);

            NetCommand commandListClients = new NetCommand(new byte[0], MessageType.ListAllClients);
            AddCommand(commandListClients);

            thread = new Thread(new ThreadStart(Run));
            thread.Start();
        }