public int WriteLength(StreamContext context)
        {
            int length = 0;

            // Meta model
            length += WriteStream.WriteModelLength(0, _metaModel, context);

            if (context.fullModel)
            {
                // Write all properties
                if (_sceneViewUUID != null && _sceneViewUUID.Length > 0)
                {
                    length += WriteStream.WriteBytesLength((uint)PropertyID.SceneViewUUID, _sceneViewUUID.Length);
                }
                if (_prefabName != null && _prefabName.Length > 0)
                {
                    length += WriteStream.WriteStringLength((uint)PropertyID.PrefabName, _prefabName);
                }
            }

            // Components
            if (_componentsModel != null)
            {
                length += WriteStream.WriteModelLength((uint)PropertyID.Components, _componentsModel, context);
            }

            // Child Views
            if (_childViewsModel != null)
            {
                length += WriteStream.WriteModelLength((uint)PropertyID.ChildViews, _childViewsModel, context);
            }

            return(length);
        }
        public int WriteLength(StreamContext context)
        {
            int length = 0;

            if (context.fullModel)
            {
                // Mark unreliable properties as clean and flatten the in-flight cache.
                // TODO: Move this out of WriteLength() once we have a prepareToWrite method.
                _name    = name;
                _pointer = pointer;
                _cache.Clear();

                // Write all properties
                length += WriteStream.WriteStringLength((uint)PropertyID.Name, _name);
                length += WriteStream.WriteVarint32Length((uint)PropertyID.Pointer, _pointer ? 1u : 0u);
            }
            else
            {
                // Reliable properties
                if (context.reliableChannel)
                {
                    LocalCacheEntry entry = _cache.localCache;
                    if (entry.nameSet)
                    {
                        length += WriteStream.WriteStringLength((uint)PropertyID.Name, entry.name);
                    }
                    if (entry.pointerSet)
                    {
                        length += WriteStream.WriteVarint32Length((uint)PropertyID.Pointer, entry.pointer ? 1u : 0u);
                    }
                }
            }

            return(length);
        }
        protected override int WriteLength(StreamContext context)
        {
            int length = 0;

            if (context.fullModel)
            {
                FlattenCache();
                length += WriteStream.WriteVarint32Length((uint)PropertyID.DeviceType, (uint)_deviceType);
                length += WriteStream.WriteStringLength((uint)PropertyID.DeviceModel, _deviceModel);
                length += WriteStream.WriteVarint32Length((uint)PropertyID.HeadActive, _headActive ? 1u : 0u);
                length += WriteStream.WriteVarint32Length((uint)PropertyID.LeftHandActive, _leftHandActive ? 1u : 0u);
                length += WriteStream.WriteVarint32Length((uint)PropertyID.RightHandActive, _rightHandActive ? 1u : 0u);
            }
            else if (context.reliableChannel)
            {
                LocalCacheEntry entry = _cache.localCache;
                if (entry.deviceTypeSet)
                {
                    length += WriteStream.WriteVarint32Length((uint)PropertyID.DeviceType, (uint)entry.deviceType);
                }
                if (entry.deviceModelSet)
                {
                    length += WriteStream.WriteStringLength((uint)PropertyID.DeviceModel, entry.deviceModel);
                }
                if (entry.headActiveSet)
                {
                    length += WriteStream.WriteVarint32Length((uint)PropertyID.HeadActive, entry.headActive ? 1u : 0u);
                }
                if (entry.leftHandActiveSet)
                {
                    length += WriteStream.WriteVarint32Length((uint)PropertyID.LeftHandActive, entry.leftHandActive ? 1u : 0u);
                }
                if (entry.rightHandActiveSet)
                {
                    length += WriteStream.WriteVarint32Length((uint)PropertyID.RightHandActive, entry.rightHandActive ? 1u : 0u);
                }
            }
            return(length);
        }