Пример #1
0
        private void    OnCommandAnswered(ResponsePacket p)
        {
            if (p.CheckPacketStatus() == true)
            {
                ServerSendCommandResponsePacket packet = p as ServerSendCommandResponsePacket;

                for (int i = 0; i < this.pendingCommands.Count; i++)
                {
                    if (this.pendingCommands[i].id == packet.requestId)
                    {
                        if (packet.returnValue == ExecResult.Success)
                        {
                            this.pendingCommands[i].row.result = packet.response;
                        }
                        else
                        {
                            this.pendingCommands[i].row.error = packet.response;
                        }

                        this.pendingCommands.RemoveAt(i);
                        break;
                    }
                }

                this.console.Repaint();
            }
        }
Пример #2
0
 private void    OnCommandNodesReceived(ResponsePacket p)
 {
     if (p.CheckPacketStatus() == true)
     {
         this.parser.SetRoot((p as ServerSendCommandNodesPacket).root);
         this.console.Repaint();
     }
 }
Пример #3
0
        private void    OnComponentToggled(ResponsePacket p)
        {
            if (p.CheckPacketStatus() == true)
            {
                ByteBuffer buffer = Utility.GetBBuffer((p as ServerUpdateFieldValuePacket).rawValue);

                this.fields[this.enabledFieldIndex].value = this.booleanHandler.Deserialize(buffer, typeof(bool));
                Utility.RestoreBBuffer(buffer);
            }
        }
Пример #4
0
 private void    OnAskCLIAnswered(ResponsePacket p)
 {
     if (p.CheckPacketStatus() == true)
     {
         if ((p as ServerAnswerCLIAvailablePacket).hasCLI == true)
         {
             this.client.AddPacket(new ClientRequestCommandNodesPacket(), this.OnCommandNodesReceived);
         }
     }
 }
Пример #5
0
        private void    OnGameObjectActiveUpdated(ResponsePacket p)
        {
            if (p.CheckPacketStatus() == true)
            {
                ByteBuffer buffer = Utility.GetBBuffer((p as ServerUpdateFieldValuePacket).rawValue);

                this.target.active = (bool)this.booleanHandler.Deserialize(buffer, typeof(bool));
                Utility.RestoreBBuffer(buffer);
            }
        }
Пример #6
0
        private void    OnResultReceived(ResponsePacket p)
        {
            if (p.CheckPacketStatus() == true)
            {
                ServerReturnInvokeResultPacket packet = p as ServerReturnInvokeResultPacket;

                this.lastInvokeResult     = packet.result;
                this.lastInvokeResultTime = DateTime.Now;
            }
        }
Пример #7
0
        private static void     OnFieldUpdated(ResponsePacket p)
        {
            if (p.CheckPacketStatus() == true)
            {
                ByteBuffer  buffer      = Utility.GetBBuffer((p as ServerUpdateFieldValuePacket).rawValue);
                UnityObject unityObject = (UnityObject)TypeHandlersManager.GetTypeHandler <UnityObject>().Deserialize(buffer, typeof(UnityObject));

                UnityObjectDrawer.currentUnityObject.Assign(unityObject.type, unityObject.gameObjectInstanceID, unityObject.instanceID, unityObject.name);
                Utility.RestoreBBuffer(buffer);
            }
        }
Пример #8
0
        private void    OnComponentAdded(ResponsePacket p)
        {
            this.editorWindow.Repaint();

            if (p.CheckPacketStatus() == true)
            {
                this.editorWindow.Close();
            }
            else
            {
                this.editorWindow.ShowNotification(new GUIContent("Component could not be added."));
            }
        }
Пример #9
0
        private void    OnProjectReceived(ResponsePacket p)
        {
            this.Hierarchy.UnblockRequestChannel(this.GetHashCode());

            if (p.CheckPacketStatus() == true)
            {
                ServerSendProjectPacket packet = p as ServerSendProjectPacket;

                this.projectAssets = packet.assets;
                this.root          = new Folder(null, "Assets");

                for (int i = 0; i < this.projectAssets.Length; i++)
                {
                    this.GeneratePath(this.projectAssets[i]);
                }

                this.Repaint();
            }
        }
Пример #10
0
        private void    OnGameObjectDataReceived(ResponsePacket p)
        {
            if (p.CheckPacketStatus() == true)
            {
                ServerSendGameObjectDataPacket packet = p as ServerSendGameObjectDataPacket;

                if (packet.gameObjectData.Length == 1)
                {
                    this.tag      = packet.gameObjectData[0].tag;
                    this.layer    = packet.gameObjectData[0].layer;
                    this.isStatic = packet.gameObjectData[0].isStatic;

                    if (this.components == null)
                    {
                        this.components = new List <ClientComponent>();
                    }
                    else
                    {
                        this.components.Clear();
                    }

                    for (int j = 0; j < packet.gameObjectData[0].components.Length; j++)
                    {
                        this.components.Add(new ClientComponent(this, packet.gameObjectData[0].components[j], this.unityData));
                    }
                }
                else
                {
                    InternalNGDebug.Log(Errors.Scene_GameObjectNotFound, "GameObject (" + this.instanceID + ") was not found. Failed to update its data.");
                }
            }

            if (this.gameObjectDataReceivedCallback != null)
            {
                this.gameObjectDataReceivedCallback(this);
            }
        }
Пример #11
0
 private void    OnComponentsDeleted(ResponsePacket p)
 {
     // Deletion of Component is handled using NotifyDeletedComponents.
     p.CheckPacketStatus();
 }
Пример #12
0
        private void    OnServerVersionReceived(ResponsePacket p)
        {
            if (p.CheckPacketStatus() == true)
            {
                ServerSendServicesPacket packet = p as ServerSendServicesPacket;
                bool allServicesPresent         = true;
                bool versionMismatch            = false;

                this.remoteServices = new string[packet.services.Length << 1];

                for (int j = 0; j < packet.services.Length; ++j)
                {
                    this.remoteServices[j << 1]       = packet.services[j];
                    this.remoteServices[(j << 1) + 1] = packet.versions[j];
                }

                for (int i = 0; i + 1 < this.requiredServices.Length; i += 2)
                {
                    bool serviceFound = false;

                    for (int j = 0; j < packet.services.Length; j++)
                    {
                        if (this.requiredServices[i] == packet.services[j])
                        {
                            serviceFound = true;

                            if (this.requiredServices[i + 1] != packet.versions[j])
                            {
                                versionMismatch = true;
                            }
                            break;
                        }
                    }

                    if (serviceFound == false)
                    {
                        allServicesPresent = false;
                    }
                }

                if (allServicesPresent == true)
                {
                    if (versionMismatch == true)
                    {
                        this.servicesWarning     = "Required services (" + this.StringifyServices(this.requiredServices) + ") do not fully match the server services (" + this.StringifyServices(this.remoteServices) + ").\nThe behaviour might be unstable.";
                        this.showServicesWarning = true;
                    }

                    this.client.AddPacket(new ClientSubscribeLogsPacket());
                    this.client.AddPacket(new ClientAskCLIAvailablePacket(), this.OnAskCLIAnswered);
                }
                else
                {
                    this.servicesWarning     = "Server does not run required services (Requiring " + this.StringifyServices(this.requiredServices) + ", has " + this.StringifyServices(this.remoteServices) + "). Disconnecting from server.";
                    this.showServicesWarning = true;
                    this.CloseClient();
                }
            }
            else
            {
                InternalNGDebug.LogError("Server could not provide vital services. Can not continue, disconnecting from server.");
                this.CloseClient();
            }
        }
Пример #13
0
        private void    OnRequestAssetCompleted(ResponsePacket p)
        {
            this.importErrorMessage = p.errorMessage;

            if (p.CheckPacketStatus() == true)
            {
                ServerSendRawAssetPacket packet = p as ServerSendRawAssetPacket;

                this.realType = packet.realType;

                this.isDownloading = false;

                Object asset = null;

                //if (this.importMode == AssetImportParameters.ImportMode.UseGUID)
                //	asset = AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(this.guid), realType);
                //else
                if (this.importMode == ImportMode.Auto)
                {
                    if (string.IsNullOrEmpty(this.autoPath) == false)
                    {
                        IObjectImporter importer = RemoteUtility.GetImportAssetTypeSupported(realType);

                        if (importer != null)
                        {
                            try
                            {
                                ImportAssetResult r = importer.ToAsset(packet.data, this.autoPath, out asset);

                                if (r == ImportAssetResult.SavedToDisk)
                                {
                                    AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
                                    asset = AssetDatabase.LoadAssetAtPath(this.autoPath, realType);
                                    InternalNGDebug.Log("Asset created at \"" + this.autoPath + "\".");
                                }
                                else if (r == ImportAssetResult.NeedCreateViaAssetDatabase)
                                {
                                    if (string.IsNullOrEmpty(AssetDatabase.AssetPathToGUID(this.autoPath)) == false)
                                    {
                                        AssetDatabase.DeleteAsset(this.autoPath);
                                    }
                                    AssetDatabase.CreateAsset(asset, this.autoPath);
                                    InternalNGDebug.Log("Asset created at \"" + this.autoPath + "\".");
                                }
                                else if (r == ImportAssetResult.ImportFailure)
                                {
                                    this.importErrorMessage = "Asset creation failed during import.";
                                }
                            }
                            catch (Exception ex)
                            {
                                InternalNGDebug.LogException(ex);
                                this.importErrorMessage = ex.ToString();
                            }
                        }
                    }
                }
                else if (this.importMode == ImportMode.RawCopy)
                {
                    if (string.IsNullOrEmpty(this.outputPath) == false)
                    {
                        IObjectImporter importer = RemoteUtility.GetImportAssetTypeSupported(realType);

                        if (importer != null)
                        {
                            ImportAssetResult r = importer.ToAsset(packet.data, this.outputPath, out asset);

                            if (r == ImportAssetResult.SavedToDisk)
                            {
                                AssetDatabase.Refresh(ImportAssetOptions.ForceSynchronousImport);
                                asset = AssetDatabase.LoadAssetAtPath(this.outputPath, realType);
                            }
                            else if (r == ImportAssetResult.NeedCreateViaAssetDatabase)
                            {
                                if (string.IsNullOrEmpty(AssetDatabase.AssetPathToGUID(this.outputPath)) == false)
                                {
                                    AssetDatabase.DeleteAsset(this.outputPath);
                                }
                                AssetDatabase.CreateAsset(asset, this.outputPath);
                            }
                        }
                    }
                }

                this.copyAsset = asset;
                this.CheckImportState();
            }
            else
            {
                this.isDownloading = false;
            }
        }