コード例 #1
0
 void CreateFileOverviews(FilePageResJson filePageResJson)
 {
     foreach (FileJson fileJson in filePageResJson.file_list)
     {
         if (email != null && !email.Equals(WebReq.email) && fileJson.anonymous)
         {
             continue;
         }
         GameObject   fileOverviewPanel = Instantiate(fileOverviewPanelPrefab, filePanel.transform);
         FileOverview fileOverview      = fileOverviewPanel.GetComponent <FileOverview>();
         fileOverview.Init(fileJson);
     }
 }
コード例 #2
0
    IEnumerator AdminRequestFilesCoro()
    {
        //Startrank is (currentPageNum-1)*FilesPerPage, Range is files per page
        string authorEmail = email;

        string sortingMethod = null; //default is timeASC

        switch (sortMethodDropdown.value)
        {
        case 0:
            sortingMethod = "timeDESC";
            break;

        case 1:
            sortingMethod = "nameDESC";
            break;

        case 2:
            sortingMethod = "downloadsDESC";
            break;

        case 3:
            sortingMethod = "likesDESC";
            break;

        case 4:
            sortingMethod = "rateDESC";
            break;
        }

        string filterType = null; //default is null

        switch (filterDropdown.value)
        {
        case 1:
            filterType = "Visual Mods";
            break;

        case 2:
            filterType = "UI Mods";
            break;

        case 3:
            filterType = "Game logic Mods";
            break;
        }

        string filterTime = null; //default is null

        switch (timeDropdown.value)
        {
        case 1:
            filterTime = "oneday";
            break;

        case 2:
            filterTime = "threemonths";
            break;

        case 3:
            filterTime = "oneyear";
            break;
        }

        string searchKeyword = keyword;

        bool searchByContributor = searchByContributorToggle.isOn;

        int startRank = StartRank();

        using (UnityWebRequest www = UnityWebRequest.Post(WebReq.serverUrl + "file/listAll", new WWWForm()))
        {
            Debug.Log(JsonUtility.ToJson(new FilePageReqJson(email, sortingMethod, filterType, filterTime, searchKeyword, searchByContributor, startRank, rateFromDropdown.value, rateToDropdown.value + 1)).Replace("\"\"", "null"));
            byte[] ReqJson = System.Text.Encoding.UTF8.GetBytes(
                JsonUtility.ToJson(new FilePageReqJson(email, sortingMethod, filterType, filterTime, searchKeyword, searchByContributor, startRank, rateFromDropdown.value, rateToDropdown.value + 1)).Replace("\"\"", "null")
                );

            www.uploadHandler = new UploadHandlerRaw(ReqJson);
            www.SetRequestHeader("Content-Type", "application/json");

            yield return(www.SendWebRequest());

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log(www.error);
            }
            else
            {
                Debug.Log(www.downloadHandler.text);

                FilePageResJson res = JsonUtility.FromJson <FilePageResJson>(www.downloadHandler.text);
                Debug.Log(JsonUtility.ToJson(res));
                numFiles = res.total_files;
                CreateFileOverviews(res);
                SaveCache();

                UpdateIndex();
            }
        }
    }