Exemple #1
0
        private void RefreshRemoteComponents(REObject remoteObject)
        {
            // CLEAR
            foreach (var component in remoteObject.Components)
            {
                _itemsDictionary.Remove(component.InstanceId);
            }

            remoteObject.Components.Clear();

            // POPULATE
            var components = remoteObject.Target.GetComponents <Component>();

            foreach (var component in components)
            {
                if (component == null)
                {
                    continue;
                }

                var componentType = component.GetType();

                var remoteComponent = new REComponent();
                remoteComponent.Target     = component;
                remoteComponent.Name       = componentType.Name;
                remoteComponent.Parent     = remoteObject;
                remoteComponent.InstanceId = component.GetInstanceID();

                remoteObject.Components.Add(remoteComponent);
                _itemsDictionary.Add(remoteComponent.InstanceId, remoteComponent);
            }
        }
        private REInvokeStatus InvokeGetComponentsCommand(Task task, List <OSCValue> inputValues, ref List <OSCValue> outputValues)
        {
            if (inputValues.Count != 4)
            {
                return(REInvokeStatus.Cancel);
            }

            if (inputValues[0].Type != OSCValueType.Int ||
                inputValues[1].Type != OSCValueType.Int ||
                inputValues[2].Type != OSCValueType.Int ||
                inputValues[3].Type != OSCValueType.String)
            {
                return(REInvokeStatus.Cancel);
            }

            var index         = inputValues[0].IntValue;
            var count         = inputValues[1].IntValue;
            var instanceId    = inputValues[2].IntValue;
            var componentType = inputValues[3].StringValue;

            var parentObject = GetItem(task.ParentId) as REObject;

            if (parentObject == null)
            {
                return(REInvokeStatus.Cancel);
            }

            var remoteComponent = new REComponent();

            remoteComponent.Name       = componentType;
            remoteComponent.InstanceId = instanceId;
            remoteComponent.Parent     = parentObject;

            parentObject.Components.Add(remoteComponent);

            if (_itemsDictionary.ContainsKey(remoteComponent.InstanceId))
            {
                _itemsDictionary.Remove(remoteComponent.InstanceId);
            }

            _itemsDictionary.Add(remoteComponent.InstanceId, remoteComponent);

            task.Process(instanceId);

            index++;

            if (index >= count)
            {
                return(REInvokeStatus.Cancel);
            }

            outputValues.Add(OSCValue.Int(index));

            return(REInvokeStatus.Complete);
        }
Exemple #3
0
        private void RefreshRemoteFields(REComponent remoteComponent)
        {
            // CLEAR
            remoteComponent.Fields.Clear();

            // POPULATE
            var componentType = remoteComponent.Target.GetType();
            var fieldsInfos   = componentType.GetFields(BindingFlags.Instance | BindingFlags.Public);

            foreach (var fieldInfo in fieldsInfos)
            {
                if (!OSCSerializer.HasPacker(fieldInfo.FieldType))
                {
                    continue;
                }

                var remoteField = new REField(fieldInfo);
                remoteField.FieldType = REFieldType.Field;
                remoteField.TypeName  = fieldInfo.FieldType.Name;
                remoteField.FieldName = fieldInfo.Name;
                remoteField.Parent    = remoteComponent;

                remoteComponent.Fields.Add(remoteField);
            }

            var propertiesInfos = componentType.GetProperties(BindingFlags.Instance | BindingFlags.Public);

            foreach (var propertyInfo in propertiesInfos)
            {
                if (!propertyInfo.CanRead || !propertyInfo.CanWrite)
                {
                    continue;
                }

                if (!OSCSerializer.HasPacker(propertyInfo.PropertyType))
                {
                    continue;
                }

                var remoteField = new REField(propertyInfo);
                remoteField.FieldType = REFieldType.Property;
                remoteField.TypeName  = propertyInfo.PropertyType.Name;
                remoteField.FieldName = propertyInfo.Name;
                remoteField.Parent    = remoteComponent;

                remoteComponent.Fields.Add(remoteField);
            }
        }