Beispiel #1
0
 public FindUnityObjectsResponse(WrappedVariable variable, ObjectPickerContext context, Object[] sourceObjects)
 {
     this.variable      = variable;
     this.context       = context;
     objectDescriptions = new UnityObjectDescription[sourceObjects.Length];
     for (int i = 0; i < sourceObjects.Length; i++)
     {
         objectDescriptions[i] = new UnityObjectDescription(sourceObjects[i]);
     }
 }
Beispiel #2
0
        public FindUnityObjectsResponse(BinaryReader br, int requestID)
            : base(br, requestID)
        {
            variable = new WrappedVariable(br);
            context  = new ObjectPickerContext(br);
            int count = br.ReadInt32();

            objectDescriptions = new UnityObjectDescription[count];
            for (int i = 0; i < count; i++)
            {
                objectDescriptions[i] = new UnityObjectDescription(br);
            }
        }
        public static void Show(ObjectPickerContext context, UnityObjectDescription[] objectDescriptions, WrappedVariable variable, ValueChangedCallback onValueChanged)
        {
            RemoteObjectPickerWindow window = EditorWindow.GetWindow <RemoteObjectPickerWindow>(true);

            window.context            = context;
            window.objectDescriptions = objectDescriptions;
            window.variable           = variable;
            window.onValueChanged     = onValueChanged;
            if (variable != null)
            {
                window.index = objectDescriptions.Select(item => item.Guid).ToList().IndexOf((Guid)variable.Value) + 1;
            }
            window.titleContent = new GUIContent("Select Object");
            window.ShowUtility();
        }
Beispiel #4
0
 public void OnObjectPickerChanged(ObjectPickerContext context, WrappedVariable variable, UnityObjectDescription objectDescription)
 {
     if (context.ComponentGuid != Guid.Empty)
     {
         // Remote component GUID specified, send a SetVariableRequest to update a field or property
         variable.Value = (objectDescription != null) ? objectDescription.Guid : Guid.Empty;
         APIManager.SendToPlayers(new SetVariableRequest(context.ComponentGuid, variable));
     }
     else if (context.ArgumentIndex != -1)
     {
         // If an argument index is supplied, this is updating an editor driven method argument set
         arguments[context.ArgumentIndex].Value = (objectDescription != null) ? objectDescription.Guid : Guid.Empty;
     }
     else
     {
         throw new NotImplementedException();
     }
 }
    public static object DrawIndividualVariable(ObjectPickerContext objectPickerContext, WrappedVariable variable, string fieldName, object fieldValue, OpenPickerCallback onObjectPicker, int index = 0)
    {
        object newValue;

        if (variable.DataType == DataType.Enum)
        {
            newValue = EditorGUILayout.IntPopup(fieldName, (int)fieldValue, variable.MetaData.EnumNames, variable.MetaData.EnumValues);
        }
        else if (variable.DataType == DataType.UnityObjectReference)
        {
            if (fieldValue is Guid)
            {
                EditorGUILayout.BeginHorizontal();
                if ((Guid)fieldValue != Guid.Empty && variable.ValueDisplayNames.Length > index)
                {
                    EditorGUILayout.TextField(fieldName, variable.ValueDisplayNames[index]);
                }
                else
                {
                    EditorGUILayout.TextField(fieldName, "None (" + variable.MetaData.TypeFullName + ")");
                }
                if (objectPickerContext != null)
                {
                    if (GUILayout.Button("...", GUILayout.Width(30)))
                    {
                        onObjectPicker(objectPickerContext, variable);
                    }
                }
                EditorGUILayout.EndHorizontal();

                newValue = fieldValue;
            }
            else
            {
                newValue = EditorGUILayout.ObjectField(fieldName, (UnityEngine.Object)fieldValue, variable.MetaData.GetTypeFromMetaData(), true);
            }
        }
        else if (variable.DataType == DataType.Integer)
        {
            newValue = EditorGUILayout.IntField(fieldName, (int)fieldValue);
        }
        else if (variable.DataType == DataType.Long)
        {
            newValue = EditorGUILayout.LongField(fieldName, (long)fieldValue);
        }
        else if (variable.DataType == DataType.String)
        {
            newValue = EditorGUILayout.TextField(fieldName, (string)fieldValue);
        }
        else if (variable.DataType == DataType.Char)
        {
            string newString = EditorGUILayout.TextField(fieldName, new string((char)fieldValue, 1));
            if (newString.Length == 1)
            {
                newValue = newString[0];
            }
            else
            {
                newValue = fieldValue;
            }
        }
        else if (variable.DataType == DataType.Float)
        {
            newValue = EditorGUILayout.FloatField(fieldName, (float)fieldValue);
        }
        else if (variable.DataType == DataType.Double)
        {
            newValue = EditorGUILayout.DoubleField(fieldName, (double)fieldValue);
        }
        else if (variable.DataType == DataType.Boolean)
        {
            newValue = EditorGUILayout.Toggle(fieldName, (bool)fieldValue);
        }
        else if (variable.DataType == DataType.Vector2)
        {
            newValue = EditorGUILayout.Vector2Field(fieldName, (Vector2)fieldValue);
        }
        else if (variable.DataType == DataType.Vector3)
        {
            newValue = EditorGUILayout.Vector3Field(fieldName, (Vector3)fieldValue);
        }
        else if (variable.DataType == DataType.Vector4)
        {
            newValue = EditorGUILayout.Vector4Field(fieldName, (Vector4)fieldValue);
        }
#if UNITY_2017_2_OR_NEWER
        else if (variable.DataType == DataType.Vector2Int)
        {
            newValue = EditorGUILayout.Vector2IntField(fieldName, (Vector2Int)fieldValue);
        }
        else if (variable.DataType == DataType.Vector3Int)
        {
            newValue = EditorGUILayout.Vector3IntField(fieldName, (Vector3Int)fieldValue);
        }
#endif
        else if (variable.DataType == DataType.Quaternion)
        {
            //if(InspectorSidekick.Current.Settings.RotationsAsEuler)
            //{
            //  Quaternion quaternion = (Quaternion)fieldValue;
            //  Vector3 eulerAngles = quaternion.eulerAngles;
            //  eulerAngles = EditorGUILayout.Vector3Field(fieldName, eulerAngles);
            //  newValue = Quaternion.Euler(eulerAngles);
            //}
            //else
            {
                Quaternion quaternion = (Quaternion)fieldValue;
                Vector4    vector     = new Vector4(quaternion.x, quaternion.y, quaternion.z, quaternion.w);
                vector   = EditorGUILayout.Vector4Field(fieldName, vector);
                newValue = new Quaternion(vector.x, vector.y, vector.z, vector.z);
            }
        }
        else if (variable.DataType == DataType.Bounds)
        {
            newValue = EditorGUILayout.BoundsField(fieldName, (Bounds)fieldValue);
        }
#if UNITY_2017_2_OR_NEWER
        else if (variable.DataType == DataType.BoundsInt)
        {
            newValue = EditorGUILayout.BoundsIntField(fieldName, (BoundsInt)fieldValue);
        }
#endif
        else if (variable.DataType == DataType.Color)
        {
            newValue = EditorGUILayout.ColorField(fieldName, (Color)fieldValue);
        }
        else if (variable.DataType == DataType.Color32)
        {
            newValue = (Color32)EditorGUILayout.ColorField(fieldName, (Color32)fieldValue);
        }
        else if (variable.DataType == DataType.Gradient)
        {
            newValue = InternalEditorGUILayout.GradientField(new GUIContent(fieldName), (Gradient)fieldValue);
        }
        else if (variable.DataType == DataType.AnimationCurve)
        {
            newValue = EditorGUILayout.CurveField(fieldName, (AnimationCurve)fieldValue);
        }
        else if (variable.DataType == DataType.Rect)
        {
            newValue = EditorGUILayout.RectField(fieldName, (Rect)fieldValue);
        }
#if UNITY_2017_2_OR_NEWER
        else if (variable.DataType == DataType.RectInt)
        {
            newValue = EditorGUILayout.RectIntField(fieldName, (RectInt)fieldValue);
        }
#endif
        else
        {
            GUILayout.Label(fieldName);
            newValue = fieldValue;
        }

        return(newValue);
    }
    public static object Draw(ObjectPickerContext objectPickerContext, WrappedVariable variable, OpenPickerCallback onObjectPicker)
    {
        string name = variable.VariableName;

        if ((variable.Attributes.HasFlagByte(VariableAttributes.IsLiteral)))
        {
            name += " [Const]";
        }
        if ((variable.Attributes.HasFlagByte(VariableAttributes.IsStatic)))
        {
            name += " [Static]";
        }

        GUI.enabled = (variable.Attributes.HasFlagByte(VariableAttributes.ReadOnly) == false &&
                       variable.Attributes.HasFlagByte(VariableAttributes.IsLiteral) == false);

        object objectValue = variable.Value;
        object newValue    = null;

        if (variable.DataType != DataType.Unknown)
        {
            if (variable.Attributes.HasFlagByte(VariableAttributes.IsArray) ||
                variable.Attributes.HasFlagByte(VariableAttributes.IsList))
            {
                GUILayout.Label(name);
                EditorGUI.indentLevel++;
                IList list = null;
                int   size = 0;
                if (variable.Value != null)
                {
                    list = (IList)variable.Value;
                    size = list.Count;
                }

                int newSize = Mathf.Max(0, EditorGUILayout.DelayedIntField("Size", size));
                if (newSize != size)
                {
                    if (list == null)
                    {
                        list = new ArrayList();
                    }
                    CollectionUtility.Resize(ref list, variable.DefaultElementValue, newSize);
                }
                if (list != null)
                {
                    for (int i = 0; i < list.Count; i++)
                    {
                        list[i] = DrawIndividualVariable(objectPickerContext, variable, "Element " + i, list[i], onObjectPicker, i);
                    }
                }
                newValue = list;
                EditorGUI.indentLevel--;
            }
            else
            {
                newValue = DrawIndividualVariable(objectPickerContext, variable, name, variable.Value, onObjectPicker);
            }
        }
        else
        {
            EditorGUILayout.LabelField(name, "Unknown <" + variable.Value.ToString() + "> ");
        }
        GUI.enabled = true;

        return(newValue);
    }
Beispiel #7
0
    public static object DrawIndividualVariable(ObjectPickerContext objectPickerContext, WrappedVariable variable, string fieldName, object fieldValue, OpenPickerCallback onObjectPicker, int index = 0)
    {
        object newValue;

        if (variable.DataType == DataType.Enum)
        {
            //Type underlyingType = variable.MetaData.GetTypeFromMetaData();
            int enumValueIndex = Array.IndexOf(variable.MetaData.EnumValues, fieldValue);
            enumValueIndex = EditorGUILayout.Popup(fieldName, enumValueIndex, variable.MetaData.EnumNames);

            newValue = variable.MetaData.EnumValues[enumValueIndex];
        }
        else if (variable.DataType == DataType.UnityObjectReference)
        {
            if (fieldValue is Guid)
            {
                EditorGUILayout.BeginHorizontal();
                Guid fieldValueGuid = (Guid)fieldValue;

                if (fieldValueGuid != Guid.Empty && variable.ValueDisplayNames.Length > index)
                {
                    EditorGUILayout.TextField(fieldName, variable.ValueDisplayNames[index]);
                }
                else
                {
                    EditorGUILayout.TextField(fieldName, "None (" + variable.MetaData.TypeFullName + ")");
                }

                if (objectPickerContext != null)
                {
                    if (GUILayout.Button("...", GUILayout.Width(30)))
                    {
                        onObjectPicker(objectPickerContext, variable);
                    }
                }

                bool guiEnabled = GUI.enabled;
                // Force GUI enabled on for this control
                GUI.enabled = (fieldValueGuid != Guid.Empty);
                if (GUILayout.Button("-->", GUILayout.Width(30)))
                {
                    APIManager       apiManager = BridgingContext.Instance.container.APIManager;
                    SidekickSettings settings   = BridgingContext.Instance.container.Settings;
                    apiManager.SendToPlayers(new GetObjectRequest((Guid)fieldValue, (InfoFlags)settings.GetGameObjectFlags));
                    Debug.Log(fieldValue);
                }

                GUI.enabled = guiEnabled;
                EditorGUILayout.EndHorizontal();

                newValue = fieldValue;
            }
            else
            {
                newValue = EditorGUILayout.ObjectField(fieldName, (UnityEngine.Object)fieldValue, variable.MetaData.GetTypeFromMetaData(), true);
            }
        }
        else if (variable.DataType == DataType.Integer)
        {
            newValue = EditorGUILayout.IntField(fieldName, (int)fieldValue);
        }
        else if (variable.DataType == DataType.Long)
        {
            newValue = EditorGUILayout.LongField(fieldName, (long)fieldValue);
        }
        else if (variable.DataType == DataType.String)
        {
            newValue = EditorGUILayout.TextField(fieldName, (string)fieldValue);
        }
        else if (variable.DataType == DataType.Char)
        {
            string newString = EditorGUILayout.TextField(fieldName, new string((char)fieldValue, 1));
            if (newString.Length == 1)
            {
                newValue = newString[0];
            }
            else
            {
                newValue = fieldValue;
            }
        }
        else if (variable.DataType == DataType.Float)
        {
            newValue = EditorGUILayout.FloatField(fieldName, (float)fieldValue);
        }
        else if (variable.DataType == DataType.Double)
        {
            newValue = EditorGUILayout.DoubleField(fieldName, (double)fieldValue);
        }
        else if (variable.DataType == DataType.Boolean)
        {
            newValue = EditorGUILayout.Toggle(fieldName, (bool)fieldValue);
        }
        else if (variable.DataType == DataType.Vector2)
        {
            newValue = EditorGUILayout.Vector2Field(fieldName, (Vector2)fieldValue);
        }
        else if (variable.DataType == DataType.Vector3)
        {
            newValue = EditorGUILayout.Vector3Field(fieldName, (Vector3)fieldValue);
        }
        else if (variable.DataType == DataType.Vector4)
        {
            newValue = EditorGUILayout.Vector4Field(fieldName, (Vector4)fieldValue);
        }
#if UNITY_2017_2_OR_NEWER
        else if (variable.DataType == DataType.Vector2Int)
        {
            newValue = EditorGUILayout.Vector2IntField(fieldName, (Vector2Int)fieldValue);
        }
        else if (variable.DataType == DataType.Vector3Int)
        {
            newValue = EditorGUILayout.Vector3IntField(fieldName, (Vector3Int)fieldValue);
        }
#endif
        else if (variable.DataType == DataType.Quaternion)
        {
            //if(InspectorSidekick.Current.Settings.RotationsAsEuler)
            //{
            //  Quaternion quaternion = (Quaternion)fieldValue;
            //  Vector3 eulerAngles = quaternion.eulerAngles;
            //  eulerAngles = EditorGUILayout.Vector3Field(fieldName, eulerAngles);
            //  newValue = Quaternion.Euler(eulerAngles);
            //}
            //else
            {
                Quaternion quaternion = (Quaternion)fieldValue;
                Vector4    vector     = new Vector4(quaternion.x, quaternion.y, quaternion.z, quaternion.w);
                vector   = EditorGUILayout.Vector4Field(fieldName, vector);
                newValue = new Quaternion(vector.x, vector.y, vector.z, vector.z);
            }
        }
        else if (variable.DataType == DataType.Bounds)
        {
            newValue = EditorGUILayout.BoundsField(fieldName, (Bounds)fieldValue);
        }
#if UNITY_2017_2_OR_NEWER
        else if (variable.DataType == DataType.BoundsInt)
        {
            newValue = EditorGUILayout.BoundsIntField(fieldName, (BoundsInt)fieldValue);
        }
#endif
        else if (variable.DataType == DataType.Color)
        {
            newValue = EditorGUILayout.ColorField(fieldName, (Color)fieldValue);
        }
        else if (variable.DataType == DataType.Color32)
        {
            newValue = (Color32)EditorGUILayout.ColorField(fieldName, (Color32)fieldValue);
        }
        else if (variable.DataType == DataType.Gradient)
        {
            newValue = InternalEditorGUILayout.GradientField(new GUIContent(fieldName), (Gradient)fieldValue);
        }
        else if (variable.DataType == DataType.AnimationCurve)
        {
            newValue = EditorGUILayout.CurveField(fieldName, (AnimationCurve)fieldValue);
        }
        else if (variable.DataType == DataType.Rect)
        {
            newValue = EditorGUILayout.RectField(fieldName, (Rect)fieldValue);
        }
#if UNITY_2017_2_OR_NEWER
        else if (variable.DataType == DataType.RectInt)
        {
            newValue = EditorGUILayout.RectIntField(fieldName, (RectInt)fieldValue);
        }
#endif
        else
        {
            GUILayout.Label(fieldName);
            newValue = fieldValue;
        }

        return(newValue);
    }
Beispiel #8
0
 public void OnOpenObjectPicker(ObjectPickerContext context, WrappedVariable variable)
 {
     APIManager.SendToPlayers(new GetUnityObjectsRequest(variable, context));
 }
Beispiel #9
0
        void OnGUI()
        {
            // Frame rate tracking
            if (Event.current.type == EventType.Repaint)
            {
                AnimationHelper.UpdateTime();
            }

            GUILayout.Space(9);

            SidekickSettings settings = Settings;


            EditorGUI.BeginChangeCheck();
            InspectionConnection newConnectionMode = (InspectionConnection)GUILayout.Toolbar((int)settings.InspectionConnection, new string[] { "Local", "Remote" }, new GUIStyle("LargeButton"));

            if (EditorGUI.EndChangeCheck())
            {
                SetConnectionMode(newConnectionMode);
            }

            settings.SearchTerm = searchField2.OnGUI(settings.SearchTerm);
            GUILayout.Space(3);
            EditorGUI.BeginChangeCheck();

            EditorGUILayout.BeginHorizontal();
            GUILayout.Label("Display");
            settings.GetGameObjectFlags = SidekickEditorGUI.EnumFlagsToggle(settings.GetGameObjectFlags, InfoFlags.Fields, "Fields");
            settings.GetGameObjectFlags = SidekickEditorGUI.EnumFlagsToggle(settings.GetGameObjectFlags, InfoFlags.Properties, "Properties");
            settings.GetGameObjectFlags = SidekickEditorGUI.EnumFlagsToggle(settings.GetGameObjectFlags, InfoFlags.Methods, "Methods");
            EditorGUILayout.EndHorizontal();

            if (EditorGUI.EndChangeCheck())
            {
                if (!string.IsNullOrEmpty(SelectionManager.SelectedPath)) // Valid path?
                {
                    APIManager.SendToPlayers(new GetGameObjectRequest(SelectionManager.SelectedPath, Settings.GetGameObjectFlags, Settings.IncludeInherited));
                }
            }

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

            if (gameObjectResponse != null)
            {
                string activeSearchTerm = settings.SearchTerm;

                foreach (ComponentDescription component in gameObjectResponse.Components)
                {
                    SidekickEditorGUI.DrawSplitter();
                    GUIStyle style = new GUIStyle(EditorStyles.foldout);
                    style.fontStyle = FontStyle.Bold;

                    Texture    icon    = IconLookup.GetIcon(component.TypeFullName);
                    GUIContent content = new GUIContent(component.TypeShortName, icon, "Object Map ID: " + component.Guid.ToString());

                    float labelWidth = EditorGUIUtility.labelWidth; // Cache label width
                    // Temporarily set the label width to full width so the icon is not squashed with long strings
                    EditorGUIUtility.labelWidth = position.width / 2f;

                    bool wasComponentExpanded = !settings.CollapsedTypeNames.Contains(component.TypeFullName);
                    bool isComponentExpanded  = wasComponentExpanded;


                    bool?activeOrEnabled = null;
                    if (component.TypeShortName == "GameObject" && (settings.GetGameObjectFlags & InfoFlags.Properties) != 0)
                    {
                        activeOrEnabled = (bool)component.Scopes[0].GetPropertyValue("activeSelf");
                    }
                    else
                    {
                        ComponentScope behaviourScope = component.BehaviourScope;
                        if (behaviourScope != null && (settings.GetGameObjectFlags & InfoFlags.Properties) != 0)
                        {
                            activeOrEnabled = (bool)behaviourScope.GetPropertyValue("enabled");
                        }
                    }

                    bool?oldActiveOrEnabled = activeOrEnabled;

                    if (SidekickEditorGUI.DrawHeaderWithFoldout(content, isComponentExpanded, ref activeOrEnabled))
                    {
                        isComponentExpanded = !isComponentExpanded;
                    }

                    if (activeOrEnabled.HasValue && activeOrEnabled != oldActiveOrEnabled)
                    {
                        if (component.TypeShortName == "GameObject")
                        {
                            // Update local cache (requires method call)
                            var property = component.Scopes[0].GetProperty("activeSelf");
                            property.Value = activeOrEnabled.Value;

                            // Update via method call
                            APIManager.SendToPlayers(new InvokeMethodRequest(component.Guid, "SetActive", new WrappedVariable[] { new WrappedVariable("", activeOrEnabled.Value, typeof(bool), false) }));
                        }
                        else if (component.BehaviourScope != null)
                        {
                            // Update local cache, then ship via SetVariable
                            var property = component.BehaviourScope.GetProperty("enabled");
                            property.Value = activeOrEnabled.Value;

                            APIManager.SendToPlayers(new SetVariableRequest(component.Guid, property));
                        }
                    }
                    EditorGUIUtility.labelWidth = labelWidth; // Restore label width
                    if (isComponentExpanded != wasComponentExpanded)
                    {
                        if (isComponentExpanded == false)
                        {
                            // Not expanded, so collapse it
                            settings.CollapsedTypeNames.Add(component.TypeFullName);
                        }
                        else
                        {
                            // Expanded, remove it from collapse list
                            settings.CollapsedTypeNames.Remove(component.TypeFullName);
                        }
                    }

                    if (isComponentExpanded)
                    {
                        foreach (ComponentScope scope in component.Scopes)
                        {
                            if (scope.TypeFullName != component.TypeFullName)
                            {
                                SidekickEditorGUI.DrawHeader2(new GUIContent(": " + scope.TypeShortName));
                            }

                            ObjectPickerContext objectPickerContext = new ObjectPickerContext(component.Guid);
                            foreach (var field in scope.Fields)
                            {
                                if (!string.IsNullOrEmpty(activeSearchTerm) && !field.VariableName.Contains(activeSearchTerm, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    // Active search term not matched, skip it
                                    continue;
                                }

                                if (settings.IgnoreObsolete && (field.Attributes & VariableAttributes.Obsolete) == VariableAttributes.Obsolete)
                                {
                                    // Skip obsolete entries if that setting is enabled
                                    continue;
                                }
                                EditorGUI.BeginChangeCheck();
                                object newValue = VariableDrawer.Draw(objectPickerContext, field, OnOpenObjectPicker);
                                if (EditorGUI.EndChangeCheck() && (field.Attributes & VariableAttributes.ReadOnly) == VariableAttributes.None && field.DataType != DataType.Unknown)
                                {
                                    if (newValue != field.Value || field.Attributes.HasFlagByte(VariableAttributes.IsList) || field.Attributes.HasFlagByte(VariableAttributes.IsArray))
                                    {
                                        field.Value = newValue;
                                        APIManager.SendToPlayers(new SetVariableRequest(component.Guid, field));
                                    }

                                    //Debug.Log("Value changed in " + field.VariableName);
                                }
                            }
                            foreach (var property in scope.Properties)
                            {
                                if (!string.IsNullOrEmpty(activeSearchTerm) && !property.VariableName.Contains(activeSearchTerm, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    // Active search term not matched, skip it
                                    continue;
                                }

                                if (settings.IgnoreObsolete && (property.Attributes & VariableAttributes.Obsolete) == VariableAttributes.Obsolete)
                                {
                                    // Skip obsolete entries if that setting is enabled
                                    continue;
                                }

                                EditorGUI.BeginChangeCheck();
                                object newValue = VariableDrawer.Draw(objectPickerContext, property, OnOpenObjectPicker);
                                if (EditorGUI.EndChangeCheck() && (property.Attributes & VariableAttributes.ReadOnly) == VariableAttributes.None && property.DataType != DataType.Unknown)
                                {
                                    if (newValue != property.Value || property.Attributes.HasFlagByte(VariableAttributes.IsList) || property.Attributes.HasFlagByte(VariableAttributes.IsArray))
                                    {
                                        property.Value = newValue;
                                        APIManager.SendToPlayers(new SetVariableRequest(component.Guid, property));
                                    }
                                    //Debug.Log("Value changed in " + property.VariableName);
                                }
                            }

                            GUIStyle   expandButtonStyle = new GUIStyle(GUI.skin.button);
                            RectOffset padding           = expandButtonStyle.padding;
                            padding.left              = 0;
                            padding.right             = 1;
                            expandButtonStyle.padding = padding;

                            GUIStyle labelStyle = new GUIStyle(GUI.skin.label);
                            labelStyle.alignment = TextAnchor.MiddleRight;
                            GUIStyle normalButtonStyle = new GUIStyle(GUI.skin.button);
                            normalButtonStyle.padding   = normalButtonStyle.padding.SetLeft(100);
                            normalButtonStyle.alignment = TextAnchor.MiddleLeft;

                            foreach (var method in scope.Methods)
                            {
                                if (!string.IsNullOrEmpty(activeSearchTerm) && !method.MethodName.Contains(activeSearchTerm, StringComparison.InvariantCultureIgnoreCase))
                                {
                                    // Active search term not matched, skip it
                                    continue;
                                }

                                if (settings.IgnoreObsolete && (method.MethodAttributes & MethodAttributes.Obsolete) == MethodAttributes.Obsolete)
                                {
                                    // Skip obsolete entries if that setting is enabled
                                    continue;
                                }

                                if (method.SafeToFire == false)
                                {
                                    EditorGUI.BeginDisabledGroup(true);
                                }

                                GUILayout.BeginHorizontal();
                                if (method.ReturnType == DataType.Void)
                                {
                                    labelStyle.normal.textColor = Color.grey;
                                }
                                else if ((method.ReturnTypeAttributes & VariableAttributes.IsValueType) == VariableAttributes.IsValueType)
                                {
                                    labelStyle.normal.textColor = new Color(0, 0, 1);
                                }
                                else
                                {
                                    labelStyle.normal.textColor = new Color32(255, 130, 0, 255);
                                }

                                string displayText = method.MethodName + " (" + method.ParameterCount + ")";

                                if ((method.MethodAttributes & MethodAttributes.Static) == MethodAttributes.Static)
                                {
                                    displayText += " [Static]";
                                }

                                if (method.SafeToFire == false)
                                {
                                    displayText += " [Unsupported]";
                                }

                                bool wasMethodExpanded = (method.Equals(expandedMethod));

                                if (GUILayout.Button(displayText, normalButtonStyle))
                                {
                                    if (wasMethodExpanded)
                                    {
                                        APIManager.SendToPlayers(new InvokeMethodRequest(component.Guid, method.MethodName, arguments.ToArray()));
                                    }
                                    else
                                    {
                                        // Not expanded, just use the default values
                                        List <WrappedVariable> defaultArguments = new List <WrappedVariable>();

                                        for (int i = 0; i < method.ParameterCount; i++)
                                        {
                                            WrappedParameter parameter = method.Parameters[i];
                                            defaultArguments.Add(new WrappedVariable(parameter));
                                        }

                                        APIManager.SendToPlayers(new InvokeMethodRequest(component.Guid, method.MethodName, defaultArguments.ToArray()));
                                    }
                                }

                                Rect lastRect = GUILayoutUtility.GetLastRect();
                                lastRect.xMax = normalButtonStyle.padding.left;
                                GUI.Label(lastRect, TypeUtility.NameForType(method.ReturnType), labelStyle);

                                if (method.ParameterCount > 0)
                                {
                                    bool isMethodExpanded = GUILayout.Toggle(wasMethodExpanded, "▼", expandButtonStyle, GUILayout.Width(20));
                                    GUILayout.EndHorizontal();

                                    if (isMethodExpanded != wasMethodExpanded) // has changed
                                    {
                                        if (isMethodExpanded)
                                        {
                                            // Reset the keyboard control as we don't want old text carrying over
                                            GUIUtility.keyboardControl = 0;

                                            expandedMethod = method;
                                            arguments      = new List <WrappedVariable>(method.ParameterCount);
                                            for (int i = 0; i < method.ParameterCount; i++)
                                            {
                                                WrappedParameter parameter = method.Parameters[i];
                                                arguments.Add(new WrappedVariable(parameter));
                                            }
                                        }
                                        else
                                        {
                                            expandedMethod = null;
                                            arguments      = null;
                                        }
                                    }
                                    else if (isMethodExpanded)
                                    {
                                        EditorGUI.indentLevel++;
                                        for (int i = 0; i < arguments.Count; i++)
                                        {
                                            var argument = arguments[i];
                                            argument.Value = VariableDrawer.Draw(new ObjectPickerContext(i), argument, OnOpenObjectPicker);
                                            //argument.Value = VariableDrawer.DrawIndividualVariable(null, argument, argument.VariableName, DataTypeHelper.GetSystemTypeFromWrappedDataType(argument.DataType), argument.Value, OnOpenObjectPicker);
                                        }

                                        //Rect buttonRect = GUILayoutUtility.GetRect(new GUIContent(), GUI.skin.button);
                                        //buttonRect = EditorGUI.IndentedRect(buttonRect);


                                        EditorGUI.indentLevel--;

                                        GUILayout.Space(10);
                                    }
                                }
                                else
                                {
                                    GUILayout.EndHorizontal();
                                }

                                if (method.SafeToFire == false)
                                {
                                    EditorGUI.EndDisabledGroup();
                                }
                            }
                        }
                    }
                }
                SidekickEditorGUI.DrawSplitter();
            }
            EditorGUILayout.EndScrollView();

            DrawOutputBox();
        }
 public GetUnityObjectsRequest(BinaryReader br)
 {
     this.variable = new WrappedVariable(br);
     this.context  = new ObjectPickerContext(br);
 }
 public GetUnityObjectsRequest(WrappedVariable variable, ObjectPickerContext context)
 {
     this.variable = variable;
     this.context  = context;
 }