상세 컨텐츠

본문 제목

유니티 오브젝트에 레이어 이름 추가하기(스크립트로 추가)

유니티/기능

by MJ_119 2024. 10. 15. 00:37

본문

- 오브젝트에 스크립트를 이용해서 레이어 설정하기

 

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[RequireComponent(typeof(Rigidbody))]
public class Target : MonoBehaviour
{
    private void Start()
    {
        gameObject.layer = LayerMask.NameToLayer("Enemy");
    }
}

관련글 더보기