UICamera.mainCamera.ScreenToWorldPoint(Input.mousePosition);

mousepoisiton.z = 0;

'Unity' 카테고리의 다른 글

Unity 모바일 시스템 언어 갖고오기  (0) 2015.08.05
NGUI DropDown Menu 만들기  (0) 2015.08.05
Update, LateUpdate 차이  (0) 2015.07.22
Unity Linq  (0) 2015.07.13
NGUI 공식 Tutorial 정리  (0) 2015.07.03

Update : Update는 프레임마다 한 번씩 호출됩니다. 이것은 프레임의 업데이트에 대한 주요 기능입니다. 

LateUpdate : LateUpdate()는 Update() 후 프레임마다 한 번씩 호출됩니다. Update()에서 수행되는 계산이 완료되면 LateUpdate() 함수가 시작 합니다. LateUpdate()의 일반적인 사용은 다음의 3인칭 카메라입니다. Update()에서 캐릭터를 이동하고 회전시킬 경우 LateUpdate()에서 카메라의 이동과 회전 계산을 수행할 수 있습니다. 이렇게하면 캐릭터가 카메라가 그 위치를 추적하기 전에 완전히 이동합니다.



http://docs.unity3d.com/kr/current/Manual/ExecutionOrder.html


'Unity' 카테고리의 다른 글

NGUI DropDown Menu 만들기  (0) 2015.08.05
Mouse좌표를 NGUI 카메라 좌표로 바꾸는 법  (0) 2015.07.24
Unity Linq  (0) 2015.07.13
NGUI 공식 Tutorial 정리  (0) 2015.07.03
animator에 붙어있는 animation의 재생여부  (0) 2015.06.11

https://github.com/RyotaMurohoshi/UniLinq

UniLinq.unitypakage를 사용하여 사용하면 됨

그러면 ios 관련 버그들 해결

 

쟤를 쓰고 싶지 않다면

http://qiita.com/RyotaMurohoshi/items/d3a2068f1ad787325ec0

http://qiita.com/RyotaMurohoshi/items/6fb02e50d9e08b487f47

http://qiita.com/RyotaMurohoshi/items/a789e6965c6de3d6e31f

참고

일본어임 약간 구글번역이 요상함

'Unity' 카테고리의 다른 글

Mouse좌표를 NGUI 카메라 좌표로 바꾸는 법  (0) 2015.07.24
Update, LateUpdate 차이  (0) 2015.07.22
NGUI 공식 Tutorial 정리  (0) 2015.07.03
animator에 붙어있는 animation의 재생여부  (0) 2015.06.11
GridMove  (0) 2015.06.10

Tutorial1

NGUI-OPEN-PREFAB TOOLBAR

 

Atlas Maker : stats의 draw calls를 보면서 넣을 것 같은 아틀라스에 있어도 줄지 않는 경우가 있음 그럴 경우는 분리

DrawCall Tool : NGUI가 그리는 draw call 체크 가능

Font Maker : Atlas 이미지로 Font이미지 파일을 만들어줌

 

Tutorial2

PhysicsManager에서 Raycasts Hit Trigger 체크

체크 안하면 클릭이벤트 사용 불가능

 

Git 사용시 최신 버전을 pull 한뒤

File->New Scene

Delete the NGUI folder form the Project View

Import NGUI from the updated Unity Pakage

해서 사용할 것

ReadMe File 안에 사용방법 들어있음

 

UIRoot 밑에 모든 NGUI 모여야 함

alt – shift – s : sprite 만드는 단축키

Unity Font는 dynamic font

depth 관리는 widget에 나와있음

ancherrhksfl 잘 해주면 리사이즈 해도 구석에 잘 붙어있음

계속 쓸 UI는 Prefab Tool 로 끌어다 넣으면 Prefab 으로 저장되고 바로 쓸 수 있음

NGUI->Selection 보면 Depth를 어떻게 정할지 나옴, 오른쪽 클릭해도 나옴

오른쪽 클릭하면 바로 child로 만들수도 있고 같은 레벨로 만들수도 있음

box collider랑 tween도 바로 접근 가능

docu도 바로 연결해주니 잘 써봅시다

 

Tutorial3

Button 만들려면 일단 Box collider부터 붙이고 Button Script붙일 것

Hover = 마우스오버

Text도 Button Script를 연결하면 예뻐짐

OnClick에 필요한 함수 스크립트를 붙인 object를 넣어주고 설정해서 불러옴

참조 : http://euna501.tistory.com/search/onclick

 

Tween은 스크립트 이름 오른쪽 클릭하면 Set to or Set from 뜸 알아서 적절히 사용할 것

Tween Height, Tween Width 둘다 있음

만약에 다른 버튼과 연계되는 이벤트라면 Event Trigger를 통해서 접근할 것

그래야 시작과 동시에 재생이 안됨

순서를 정하고 싶으면 OnFinished를 이용함

Animation으로 만들어도 됨

 

keyboard로 조절하고 싶으면 UIKeyBinding 사용

KeyCoard Return == Enter

 

InputField에 UIKeyBinding Return 에 Select 하면 엔터치면 바로 입력 가능함

OnSubmit 항목에 작성하고 나면 할 action을 정할 수 있음

 

UIKey Navigation을 설정하면 키보드 화살표로 조절할 수 있게 됨

 

UISlider에는 OnValue Change 항복이 있음 조절해주면 됨

 

Tutorial4

Scroll View 오른쪽 클릭 drag scroll view 하면 object가 scrollView 밖으로 벗어나지 않음

모두 scroll view child로 들어가야 함

invisible widget 영역을 설정해 영역 내를 클릭하면 스크롤 되도록 설정도 가능

container에 scrollview를 설정하고 drag scroll view

 

UICamera debug옵션을 켜면 게임뷰에서 raycast hit을 확인 할 수 있음

 

Panel은 뭔가 맨 앞에 있어야 하는 것을 넣어놓으면 됨

 

drag drop root 를 설정하고 grid를 설정해

tween을 체크하면 움직임이 더 예뻐지고

sorting을 설정하면 다시 원위치로 돌아옴

drag drop container를 사용하면 parent를 옮길 수 있음

 

Tutorial5

UILocalize key넣으면 적절하게 때마다 바꿔줌

Texture는 아틀라스로 만들어서 출력해 draw call 줄일 것

FontMaker는 원하는 글자를 맘대로 넣을 수도 있고 아스키 코드만 넣을수도 있음

 

UICamera에 OnHover OnPress OnClick 등등의 이벤트가 구현되어 있으니 찾아볼 것

 

 

 

 

 

'Unity' 카테고리의 다른 글

Update, LateUpdate 차이  (0) 2015.07.22
Unity Linq  (0) 2015.07.13
animator에 붙어있는 animation의 재생여부  (0) 2015.06.11
GridMove  (0) 2015.06.10
Rigidbody 초기화  (0) 2015.05.15
!animator.GetCurrentAnimatorStateInfo(0).IsName("Walking@loop")

"애니메이션"이 재생되고 있는지 확인할 수 있음


'Unity' 카테고리의 다른 글

Unity Linq  (0) 2015.07.13
NGUI 공식 Tutorial 정리  (0) 2015.07.03
GridMove  (0) 2015.06.10
Rigidbody 초기화  (0) 2015.05.15
Humanoid 머리에 콜라이더 달기  (0) 2015.05.14

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

104

105

106

107

108

109

110

111

112

113

114

115

116

117

118

119

120

121

122

123

124

125

126

127

128

129

130

131

132

133

134

135

136

137

138

139

140

141

142

143

144

145

146

using UnityEngine;

using System.Collections;

   

public class MoveTest : MonoBehaviour {

   

    public float speed = 1.0F;

    public float grid = 1.0f;

    public float rotationSpeed = 100.0F;

   

    [SerializeField]

     Direction direction = Direction.NONE;

   

    Vector3 startPosition;

    Vector3 endPosition = Vector3.zero;

    Vector3 dir = Vector3.zero;

   

    Hashtable hash = new Hashtable();

   

    bool isMoving = false;

   

   

    enum Direction

    {

        LEFT,

        RIGHT,

        FORWARD,

        BACK,

        NONE

    };

   

    Animator animator;

    void Start()

    {

        animator = GetComponent<Animator>();

    }

   

      

    // Update is called once per frame

      

    void Update() {

        if (Input.GetKeyDown(KeyCode.DownArrow))

            direction = Direction.BACK;

        else if (Input.GetKeyDown(KeyCode.LeftArrow))

            direction = Direction.LEFT;

        else if (Input.GetKeyDown(KeyCode.RightArrow))

            direction = Direction.RIGHT;

        else if (Input.GetKeyDown(KeyCode.UpArrow))

            direction = Direction.FORWARD;

   

        if(isMoving == false)

            Move();

    }

   

    void Move()

    {

        isMoving = true;

        startPosition = transform.position;

          

   

        switch(direction)

        {

            case Direction.LEFT:

                hash.Clear();

                endPosition = startPosition + transform.right * grid * -1;

   

                dir = endPosition - startPosition;

                dir.y = 0.0f;

                dir.Normalize();

   

                transform.rotation = Quaternion.Lerp(transform.rotation,

                                                                     Quaternion.LookRotation(dir),

                                                                      rotationSpeed);

   

   

                hash.Clear();

                hash.Add("position", endPosition);

                hash.Add("speed", speed);

                hash.Add("easetype", iTween.EaseType.linear);

                iTween.MoveTo(gameObject, hash);

   

                animator.SetTrigger("Move");

   

                break;

            case Direction.RIGHT:

   

                hash.Clear();

                endPosition = startPosition + transform.right * grid;

   

                dir = endPosition - startPosition;

                dir.y = 0.0f;

                dir.Normalize();

                transform.rotation = Quaternion.Lerp(transform.rotation,

                                                                     Quaternion.LookRotation(dir),

                                                                      rotationSpeed);

   

                hash.Add("position", endPosition);

                hash.Add("speed", speed);

                hash.Add("easetype", iTween.EaseType.linear);

                iTween.MoveTo(gameObject, hash);

   

                animator.SetTrigger("Move");

                break;

            case Direction.FORWARD:

   

                hash.Clear();

   

                endPosition = startPosition + transform.forward * grid;

   

                hash.Add("position", endPosition);

                hash.Add("speed", speed);

                hash.Add("easetype", iTween.EaseType.linear);

                iTween.MoveTo(gameObject, hash);

   

                animator.SetTrigger("Move");

                break;

   

            case Direction.BACK:

   

                hash.Clear();

                endPosition = startPosition + transform.forward * grid * -1;

   

                dir = endPosition - startPosition;

                dir.y = 0.0f;

                dir.Normalize();

                transform.rotation = Quaternion.Lerp(transform.rotation,

                                                                     Quaternion.LookRotation(dir),

                                                                      rotationSpeed);

   

                hash.Add("position", endPosition);

                hash.Add("speed", speed);

                hash.Add("easetype", iTween.EaseType.linear);

                iTween.MoveTo(gameObject, hash);

   

                animator.SetTrigger("Move");

                break;

   

        }

   

        transform.position = new Vector3(Mathf.Round(transform.position.x), Mathf.Round(transform.position.y), Mathf.Round(transform.position.z));

        transform.rotation = new Quaternion(Mathf.Round(transform.rotation.x), Mathf.Round(transform.rotation.y), Mathf.Round(transform.rotation.z), Mathf.Round(transform.rotation.w));

   

        direction = Direction.NONE;

        isMoving = false;

    }

}

   

Colored by Color Scripter

cs

 

 

Grid Move 코드

itween으로 부드럽게 움직이게 했고 움직임에 따라 회전하게 만듬

또 움직이다보면 정확히 안움직이는데 다 반올림시켜서 움직이게 만듬

grid단위가 1이여서 편했네

'Unity' 카테고리의 다른 글

NGUI 공식 Tutorial 정리  (0) 2015.07.03
animator에 붙어있는 animation의 재생여부  (0) 2015.06.11
Rigidbody 초기화  (0) 2015.05.15
Humanoid 머리에 콜라이더 달기  (0) 2015.05.14
Animator에서 Trigger 와 Bool의 차이  (0) 2015.05.14

1

2

3

rigidbody.velocity = Vector3.zero;

rigidbody.angularVelocity = Vector3.zero;

rigidbody.Sleep();

cs

 

하면 되는데

오브젝트를 다시 사용할때는

위치를 원위치로 돌리고 그 다음에 rigidbody.WakeUp();

애니메이션 하면 콜라이더가 그만큼 따라가야 하는데 안따라가서 왤까 고민하다가

본 박혀있는데다가 박아놨더니 콜라이더도 따라감


'Unity' 카테고리의 다른 글

GridMove  (0) 2015.06.10
Rigidbody 초기화  (0) 2015.05.15
Animator에서 Trigger 와 Bool의 차이  (0) 2015.05.14
물체가 카메라에 그려지고 있는지 확인하는 함수(OnBecameInvisible)  (0) 2015.05.13
RequireComponent  (0) 2015.04.14

메카님에서 애니메이션을 시키려고 Trigger혹은 bool을 만들려고 봤다가

뭐 써야할지 고민이 돼서 찾아보고 테스트 해본 결과

Trigger는 한번 true가 되면 애니메이션이 끝난다음 다음 애니메이션으로 전환해줌

bool은 안해줌

그래서 jump같은 애니메이션을 하려고 파라미터를 만들려면 bool말고 trigger를 사용할것

'Unity' 카테고리의 다른 글

Rigidbody 초기화  (0) 2015.05.15
Humanoid 머리에 콜라이더 달기  (0) 2015.05.14
물체가 카메라에 그려지고 있는지 확인하는 함수(OnBecameInvisible)  (0) 2015.05.13
RequireComponent  (0) 2015.04.14
Particle System  (0) 2015.04.14

http://docs.unity3d.com/ScriptReference/MonoBehaviour.OnBecameInvisible.html


1
2
3
 void OnBecameInvisible() {
        enabled = false;
    }
cs


'Unity' 카테고리의 다른 글

Humanoid 머리에 콜라이더 달기  (0) 2015.05.14
Animator에서 Trigger 와 Bool의 차이  (0) 2015.05.14
RequireComponent  (0) 2015.04.14
Particle System  (0) 2015.04.14
Invoke Coroutine  (0) 2015.04.14

+ Recent posts