본문 바로가기

분류 전체보기

(111)
프로젝트 1-1 플레이어 이동 using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMove : MonoBehaviour { public float speed = 5f; void Update() { float h = Input.GetAxisRaw("Horizontal"); float v = Input.GetAxisRaw("Vertical"); Vector3 dir = Vector3.right * h + Vector3.up * v; //dir의 크기가 1이 아닌 경우가 있음 -> 크기를 1로 만들 때 정규화 dir.Normalize(); transform.position += dir * speed * Time.del..
Instantiate public class LeaderBoard : MonoBehaviour { public GameObject goRankBar; public GameObject goLastRankBar; public int count; public Transform rankBarParent; void OnEnable() { for (int i = 0; i < 50; i++) { GameObject rankBar = Instantiate(goRankBar, transform.position, Quaternion.identity); rankBar.transform.SetParent(rankBarParent); if(i == 49) { GameObject lastRankBar = Instantiate(goLastRankBar..
Scroll View 처음 부분부터 보이게 하기 public class MyScoreBoard : MonoBehaviour { public RectTransform a; void OnEnable() { a.anchoredPosition = new Vector2(0, 0); } } a는 Scroll View /View Port 안에 있는 Content를 참조했다. Scroll View 오브젝트가 켜질 때마다 처음 부분부터 보이게 하기 위해 OnEnable 에 작성했다.
Firebase 저장, 불러오기, 정렬 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngi..
C# Dicationary to Json 123456789101112131415using System.Collections;using System.Collections.Generic;using System.Linq; Dictionary example = new Dictionary();example.Add("abc", 100); string MyDictionaryToJson(Dictionary dict) { var entries = dict.Select(d => string.Format("\"{0}\": {1}", d.Key, string.Join(",", d.Value))); return "{" + string.Join(",", entries) + "}"; } print(MyDictionaryToJson(example));Colored by C..
유니티 자동 로그인 및 닉네임 생성창 저번 포스팅에서 구글 연동 후 로그인하는 것까지 다뤄봤다. 이번 포스팅은 구글 자동로그인과 닉네임 생성을 하는 것을 다뤄보겠다. 우선 firebase SDK - dotnet4 폴더 안에 있는 FirebaseDatabase.unitypackage를 import 해주자. 유저의 구글ID 과 닉네임을 불러오고, 만약에 닉네임이 없을 때 닉네임을 생성할 수 있는 창을 만들어주기 위해서 데이터베이스를 사용할 것이다. 구글 로그인을 할 때 PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder().RequestIdToken() 이 구문으로 IDToken을 요청한다. 아마 이게 로그인할 때 IDToken을 요청한다는 그런 뜻인 것 ..
유니티 구글 연동 방법 1. Firebase SDK import 하기 https://firebase.google.com/docs/unity/setup Unity 프로젝트에 Firebase 추가 Unity 프로젝트에 Firebase 추가plat_iosplat_androidplat_unity Firebase Unity SDK를 활용하여 Unity 게임을 업그레이드 해보세요. Firebase를 Unity 프로젝트에 연결하는 것이 얼마나 간편한지 보여드리기 위해 Google firebase.google.com Firebase unity SDK - dotnet4 폴더 안에 있는 FirebaseAnalytics.unitypackage 와 FirebaseAuth.unitypackage를 유니티에 임포트 시킨다. GPGS 보다 먼저 임포트 ..