반응형

SDL 에는 GUI 기능이 없어 다른 라이브러리를 사용해야 한다. 많은 GUI 라이브러리가 있는데 ImGui 를 확인해 보자.

아래 링크에서 ImGui를 다운로드 한다.

Dear ImGui

 

압축을 풀고 examples - imgui_examples.sln 파일을 실행한다.

 

비주얼 스튜디오 버전이 다르면 프로젝트를 업그레이드 한다.

 

sdlrenderer2를 startup 프로젝트로 설정한다.

 

main.cpp 파일을 확인하자.

 

 

SDL 관련 명령에서 에러가 발생한다.

 

Project Property Pages - Additional Include Directories 에 정확한 SDL Include 디렉토리를 지정한다.

 

Project Property Pages - Additional Library Directories 에 정확한 SDL Library 디렉토리를 지정한다.

 

프로젝트를 빌드한다.

 

실행하면 윈도우에 GUI가 출력된다. (SDL2.dll 파일이 없다는 에러가 발생하면 복사해 넣어준다)

 

 

이번엔 내가 직접 만든 프로젝트에서 ImGui 예제를 실행해 보자.

 

ImGui 라이브러리 디렉토리는 위 그림과 같이 구성 되어 있다.

 

비주얼 스튜디오 프로젝트를 만들고 소스 파일 하나만 추가한다.

 

SDL2.dll 파일을 찾을 수 있도록 환경을 설정한다.

 

SDL과 ImGui에서 사용하는 Include 디렉토리를 설정한다.

 

 

SDL에서 사용하는 Library 디렉토리를 설정한다.

 

SDL에서 사용하는 라이브러리 파일을 설정한다.

 

ImGui, ImGui-Backend 필터를 만들고 ImGui SDL 예제에서 사용하는 파일을 추가한다.

 

처음에 만들어둔 소스 파일에 예제 소스파일(..\imgui-1.90.1\examples\example_sdl2_sdlrenderer2\main.cpp) 내용을 복사하고 빌드한다.

 

 

실행하면 운도우에 GUI가 출력된다.

 

※ 참고

Getting Started

 

반응형
Posted by J-sean
:
반응형

DOTween의 DOPath() 예제


아래와 같은 스크립트를 만든다.

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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
 
public class Tween : MonoBehaviour
{
    public Ease ease;
 
    public Transform wayPoint1;
    public Transform wayPoint2;
    public Transform wayPoint3;
 
    private Vector3[] wayPoints;
 
    // Start is called before the first frame update
    void Start()
    {
        // static DOTween.Init(bool recycleAllByDefault = false, bool useSafeMode = true, LogBehaviour logBehaviour = LogBehaviour.ErrorsOnly)
        // Initializes DOTween.
        DOTween.Init(falsetrue, LogBehaviour.ErrorsOnly);
 
        wayPoints = new Vector3[3];
        wayPoints.SetValue(wayPoint1.position, 0);
        wayPoints.SetValue(wayPoint2.position, 1);
        wayPoints.SetValue(wayPoint3.position, 2);
        // wayPoints = new[] { wayPoint1.position, wayPoint2.position, wayPoint3.position };
 
        // DOPath(Vector3[] waypoints, float duration, PathType pathType = Linear, PathMode pathMode = Full3D, int resolution = 10, Color gizmoColor = null)
        // Tweens a Transform's position through the given path waypoints, using the chosen path algorithm.
        transform.DOPath(wayPoints, 6.0f, PathType.CatmullRom).SetLookAt(new Vector3(0.0f, 0.0f, 0.0f)).SetEase(ease).SetLoops(-1, LoopType.Yoyo);
    }
 
    // Update is called once per frame
    void Update()
    {
 
    }
}
 


스크립트 이름은 Tween으로 지정 한다.


Empty Object(WayPoint)와 Cube를 생성하고 Cube에 Tween 스크립트를 추가한다.


Empty Object를 3개 생성하고 WayPointX로 이름을 바꿔서 Cube가 이동할 위치에 배치한다. Cube Inspector 창의 Tween 스크립트에서 Way Point1~3 변수에 WayPoint1~3 오브젝트를 지정한다. Ease 변수도 In Bounce 등 원하는 ease로 변경한다.


플레이 버튼을 클릭 하면 Cube가 지정한 위치들을 거쳐 이동 한다. DOPath()의 경우 Scene창에 이동 경로가 표시 된다.


반응형
Posted by J-sean
: