-
카테고리
-
세부 분야
게임 프로그래밍
-
해결 여부
미해결
go = new GameObject(name = "@Managers"); 버그
23.10.16 10:46 작성 23.10.16 10:49 수정 조회수 293
0
using System.Collections;
using System.Collections.Generic;
using JetBrains.Annotations;
using UnityEngine;
public class Managers : MonoBehaviour
{
private static Managers s_instance;
public static Managers instance {get {init(); return s_instance; }}
// Start is called before the first frame update
void Start()
{
init();
}
// Update is called once per frame
void Update()
{
}
static void init()
{
if (s_instance == null)
{
GameObject go = GameObject.Find("@Managers");
if (go == null)
{
go = new GameObject(name = "@Managers");
go.AddComponent<Managers>();
}
DontDestroyOnLoad(go);
s_instance = go.GetComponent<Managers>();
}
}
}
Managers.cs(29, 37): [CS0120] static이 아닌 필드, 메서드 또는 속성 'Object.name'에 개체 참조가 필요합니다.
이런 오류가 뜨는데 어떻게 수정해야 될까요? 제가 놓친 부분이 있을까요?
답변을 작성해보세요.
답변 1