Transform
2020. 5. 12. 16:44
728x90
Transform.childCount
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
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
public TestHero testHero;
// Start is called before the first frame update
void Start()
{
// 부모 트랜스폼에 상대적인 트랜스폼의 위치를 나타냄
Debug.LogFormat("{0}", this.testHero.model.transform.localPosition);
// 월드 공간에서 트랜스폼의 위치를 나타냄
// Debug.LogFormat("{0}", this.testHero.transform.position);
Debug.LogFormat("{0}", this.testHero.model.transform.position);
}
// Update is called once per frame
void Update()
{
}
}
|
cs |




localScale
lossyScale
eulerAngles: Transform의 월드 회전량을 Degree로 접근하는 프로퍼티
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
public TestHero testHero;
// Start is called before the first frame update
void Start()
{
Debug.LogFormat("{0}", this.testHero.model.transform.eulerAngles);
}
// Update is called once per frame
void Update()
{
}
}
|
cs |

forward >> he's walking hardly
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
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
public TestHero testHero;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
var dir = this.testHero.transform.forward;
var speed = 1;
var time = Time.deltaTime;
var displacement = dir * speed * time;
this.testHero.transform.position += displacement;
}
}
|
cs |
root: 계층에서 가장 위에 있는 트랜스폼을 반환합니다.
Detach
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
public TestHero testHero;
// Start is called before the first frame update
void Start()
{
this.testHero.transform.DetachChildren();
// this.testHero.transform.SetParent(null);
// this.testHero.transform.parent = null;
}
}
|
cs |
rotate >> 뱅글뱅글~
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
public TestHero testHero;
public float speed;
// Start is called before the first frame update
void Start()
{
Debug.LogFormat("{0}", Vector3.up);
}
// Update is called once per frame
void Update()
{
this.testHero.transform.Rotate(Vector3.up * this.speed * Time.deltaTime);
}
}
|
cs |
728x90
'Unity > Study' 카테고리의 다른 글
prefab, SetActive, SetParent, dummyRHand (0) | 2020.05.13 |
---|---|
도끼생성(Prefab) (0) | 2020.05.12 |
Scene example (0) | 2020.05.12 |
UnityAction/ 람다식 (0) | 2020.05.11 |
Scene (0) | 2020.05.11 |