Exemplo n.º 1
0
        void OnGUI()
        {
            var width = position.width - GUI.skin.verticalScrollbar.fixedWidth - 5;

            EditorGUIUtility.labelWidth = LABEL_WIDTH;
            GUI.skin.label.wordWrap     = true;

            scrollPos = EditorGUILayout.BeginScrollView(scrollPos);

            EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(width));
            myApiKey = EditorGUILayout.PasswordField("API KEY", myApiKey);
            if (GUILayout.Button("Set API Key", GUILayout.Width(BUTTON_WIDTH)))
            {
                EditorPrefs.SetString(MVSHLF_API_KEY, myApiKey);
                client = new GraphQl.Client(myApiKey);
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Label("Quick search", EditorStyles.boldLabel);
            EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(width));
            myString = EditorGUILayout.TextField("Keywords", myString);
            if (GUILayout.Button("SEARCH", GUILayout.Width(BUTTON_WIDTH)))
            {
                search(myString);
            }
            EditorGUILayout.EndHorizontal();

            GUILayout.Label("Search results", EditorStyles.boldLabel);
            if (searchResults.mocapClips.edges != null)
            {
                foreach (var clip in searchResults.mocapClips.edges)
                {
                    EditorGUILayout.BeginHorizontal(GUILayout.MaxWidth(width));
                    GUILayout.Label(clip.node.title, GUILayout.ExpandWidth(true), GUILayout.MaxWidth(width - 2 * BUTTON_WIDTH));
                    if (GUILayout.Button("import", GUILayout.Width(BUTTON_WIDTH)))
                    {
                        downloadAsset(clip.node.id);
                    }
                    if (GUILayout.Button("preview", GUILayout.Width(BUTTON_WIDTH)))
                    {
                        getClipDetails(clip.node.id);
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }

            GUILayout.Label("Clip info", EditorStyles.boldLabel);
            if (clipDetails.id != null)
            {
                GUILayout.Label("Title: " + clipDetails.title, GUILayout.MaxWidth(width));
                GUILayout.Label("Description: " + clipDetails.description, GUILayout.MaxWidth(width));
                if (GUILayout.Button("See it on Moveshelf.com", GUILayout.Width(width)))
                {
                    Application.OpenURL("https://moveshelf.com/edit/" + clipDetails.id);
                }

                GUILayout.Label("Comments", EditorStyles.boldLabel);
                foreach (var edge in clipDetails.comments.edges)
                {
                    var comment = edge.node.comment;
                    var author  = edge.node.author.displayName;
                    GUILayout.Label(author + ": " + comment);
                }

                myComment = EditorGUILayout.TextField("Comment: ", myComment,
                                                      GUILayout.MaxWidth(width));
                if (GUILayout.Button("Send", GUILayout.Width(width)))
                {
                    createComment(clipDetails.id, myComment);
                }

                GUILayout.Label("Preview image", EditorStyles.boldLabel);
                if (this.clipPreviewImage != null)
                {
                    var aspectRatio = (float)clipPreviewImage.width / clipPreviewImage.height;
                    GUILayout.Label(this.clipPreviewImage,
                                    GUILayout.Width(width), GUILayout.Height(width / aspectRatio));
                }
                else
                {
                    GUILayout.Label("No preview available");
                }
            }

            EditorGUILayout.EndScrollView();
        }
Exemplo n.º 2
0
 void OnEnable()
 {
     //Load API from Environment Variables, if present
     myApiKey = EditorPrefs.GetString(MVSHLF_API_KEY);
     client   = new GraphQl.Client(myApiKey);
 }