示例#1
0
        public static void      Serialize(ByteBuffer buffer, ServerGameObject NGGameObject)
        {
            using (SafeWrapByteBuffer.Get(buffer))
            {
                NGGameObject.ProcessComponents();

                buffer.Append(NGGameObject.instanceID);
                buffer.AppendUnicodeString(NGGameObject.gameObject.tag);
                buffer.Append(NGGameObject.gameObject.layer);
                buffer.Append(NGGameObject.gameObject.isStatic);
                buffer.Append(NGGameObject.components.Count);

                for (int i = NGGameObject.components.Count - 1; i >= 0; --i)
                {
                    try
                    {
                        NetComponent.Serialize(buffer, NGGameObject.components[i]);
                    }
                    catch (Exception ex)
                    {
                        InternalNGDebug.LogException("GameObject \"" + NGGameObject.gameObject.name + "\" failed on Component \"" + NGGameObject.components[i].component.name + "\" (" + (i + 1) + "/" + NGGameObject.components.Count + ").", ex);
                        throw;
                    }
                }
            }
        }
示例#2
0
        public MonitorGameObject(ServerGameObject gameObject) : base(gameObject.gameObject.GetInstanceID().ToString(), () => gameObject)
        {
            this.gameObject           = gameObject;
            this.gameObjectInstanceID = this.gameObject.instanceID;

            this.children = new List <MonitorData>(this.gameObject.components.Count + 5)
            {
                new MonitorProperty(this.path + NGServerScene.ValuePathSeparator + NGServerScene.SpecialGameObjectSeparator + "active", () => this.gameObject.gameObject, typeof(GameObject).GetProperty("activeSelf")),
                new MonitorString(this.path + NGServerScene.ValuePathSeparator + NGServerScene.SpecialGameObjectSeparator + "name", () => this.gameObject.gameObject, new PropertyModifier(typeof(GameObject).GetProperty("name"))),
                new MonitorProperty(this.path + NGServerScene.ValuePathSeparator + NGServerScene.SpecialGameObjectSeparator + "isStatic", () => this.gameObject.gameObject, typeof(GameObject).GetProperty("isStatic")),
                new MonitorString(this.path + NGServerScene.ValuePathSeparator + NGServerScene.SpecialGameObjectSeparator + "tag", () => this.gameObject.gameObject, new PropertyModifier(typeof(GameObject).GetProperty("tag"))),
                new MonitorProperty(this.path + NGServerScene.ValuePathSeparator + NGServerScene.SpecialGameObjectSeparator + "layer", () => this.gameObject.gameObject, typeof(GameObject).GetProperty("layer"))
            };

            this.gameObject.ProcessComponents();

            for (int i = 0; i < this.gameObject.components.Count; i++)
            {
                this.children.Add(new MonitorComponent(this.path + NGServerScene.ValuePathSeparator + this.gameObject.components[i].instanceID, this.gameObject.components[i]));
            }
        }