Ejemplo n.º 1
0
        void PopulateAssets(string search = null)
        {
            LootLockerSDKAdminManager.DebugMessage("Getting assets..");

            currentView = LootLockerView.Loading;

            LootLockerSDKAdminManager.GetAssets((response) =>
            {
                LootLockerSDKAdminManager.GetContexts((contextResponse) =>
                {
                    if (contextResponse.success)
                    {
                        Contexts     = contextResponse.Contexts;
                        ContextNames = Contexts.Select(x => x.name).ToArray();
                        LootLockerSDKAdminManager.DebugMessage("Successful got all contexts: " + contextResponse.text);
                    }
                    else
                    {
                        LootLockerSDKAdminManager.DebugMessage("failed to get all contexts: " + contextResponse.Error, true);
                    }

                    if (response.success)
                    {
                        assetsResponse = response;
                        currentView    = LootLockerView.Assets;
                        Repaint();
                        LootLockerSDKAdminManager.DebugMessage("Successful got all assets: " + response.text);
                    }
                    else
                    {
                        LootLockerSDKAdminManager.DebugMessage("failed to get all assets: " + response.Error, true);
                    }
                });
            }, search);
        }
Ejemplo n.º 2
0
        void DrawCreateFileView()
        {
            GUILayout.BeginArea(ContentSection);

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("Asset name: ");
            assetName = EditorGUILayout.TextField(assetName);

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("Asset Context ID: ");

            activeAsset = assetsResponse.assets[0];

            AssetContextIndex   = EditorGUILayout.Popup(AssetContextIndex, ContextNames);
            activeAsset.context = Contexts[AssetContextIndex].name;

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();

            EditorGUILayout.BeginHorizontal();

            EditorGUILayout.LabelField("Tags");

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.LabelField("saperated by comma", new GUIStyle(GUI.skin.label)
            {
                fontSize = 10
            });
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();

            FileTags = EditorGUILayout.TextField(FileTags);

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();
            EditorGUILayout.Separator();

            EditorGUILayout.BeginHorizontal();

            if (GUILayout.Button(string.IsNullOrEmpty(filePath) ? "Attach File" : "Choose a different file", GUILayout.Height(30), GUILayout.MaxWidth(200)))
            {
                filePath = EditorUtility.OpenFilePanel("Choose a file", "", "");
            }

            if (string.IsNullOrEmpty(filePath))
            {
                EditorGUILayout.Separator();
                EditorGUILayout.Separator();

                EditorGUILayout.LabelField("You must attach a file to be able to upload",
                                           new GUIStyle(GUI.skin.label)
                {
                    fontSize = 12, fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleLeft
                },
                                           GUILayout.MaxWidth(1000), GUILayout.Height(25));
            }
            else
            {
                EditorGUILayout.LabelField("File name: " + Path.GetFileName(filePath),
                                           new GUIStyle(GUI.skin.label)
                {
                    fontSize = 12, fontStyle = FontStyle.Bold, alignment = TextAnchor.MiddleLeft
                },
                                           GUILayout.MaxWidth(1000), GUILayout.Height(25));

                EditorGUILayout.EndHorizontal();

                EditorGUILayout.Separator();
                EditorGUILayout.Separator();

                EditorGUILayout.BeginHorizontal();

                if (GUILayout.Button("Upload", GUILayout.Height(30)))
                {
                    currentView = LootLockerView.Loading;

                    var request = new LootLockerCreateAssetRequest()
                    {
                        name = assetName, context_id = Contexts[Array.IndexOf(ContextNames, activeAsset.context)].id
                    };

                    LootLockerSDKAdminManager.CreateAsset(request, (response) =>
                    {
                        if (response.success)
                        {
                            Debug.LogError("Asset created successfully. Uploading file..");

                            LootLockerSDKAdminManager.GetAssets((getAssetsResponse) =>
                            {
                                if (getAssetsResponse.success)
                                {
                                    Debug.Log("Successfully got uploaded asset: " + getAssetsResponse.text);

                                    LootLockerCommonAsset uploadedAsset = getAssetsResponse.assets[0];

                                    LootLockerSDKAdminManager.UploadAFile(filePath, uploadedAsset.id.ToString(), LootLockerAdminConfig.current.gameID, (uploadResponse) =>
                                    {
                                        if (uploadResponse.success)
                                        {
                                            Debug.Log("Successfully uploaded file: " + uploadResponse.text);
                                            PopulateFiles();
                                        }
                                        else
                                        {
                                            Debug.LogError("Failed to upload file: " + uploadResponse.Error);
                                            currentView = LootLockerView.CreateFile;
                                        }
                                    }, tags: FileTags.Split(','));
                                }
                                else
                                {
                                    Debug.LogError("Failed to get assets: " + getAssetsResponse.Error);
                                    currentView = LootLockerView.CreateFile;
                                }
                            });
                        }
                        else
                        {
                            Debug.LogError("failed to get create/update asset: " + response.Error);
                            currentView = LootLockerView.CreateFile;
                        }
                    });
                }
            }

            EditorGUILayout.EndHorizontal();

            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();
            EditorGUILayout.Separator();

            if (GUILayout.Button("Back", GUILayout.Height(20)))
            {
                PopulateFiles();
            }

            GUILayout.EndArea();
        }
Ejemplo n.º 3
0
        void PopulateFiles()
        {
            Debug.Log("Getting files..");
            LootLockerSDKAdminManager.GetFiles(LootLocker.Admin.Requests.LootLockerFileFilterType.none, (response) =>
            {
                Debug.Log("files on complete");
                if (response.success)
                {
                    LootLockerSDKAdminManager.GetAssets((assetssResponse) =>
                    {
                        LootLockerSDKAdminManager.GetContexts((contextResponse) =>
                        {
                            if (contextResponse.success)
                            {
                                Contexts     = contextResponse.Contexts;
                                ContextNames = Contexts.Select(x => x.name).ToArray();
                                Debug.Log("Successful got all contexts: " + contextResponse.text);
                            }
                            else
                            {
                                Debug.LogError("failed to get all contexts: " + contextResponse.Error);
                            }

                            if (assetssResponse.success)
                            {
                                assetsResponse = assetssResponse;
                                Debug.Log("Successful got all assets: " + response.text);
                            }
                            else
                            {
                                Debug.LogError("failed to get all assets: " + response.Error);
                            }
                        });
                    });

                    getFilesResponse = response;
                    currentView      = LootLockerView.Files;
                    Repaint();
                    Debug.Log("Successful got all files: " + response.text);
                }
                else
                {
                    Debug.LogError("failed to get all files: " + response.Error);
                }

                // getFilesResponse = new GetFilesResponse()
                // {
                //     success = true,
                //     files = new File[]
                //     {
                //         new File()
                //         {
                //             name = "testName1",
                //             id = 2,
                //         },
                //         new File()
                //         {
                //             name = "testName2",
                //             id = 3,
                //             tags = new string[]{"tag1" , "tag2" , "tag3" },
                //         },
                //         new File()
                //         {
                //             name = "testName3",
                //             id = 4,
                //         },
                //         new File()
                //         {
                //             name = "testName4",
                //             id = 5,
                //             tags = new string[]{"tag1" , "tag2"  },
                //         },
                //         new File()
                //         {
                //             name = "testName5",
                //             id = 6,
                //         },

                //     }
                // };

                // currentView = View.Files;
                // Repaint();
                // DestroyImmediate(ServerAPI.Instance.gameObject);
                // ServerAPI.ResetManager();
                // Debug.Log("Successful got all files: " + response.text);
            });
        }