할 일


프론트와 회의


Unity Api 통신 회의록


  1. 관련 영상

  2. 관련 문서

  3. 간단 정리

    # Get(url), Post(url, json), Put(url, json), Delete(url)
    UnityWebRequest request = UnityWebRequest.Post(url, json);
    
    # Header에 토큰 넣기 (PlayerPrefs에 저장된 access 토큰)
    request.SetRequestHeader("Authorization", PlayerPrefs.GetString("access"));
    
    # 클래스
    [System.Serializable]
    public class User
    {
    	public string userId;
    	public string userPwd;
    }
    
    # class to json (api 요청할 때 같이 dto처럼 쓰기 위함)
    string json = JsonConvert.SerializeObject(user);
    string json = JsonUtility.ToJson(user);
    
    # 응답 상태
    request.error
    

    Untitled

    # 응답 데이터
    request.downloadHandler.text
    

    Untitled

    # 응답 결과
    request.result
    

    Untitled

    # 응답 코드
    request.responseCode
    
    # 데이터 저장
    PlayerPrefs.SetString("userId", "testing1");
    
    # 데이터 로딩
    PlayerPrefs.GetString("userId");
    
    # bool 값은 SetBool이런게 없기 때문에 int형으로 변환하여 SetInt로 저장한다
    # intToBool(), boolToInt() 함수를 따로 만들어서 사용
    
    # 게임오브젝트 활성화/비활성화 (버튼 클릭에 따른 값 변경 시 사용)
    OOO.gameObject.SetActive(true/false);
    

홈페이지에 대해