이미지 정리 및 검색 코드작업
This commit is contained in:
parent
0feb2e8aaf
commit
22cd21f449
File diff suppressed because it is too large
Load Diff
|
|
@ -11,15 +11,12 @@ public class Common : MonoBehaviour
|
|||
[SerializeField] TMP_Dropdown dRegion;
|
||||
//내부 저장 기능 만들기
|
||||
//버전 기능 까지 만들어서 버전 체크후 새로 다운받아오게 만들기.
|
||||
List<CommonData> animalTypes;
|
||||
List<CommonData> suitStyle;
|
||||
List<CommonData> suitType;
|
||||
List<CommonData> region;
|
||||
|
||||
void Start()
|
||||
{
|
||||
NetworkManager.Instance.CreateRequest<List<CommonData>>("common/animalTypes", new object(), (data) =>
|
||||
{
|
||||
animalTypes = data;
|
||||
GameManager.Instance.animalTypes = data;
|
||||
List<string> strings = new List<string>();
|
||||
for(int n = 0; n < data.Count; n++)
|
||||
{
|
||||
|
|
@ -29,7 +26,7 @@ public class Common : MonoBehaviour
|
|||
}, null, BestHTTP.HTTPMethods.Get);
|
||||
NetworkManager.Instance.CreateRequest<List<CommonData>>("common/suitStyle", new object(), (data) =>
|
||||
{
|
||||
suitStyle = data;
|
||||
GameManager.Instance.suitStyle = data;
|
||||
List<string> strings = new List<string>();
|
||||
for (int n = 0; n < data.Count; n++)
|
||||
{
|
||||
|
|
@ -39,7 +36,7 @@ public class Common : MonoBehaviour
|
|||
}, null, BestHTTP.HTTPMethods.Get);
|
||||
NetworkManager.Instance.CreateRequest<List<CommonData>>("common/suitType", new object(), (data) =>
|
||||
{
|
||||
suitType = data;
|
||||
GameManager.Instance.suitType = data;
|
||||
List<string> strings = new List<string>();
|
||||
for (int n = 0; n < data.Count; n++)
|
||||
{
|
||||
|
|
@ -49,7 +46,7 @@ public class Common : MonoBehaviour
|
|||
}, null, BestHTTP.HTTPMethods.Get);
|
||||
NetworkManager.Instance.CreateRequest<List<CommonData>>("common/region", new object(), (data) =>
|
||||
{
|
||||
region = data;
|
||||
GameManager.Instance.region = data;
|
||||
List<string> strings = new List<string>();
|
||||
for (int n = 0; n < data.Count; n++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -10,9 +10,8 @@ public class ScreenMove : MonoBehaviour
|
|||
readonly Vector2 stretch = new Vector2(0f, 0.5f);
|
||||
readonly Vector2 middle = new Vector2(1f, 0.5f);
|
||||
readonly Vector2 center = new Vector2(0.5f, 0.5f);
|
||||
readonly Vector2 movePos = new Vector2(-58.5f, 20f);
|
||||
readonly Vector2 pos = new Vector2(-58.5f, 20f);
|
||||
readonly Vector2 moveSize = new Vector2(-343f, 100f);
|
||||
readonly Vector2 idlePos = new Vector2(-58.5f, 20f);
|
||||
readonly Vector2 idleSize = new Vector2(553f, 100f);
|
||||
bool isMobile;
|
||||
void Awake()
|
||||
|
|
@ -26,6 +25,20 @@ public class ScreenMove : MonoBehaviour
|
|||
if (isMobile)
|
||||
{
|
||||
rectTransform.sizeDelta = new Vector2(Screen.width, Screen.height);
|
||||
if (Screen.width < 1280)
|
||||
{
|
||||
test_rectTransform.anchorMin = center;
|
||||
test_rectTransform.anchorMax = center;
|
||||
test_rectTransform.anchoredPosition = pos;
|
||||
test_rectTransform.sizeDelta = idleSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
test_rectTransform.anchorMin = stretch;
|
||||
test_rectTransform.anchorMax = middle;
|
||||
test_rectTransform.anchoredPosition = pos;
|
||||
test_rectTransform.sizeDelta = moveSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -35,23 +48,20 @@ public class ScreenMove : MonoBehaviour
|
|||
if (!isMobile)
|
||||
{
|
||||
rectTransform.sizeDelta = new Vector2(Screen.width, Screen.height);
|
||||
//1280
|
||||
//Debug.Log($"{Screen.width} : {Screen.height}");
|
||||
if (Screen.width < 1280)
|
||||
{
|
||||
test_rectTransform.anchorMin = center;
|
||||
test_rectTransform.anchorMax = center;
|
||||
test_rectTransform.anchoredPosition = idlePos;
|
||||
test_rectTransform.anchoredPosition = pos;
|
||||
test_rectTransform.sizeDelta = idleSize;
|
||||
}
|
||||
else
|
||||
{
|
||||
test_rectTransform.anchorMin = stretch;
|
||||
test_rectTransform.anchorMax = middle;
|
||||
test_rectTransform.anchoredPosition = movePos;
|
||||
test_rectTransform.anchoredPosition = pos;
|
||||
test_rectTransform.sizeDelta = moveSize;
|
||||
}
|
||||
//Debug.Log($"{test_rectTransform.anchoredPosition} : {test_rectTransform.sizeDelta}");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,13 +1,137 @@
|
|||
using Newtonsoft.Json.Linq;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class SearchCtrl : MonoBehaviour
|
||||
{
|
||||
[SerializeField] GameObject opsion;
|
||||
|
||||
[SerializeField] TMP_InputField name;
|
||||
[SerializeField] TMP_Dropdown suitStyle;
|
||||
[SerializeField] TMP_Dropdown suitType;
|
||||
[SerializeField] TMP_Dropdown region;
|
||||
[SerializeField] TMP_Dropdown animalTypes;
|
||||
[SerializeField] Toggle[] colors;
|
||||
[SerializeField] Sprite[] isOnSprite;
|
||||
|
||||
private SearchRequest request;
|
||||
private List<Library> librarys;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
opsion.SetActive(false);
|
||||
}
|
||||
|
||||
public void OpsionButton()
|
||||
{
|
||||
opsion.SetActive(!opsion.activeSelf);
|
||||
ResetButton();
|
||||
}
|
||||
|
||||
public void SearchButton()
|
||||
{
|
||||
Debug.Log("검색 시작");
|
||||
request = new SearchRequest();
|
||||
request.fursuitName = name.text;
|
||||
if (suitStyle.value != 0)
|
||||
request.suitStyle = GameManager.Instance.suitStyle[suitStyle.value - 1].code_id;
|
||||
if (suitType.value != 0)
|
||||
request.suitType = GameManager.Instance.suitType[suitType.value - 1].code_id;
|
||||
if (region.value != 0)
|
||||
request.suitRegion = GameManager.Instance.region[region.value - 1].code_id;
|
||||
if (animalTypes.value != 0)
|
||||
request.suitAnimalType = GameManager.Instance.animalTypes[animalTypes.value - 1].code_id;
|
||||
NetworkManager.Instance.CreateRequest<SearchResponse>("library/select/suiters", request, (data) =>
|
||||
{
|
||||
librarys = data.data;
|
||||
for(int n = 0; n < data.data.Count; n++)
|
||||
{
|
||||
Debug.Log($"name : {data.data[n].suit_name}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void NextSearch()
|
||||
{
|
||||
request.page++;
|
||||
NetworkManager.Instance.CreateRequest<SearchResponse>("library/select/suiters", request, (data) =>
|
||||
{
|
||||
librarys.AddRange(data.data);
|
||||
for (int n = 0; n < data.data.Count; n++)
|
||||
{
|
||||
Debug.Log($"name : {data.data[n].suit_name}");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void GetImage(int velue)
|
||||
{
|
||||
NetworkManager.Instance.CreateImageRequest(librarys[velue].imageBase64.Substring(1), new object(), (data) =>
|
||||
{
|
||||
librarys[velue]._suit_image = Sprite.Create(data, new Rect(0, 0, data.width, data.height), new Vector2(0.5f, 0.5f));
|
||||
}, null, BestHTTP.HTTPMethods.Get);
|
||||
}
|
||||
|
||||
public void ResetButton()
|
||||
{
|
||||
suitStyle.value = 0;
|
||||
suitType.value = 0;
|
||||
region.value = 0;
|
||||
animalTypes.value = 0;
|
||||
for(int n = 0; n < colors.Length; n++)
|
||||
{
|
||||
colors[n].isOn = false;
|
||||
colors[n].image.sprite = isOnSprite[0];
|
||||
}
|
||||
}
|
||||
|
||||
public void OnToggle(int velue)
|
||||
{
|
||||
colors[velue].image.sprite = isOnSprite[(colors[velue].isOn ? 1 : 0)];
|
||||
}
|
||||
}
|
||||
|
||||
public class SearchRequest
|
||||
{
|
||||
public int xid;
|
||||
public string fursuitName = ""; /*오너,슈트 이름*/
|
||||
public string suitMaker; /*사용안함*/
|
||||
public string suitRegion = ""; /*활동 국가*/
|
||||
public string suitStyle = ""; /*슈트 스타일*/
|
||||
public string suitAnimalType = ""; /*슈트 동물 종*/
|
||||
public string suitType = ""; /*슈트 형태*/
|
||||
public List<string> colorList = new List<string>(); /*슈트 색상*/
|
||||
public int page = 1;
|
||||
public int size = 5;
|
||||
public int offset = 0;
|
||||
}
|
||||
public class SearchResponse
|
||||
{
|
||||
public List<Library> data;
|
||||
public bool hasMore;
|
||||
}
|
||||
public class ImageResponse
|
||||
{
|
||||
public byte[] imageBytes;
|
||||
}
|
||||
|
||||
public class Library
|
||||
{
|
||||
public string imageBase64;
|
||||
public string suit_name;
|
||||
public string owner_id;
|
||||
public string owner_name;
|
||||
public string production_date;
|
||||
public string suit_image;//사용안함
|
||||
public Sprite _suit_image;
|
||||
public string maker;
|
||||
public string region;
|
||||
public string animal_type;
|
||||
public string suit_style;
|
||||
public string suit_type;
|
||||
public List<string> suit_color;
|
||||
}
|
||||
|
|
@ -1,4 +1,11 @@
|
|||
|
||||
using static Common;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class GameManager : DontDestroy<GameManager>
|
||||
{
|
||||
public List<CommonData> animalTypes;
|
||||
public List<CommonData> suitStyle;
|
||||
public List<CommonData> suitType;
|
||||
public List<CommonData> region;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,9 +16,8 @@ public class NetworkManager : SingletonMonoBehaviour<NetworkManager>
|
|||
/// <param name="onRequestFinished">데이터 받은 후 처리할 절차</param>
|
||||
/// <param name="serializeData">전송할 데이터, null로 넣으면 안보냅니다.</param>
|
||||
/// <param name="methods">동작방식</param>
|
||||
/// <param name="codec">암복호화 할 것인지</param>
|
||||
/// <returns>역직렬화된 데이터 or 기본값(반환 받지 못함)</returns>
|
||||
public HTTPRequest CreateRequest<T>(string api, object serializeData, Action<T> onSuccess, Action<T>onFail = null, HTTPMethods methods = HTTPMethods.Post)
|
||||
public HTTPRequest CreateRequest<T>(string api, object serializeData, Action<T> onSuccess, Action<T> onFail = null, HTTPMethods methods = HTTPMethods.Post)
|
||||
{
|
||||
string url = $"{baseUrl}{api}".Replace("\\p{Z}", String.Empty);
|
||||
|
||||
|
|
@ -43,6 +42,34 @@ public class NetworkManager : SingletonMonoBehaviour<NetworkManager>
|
|||
httpRquest.RawData = System.Text.Encoding.UTF8.GetBytes(json);
|
||||
}
|
||||
|
||||
httpRquest.Send();
|
||||
return httpRquest;
|
||||
}
|
||||
public HTTPRequest CreateImageRequest(string api, object serializeData, Action<Texture2D> onSuccess, Action<Texture2D> onFail = null, HTTPMethods methods = HTTPMethods.Post)
|
||||
{
|
||||
string url = $"{baseUrl}{api}".Replace("\\p{Z}", String.Empty);
|
||||
|
||||
var httpRquest = new HTTPRequest(new Uri(url) //url ³Ö±â
|
||||
, methods //µ¿ÀÛ ¹æ½Ä ³Ö±â
|
||||
, (request, response) => {
|
||||
if (response == null || (response.StatusCode != 200))
|
||||
{
|
||||
onFail?.Invoke(null);
|
||||
}
|
||||
else
|
||||
{
|
||||
Texture2D deSerialized = response.DataAsTexture2D;
|
||||
onSuccess?.Invoke(deSerialized);
|
||||
}
|
||||
});
|
||||
|
||||
if (serializeData != null)
|
||||
{
|
||||
httpRquest.SetHeader("Content-Type", "application/json; charset=UTF-8");
|
||||
string json = JsonConvert.SerializeObject(serializeData);
|
||||
httpRquest.RawData = System.Text.Encoding.UTF8.GetBytes(json);
|
||||
}
|
||||
|
||||
httpRquest.Send();
|
||||
return httpRquest;
|
||||
}
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 14 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 1.5 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 795 B |
Binary file not shown.
|
After Width: | Height: | Size: 1.1 KiB |
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue