示例#1
0
        private void OnMessageGameObjectComponents(rdtTcpMessage message)
        {
            this.m_components = new rdtTcpMessageComponents?((rdtTcpMessageComponents)message);
            List <rdtTcpMessageComponents.Component> components = this.m_components.Value.m_components;

            for (int i = 0; i < components.Count; i++)
            {
                rdtTcpMessageComponents.Component component = components[i];
                if (component.m_properties == null)
                {
                    rdtDebug.Debug(this, "Component '{0}' has no properties", new object[] { component.m_name });
                }
                else
                {
                    for (int j = 0; j < component.m_properties.Count; j++)
                    {
                        rdtTcpMessageComponents.Property property = component.m_properties[j];
                        property.Deserialise(this.m_serializerRegistry);
                        component.m_properties[j] = property;
                    }
                    components[i] = component;
                }
            }
            base.Repaint();
        }
示例#2
0
        private bool DrawComponentTitle(rdtTcpMessageComponents.Component component, [Optional, DefaultParameterValue(null)] UnityEngine.Component unityComponent)
        {
            bool foldout  = this.m_expandedCache.IsExpanded(component);
            bool expanded = foldout;
            Rect rect     = EditorGUILayout.BeginHorizontal(new GUILayoutOption[] { GUILayout.Height(18f) });
            Rect position = GUILayoutUtility.GetRect((float)13f, (float)16f, new GUILayoutOption[] { GUILayout.ExpandWidth(false) });

            if ((component.m_properties != null) && (component.m_properties.Count > 0))
            {
                expanded = EditorGUI.Foldout(position, foldout, GUIContent.none, this.m_normalFoldoutStyle);
                if (expanded != foldout)
                {
                    this.m_expandedCache.SetExpanded(expanded, component);
                }
            }
            bool flag3 = true;
            int  width = this.m_toggleStyle.normal.background.width;

            if (component.m_canBeDisabled)
            {
                flag3 = EditorGUILayout.Toggle(component.m_enabled, this.m_toggleStyle, new GUILayoutOption[] { GUILayout.Width((float)width) });
            }
            else
            {
                EditorGUILayout.LabelField("", new GUILayoutOption[] { GUILayout.Width((float)width) });
            }
            string label = ObjectNames.NicifyVariableName(component.m_name);

            if (this.m_debug)
            {
                label = label + ":" + component.m_instanceId;
            }
            EditorGUILayout.LabelField(label, EditorStyles.boldLabel, new GUILayoutOption[0]);
            if (component.m_canBeDisabled && (flag3 != component.m_enabled))
            {
                component.m_enabled = flag3;
                this.OnPropertyChanged(new rdtTcpMessageComponents.Component?(component), null, null);
            }
            EditorGUILayout.EndHorizontal();
            if ((component.m_properties != null) && (component.m_properties.Count > 0))
            {
                Event current = Event.current;
                if (!rect.Contains(current.mousePosition) || !current.isMouse)
                {
                    return(expanded);
                }
                if (current.type == EventType.MouseDown)
                {
                    this.m_pendingExpandComponent = new rdtTcpMessageComponents.Component?(component);
                    current.Use();
                    return(expanded);
                }
                if (((current.type == EventType.MouseUp) && this.m_pendingExpandComponent.HasValue) && (this.m_pendingExpandComponent.Value.m_instanceId != component.m_instanceId))
                {
                    this.m_pendingExpandComponent = null;
                }
            }
            return(expanded);
        }
示例#3
0
 private void DrawComponent(rdtTcpMessageComponents.Component component, Stack <rdtTcpMessageComponents.Property> hierarchy, List <rdtTcpMessageComponents.Property> properties)
 {
     if ((properties != null) && (properties.Count != 0))
     {
         foreach (rdtTcpMessageComponents.Property property in properties)
         {
             EditorGUILayout.BeginHorizontal(new GUILayoutOption[0]);
             string content   = ObjectNames.NicifyVariableName(property.m_name);
             object propValue = property.m_value;
             bool   flag      = rdtGuiProperty.HasFoldout(propValue);
             if (!flag)
             {
                 GUILayout.Space((float)((EditorStyles.foldout.padding.left + EditorStyles.foldout.margin.left) - EditorStyles.label.padding.left));
             }
             bool        foldout = flag ? this.m_expandedCache.IsExpanded(component, property) : false;
             System.Type type    = propValue.GetType();
             hierarchy.Push(property);
             if (type == typeof(List <rdtTcpMessageComponents.Property>))
             {
                 EditorGUILayout.BeginVertical(new GUILayoutOption[0]);
                 GUILayout.Label("", new GUILayoutOption[0]);
                 foldout = EditorGUI.Foldout(GUILayoutUtility.GetLastRect(), foldout, content, true);
                 if (foldout)
                 {
                     EditorGUI.indentLevel++;
                     List <rdtTcpMessageComponents.Property> list = (List <rdtTcpMessageComponents.Property>)propValue;
                     this.DrawComponent(component, hierarchy, list);
                     EditorGUI.indentLevel--;
                 }
                 EditorGUILayout.EndVertical();
             }
             else
             {
                 object newValue = rdtGuiProperty.Draw(content, propValue, ref foldout);
                 this.CheckValueChanged(propValue, newValue, hierarchy, component);
             }
             hierarchy.Pop();
             if (flag)
             {
                 this.m_expandedCache.SetExpanded(foldout, component, property);
             }
             EditorGUILayout.EndHorizontal();
         }
     }
 }
示例#4
0
 public void SetExpanded(bool expanded, rdtTcpMessageComponents.Component component, rdtTcpMessageComponents.Property property)
 {
     this.SetExpanded(expanded, component.m_instanceId, property.m_name);
 }
示例#5
0
 public void SetExpanded(bool expanded, rdtTcpMessageComponents.Component component)
 {
     this.SetExpanded(expanded, component.m_instanceId, null);
 }
示例#6
0
 public bool IsExpanded(rdtTcpMessageComponents.Component component, rdtTcpMessageComponents.Property property)
 {
     return(this.IsExpanded(component.m_instanceId, property.m_name));
 }
示例#7
0
 public bool IsExpanded(rdtTcpMessageComponents.Component component)
 {
     return(this.IsExpanded(component.m_instanceId, null));
 }
示例#8
0
        private void OnRequestGameObjectComponents(rdtTcpMessage message)
        {
            rdtTcpMessageGetComponents components = (rdtTcpMessageGetComponents)message;

            if (components.m_instanceId != 0)
            {
                GameObject obj2 = this.FindGameObject(components.m_instanceId);
                if (obj2 != null)
                {
                    rdtTcpMessageComponents components2 = new rdtTcpMessageComponents();
                    components2.m_instanceId = components.m_instanceId;
                    components2.m_components = new List <rdtTcpMessageComponents.Component>();
                    components2.m_layer      = obj2.layer;
                    components2.m_tag        = obj2.tag;
                    components2.m_enabled    = obj2.activeSelf;
                    this.m_components.Clear();
                    obj2.GetComponents <UnityEngine.Component>(this.m_unityComponents);
                    if (this.m_unityComponents.Count > this.m_components.Capacity)
                    {
                        this.m_components.Capacity = this.m_unityComponents.Count;
                    }
                    for (int i = 0; i < this.m_unityComponents.Count; i++)
                    {
                        UnityEngine.Component owner = this.m_unityComponents[i];
                        if (owner == null)
                        {
                            rdtDebug.Debug(this, "Component is null, skipping", new object[0]);
                        }
                        else
                        {
                            List <rdtTcpMessageComponents.Property> list = this.m_server.SerializerRegistry.ReadAllFields(owner);
                            if (list == null)
                            {
                                rdtDebug.Debug(this, "Properties are null, skipping", new object[0]);
                            }
                            else
                            {
                                rdtTcpMessageComponents.Component item = new rdtTcpMessageComponents.Component();
                                if (owner is Behaviour)
                                {
                                    item.m_canBeDisabled = true;
                                    item.m_enabled       = ((Behaviour)owner).enabled;
                                }
                                else if (owner is Renderer)
                                {
                                    item.m_canBeDisabled = true;
                                    item.m_enabled       = ((Renderer)owner).enabled;
                                }
                                else if (owner is Collider)
                                {
                                    item.m_canBeDisabled = true;
                                    item.m_enabled       = ((Collider)owner).enabled;
                                }
                                else
                                {
                                    item.m_canBeDisabled = false;
                                    item.m_enabled       = true;
                                }
                                System.Type type = owner.GetType();
                                item.m_name         = type.Name;
                                item.m_assemblyName = type.AssemblyQualifiedName;
                                item.m_instanceId   = owner.GetInstanceID();
                                item.m_properties   = list;
                                this.m_components.Add(item);
                            }
                        }
                    }
                    components2.m_components = this.m_components;
                    this.m_unityComponents.Clear();
                    this.m_server.EnqueueMessage(components2);
                }
            }
        }
示例#9
0
 private void CheckValueChanged(object oldValue, object newValue, Stack <rdtTcpMessageComponents.Property> hierarchy, rdtTcpMessageComponents.Component component)
 {
     if (newValue != null)
     {
         bool flag = false;
         if (oldValue.GetType().IsArray)
         {
             Array array  = (Array)oldValue;
             Array array2 = (Array)newValue;
             flag = array.Length != array2.Length;
             if (!flag)
             {
                 for (int i = 0; i < array.Length; i++)
                 {
                     object obj2 = array.GetValue(i);
                     object obj3 = array2.GetValue(i);
                     flag = ((obj2 == null) && (obj3 != null)) || ((obj2 != null) && (obj3 == null));
                     if (!flag && (obj2 != null))
                     {
                         flag = !obj2.Equals(obj3);
                     }
                     if (flag)
                     {
                         break;
                     }
                 }
             }
         }
         else
         {
             flag = !newValue.Equals(oldValue);
         }
         if (flag)
         {
             rdtTcpMessageComponents.Property[] collection = hierarchy.ToArray();
             collection[0].m_value = newValue;
             hierarchy             = new Stack <rdtTcpMessageComponents.Property>(collection);
             this.OnPropertyChanged(new rdtTcpMessageComponents.Component?(component), hierarchy, null);
         }
     }
 }