예제 #1
0
        void OnResponseReceived(BaseResponse response)
        {
            Repaint();

            if (response is GetGameObjectResponse)
            {
                gameObjectResponse = (GetGameObjectResponse)response;
            }
            else if (response is InvokeMethodResponse)
            {
                InvokeMethodResponse invokeMethodResponse = (InvokeMethodResponse)response;
                methodOutput = invokeMethodResponse.MethodName + " () returned:\n" + invokeMethodResponse.ReturnedVariable.Value;

                UnityEngine.Object returnedUnityObject = invokeMethodResponse.ReturnedVariable.Value as UnityEngine.Object;
                if (returnedUnityObject != null)
                {
                    EditorGUIUtility.PingObject(returnedUnityObject);
                }
                opacity = 1f;
                Repaint();
            }
            else if (response is GetUnityObjectsResponse)
            {
                GetUnityObjectsResponse castResponse = (GetUnityObjectsResponse)response;

                RemoteObjectPickerWindow.Show(castResponse.Context, castResponse.ObjectDescriptions, castResponse.Variable, OnObjectPickerChanged);
            }
#if SIDEKICK_DEBUG
            string responseString = ResponseDebug.GetDebugStringForResponse(response);
            if (!string.IsNullOrEmpty(responseString))
            {
                Debug.Log(responseString);
            }
#endif
        }
        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();
        }
        void OnResponseReceived(BaseResponse response)
        {
            Repaint();

            if (response is GetGameObjectResponse)
            {
                gameObjectResponse = (GetGameObjectResponse)response;
                StringBuilder stringBuilder = new StringBuilder();
                stringBuilder.AppendLine(gameObjectResponse.GameObjectName);
                foreach (var component in gameObjectResponse.Components)
                {
                    stringBuilder.Append(" ");
                    stringBuilder.AppendLine(component.TypeFullName);
                    foreach (var field in component.Fields)
                    {
                        stringBuilder.Append("  ");
                        stringBuilder.Append(field.VariableName);
                        stringBuilder.Append(" ");
                        stringBuilder.Append(field.DataType);
                        stringBuilder.Append(" = ");
                        stringBuilder.Append(field.Value);
                        stringBuilder.AppendLine();
                    }
                    foreach (var property in component.Properties)
                    {
                        stringBuilder.Append("  ");
                        stringBuilder.Append(property.VariableName);
                        stringBuilder.Append(" ");
                        stringBuilder.Append(property.DataType);
                        stringBuilder.Append(" = ");
                        stringBuilder.Append(property.Value);
                        stringBuilder.AppendLine();
                    }
                    foreach (var method in component.Methods)
                    {
                        stringBuilder.Append("  ");
                        stringBuilder.Append(method.MethodName);
                        stringBuilder.Append(" ");
                        stringBuilder.Append(method.ReturnType);
                        stringBuilder.Append(" ");
                        stringBuilder.Append(method.ParameterCount);
                        stringBuilder.Append(" ");
                        if (method.Parameters.Count > 0)
                        {
                            stringBuilder.Append(method.Parameters[0].DataType);
                        }
                        stringBuilder.AppendLine();
                    }
                }
                //Debug.Log(stringBuilder);
            }
            else if (response is InvokeMethodResponse)
            {
                InvokeMethodResponse invokeMethodResponse = (InvokeMethodResponse)response;
                methodOutput = invokeMethodResponse.MethodName + " () returned:\n" + invokeMethodResponse.ReturnedVariable.Value;
                opacity      = 1f;
                Repaint();
            }
            else if (response is GetUnityObjectsResponse)
            {
                GetUnityObjectsResponse castResponse = (GetUnityObjectsResponse)response;

                RemoteObjectPickerWindow.Show(castResponse.ComponentGuid, castResponse.ObjectDescriptions, castResponse.Variable, OnObjectPickerChanged);
            }
        }