2021년 2월 13일 토요일

[Unity3d] 2d 게임 제작해보자 - scene

간단한 2D게임이라도 만들어 보자.

일단 구글링해서 찾은 사이트에서 그림을 다운받고, 2D 게임 프로젝트를 생성해서 Assets/Images 폴더에 넣자. 
https://blog.naver.com/fightingdog/220034264831

1.Charactor 이미지를 선택후 , Inspector에서 Texture Type을  Sprite(2D and UI)로 한다. 
  • Texture Type : https://docs.unity3d.com/kr/2018.4/Manual/class-TextureImporter.html 
  • Sprite Mode : 여러 이미지가 있으면 Multiple
  • Pixels Per Unit : 개발화면의 1Unit(한칸)이 몇픽셀일까를 정함. 100인데 32pixel짜리를 넣으면 한칸의 1/3 에 표시됨. dot 이미지라면 1로   함.
  • Max Size : Opengl 에서는 texutre size가 한계가 있다. 2048 이면  된다
2.스프라이트를 슬라이스해서 각각은 작은 스프라이트로 써먹을수 있게 하자. 여기선 32:48 사이즈이고 Offset 2, padding2  다. 이름은 귀찮으니 그냥 둔다.

3.여러개 묶어서 씬에 드롭하면 애니메이션으로 만들수 있다.

일단 씬전환은 
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
public class NewBehaviourScript : MonoBehaviour
{
    // Start is called before the first frame update
    void Start()
    {
        
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonUp(0))
        {
            UnityEngine.SceneManagement.SceneManager.LoadScene("SampleScene");
        }
    }
}


4. ui버튼을 추가해서 입력한 스크립트의 지정된 함수를 실행해서 화면전환을 할수 있따.
https://github.com/sugoigroup/unity_study_1/commit/891fca44e7573d535f319f1a260abd3e1eb1431e

5.하나의 화면에 보이는 Scene 은 여러개를 겹쳐서 작업할수 있다. 배경 씬 작업자 따로 캐릭터 작업자 따로 작업해서 나중에 합칠수도 있다.
 https://github.com/sugoigroup/unity_study_1/commit/94cd5b795f26d37776628dcb51dfa70f7719c236




0 comments:

댓글 쓰기