목록유니티/개발 (32)
안 쓰던 블로그
//GameManager스크립트에 GetnewImage(int num) 함수가 있음 using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class Box1Manager : MonoBehaviour { public GameManager gm; // Start is called before the first frame update void Start() { gameObject.GetComponent().sprite = gm.GetnewImage(1); //오브젝트 찾지 못함 에러 } public void OnClickBox() { gameObject.GetCompone..
public Sprite GetnewImage(int num) { int randomQuestionIndex; if (num == 1) { randomQuestionIndex = Random.Range(0, box1.Length); return box1[randomQuestionIndex]; } else if (num == 2) { randomQuestionIndex = Random.Range(0, box2.Length); return box2[randomQuestionIndex]; } else if (num == 3) { randomQuestionIndex = Random.Range(0, box3.Length); return box3[randomQuestionIndex]; } else if (num =..
void setmix(int index, GameObject image) { float x = mixposition[index, 0]; float y = mixposition[index, 1]; float z = mixposition[index, 2]; image.transform.position = new Vector3(x, y, z); //image.transform.localPosition = new Vector3(x,y,z); Debug.Log(image.transform.position); print(x); print(y); print(z); } 유니티에서 오브젝트를 순간이동 시키려면 보통 vector3로 transform.position에다가 값을 넣을 것임 근데 내 프로젝트에서 image를 ..
유니티에서 서브 디렉토리를 만들 때 특정 이름으로 만들면 특별한 작동을 한다 Resources라는 이름의 폴더가 있다면, 그 폴더 안의 리소스를 불러오는 함수를 쓸 수 있다 Resources 폴더를 새로 만들어서 안에 이미지 파일을 넣었다 테스트를 위한 버튼 하나를 만들어서 스크립트를 붙였다 public class Box1Manager : MonoBehaviour { object[] sprites; // Start is called before the first frame update void Start() { sprites = Resources.LoadAll("1_LikeLove"); for (int i = 0; i < sprites.Length; i++) { GameObject go = sprites..