EntryPoint.cs
protected IEnumerator LoadAsync(string prf_path, Transform prt_tf, bool is_enable = true)
{
ResourceRequest res_req = Resources.LoadAsync<GameObject>(string.Format(prf_path, quality));
res_req.priority = 0; // = ThreadPriority.Low;
yield return res_req;
if (res_req == null || res_req.asset == null)
{
res_req = Resources.LoadAsync<GameObject>(string.Format(prf_path, "HIGH"));
res_req.priority = 0; // = ThreadPriority.Low;
yield return res_req;
Debug.LogFormat(prf_path, "HIGH");
}
else
{
Debug.LogFormat(prf_path, quality);
}
GameObject prf = res_req.asset as GameObject;
GameObject obj = Instantiate(prf);
obj.transform.SetParent(prt_tf);
obj.transform.localScale = Vector3.one;
obj.transform.localRotation = prf.transform.localRotation;
obj.transform.localPosition = prf.transform.localPosition;
obj.name = prf.name;
yield return new WaitForEndOfFrame();
obj.SetActive(is_enable);
}
LOBBYUI:
我有一个选项,即选项Rendering
和选项Livestreaming
。现在这是问题所在。当我第一次尝试运行我的程序并选择选项Livestreaming
它将工作然后我将注销然后它将返回到我的LobbyUI并选择选项Rendering
。然后会出现这个错误
“GameObject”类型的对象已被破坏,但您仍在尝试访问它。
现在我尝试了这行代码
if (obj != null)
{
obj.SetActive(is_enable);
}
它会指出我的对象已启动,这很奇怪。有什么想法吗?
我使用以下代码加载资源:
MC_EntryPoint:EntryPointA
if (PlayerPrefs.GetInt(OptionPopup.LiveStreaming_) == 1)
{
tf = transform.Find("UI Root/FullscreenPanel/Screen3DUI/panel (depth 1~2)");
yield return StartCoroutine(LoadAsync("MC_VERSION/{0}/UI/Screen3DUI/logo", tf));
yield return StartCoroutine(LoadAsync("MC_VERSION/{0}/UI/Screen3DUI/card_open_window", tf));
yield return StartCoroutine(LoadAsync("MC_VERSION/{0}/UI/Screen3DUI/ranking", tf));
yield return StartCoroutine(LoadAsync("MC_VERSION/{0}/UI/Screen3DUI/streaming_feed", tf));
tf = transform.Find("UI Root/FullscreenPanel/Screen3DUI/panel (depth 10~11)");
yield return StartCoroutine(LoadAsync("MC_VERSION/{0}/UI/Screen3DUI/midterm_loading", tf));
tf = transform.Find("UI Root/FullscreenPanel/Screen3DUI/panel (depth 12)");
yield return StartCoroutine(LoadAsync("MC_VERSION/{0}/UI/Screen3DUI/game_result", tf));
}
else
{
yield return StartCoroutine(LoadAsync("MC_VERSION/{0}/UI/Screen3DUI/minimap_type_b (x_ 1575, 1356)", tf));
yield return StartCoroutine(LoadAsync("MC_VERSION/{0}/UI/Screen3DUI/replay", tf));
tf = transform.Find("UI Root/FullscreenPanel/Screen3DUI/panel (depth 1~2)");
yield return StartCoroutine(LoadAsync("MC_VERSION/{0}/UI/Screen3DUI/logo", tf));
yield return StartCoroutine(LoadAsync("MC_VERSION/{0}/UI/Screen3DUI/card_open_window", tf));
yield return StartCoroutine(LoadAsync("MC_VERSION/{0}/UI/Screen3DUI/ranking", tf));
yield return StartCoroutine(LoadAsync("MC_VERSION/{0}/UI/Screen3DUI/top_bar", tf));
tf = transform.Find("UI Root/FullscreenPanel/Screen3DUI/panel (depth 10~11)");
yield return StartCoroutine(LoadAsync("MC_VERSION/{0}/UI/Screen3DUI/midterm_loading", tf));
tf = transform.Find("UI Root/FullscreenPanel/Screen3DUI/panel (depth 12)");
yield return StartCoroutine(LoadAsync("MC_VERSION/{0}/UI/Screen3DUI/game_result", tf));
}
loading.SetValue(0.02f); // 2%.
所以它就像。如果我来自Livestreaming
(我没有加载某些UI)到Rendering
(我加载了一些UI),还有其他任何方式加载我的 UserInterface 。
EntryPointA:入口点
protected override IEnumerator Init()
{
tzPlayInfo.Instance.BLOCK_GAME_FLOW = true;
tzPlayInfo.Instance.MAKING_GAME_OBJECT = true;
//start_time = Time.realtimeSinceStartup;
loading.SetValue(0f); // 0%.
yield return StartCoroutine(InitSystem());
//Debug.Log(string.Format("End InitSystem - {0}s", Time.realtimeSinceStartup - start_time));
loading.SetValue(0.01f); // 1%.
yield return StartCoroutine(InitUI());
//Debug.Log(string.Format("End InitUI - {0}s", Time.realtimeSinceStartup - start_time));
loading.SetValue(0.05f); // 5%.
yield return StartCoroutine(InitGO());
//Debug.Log(string.Format("End InitGO - {0}s", Time.realtimeSinceStartup - start_time));
loading.SetValue(0.95f); // 95%.
yield return StartCoroutine(InitServerDependentInfo());
//Debug.Log(string.Format("End InitServerDependentInfo - {0}s", Time.realtimeSinceStartup - start_time));
loading.SetValue(0.96f); // 96%.
yield return StartCoroutine(Recheck());
//Debug.Log(string.Format("End Recheck - {0}s", Time.realtimeSinceStartup - start_time));
loading.SetValue(1f); // 100%.
CameraManager.Instance.TurnOnCamera(eCmr.PADDOCK_1); // 로딩이 끝나면 카메라를 켠다.
tzPlayInfo.Instance.BLOCK_GAME_FLOW = false;
Destroy(loading.gameObject); // 첫로딩 UI 삭제.
Destroy(this); // EntryPoint 컴포넌트 삭제.
}
我想我提供的信息有点僵硬所以我编辑了它。我猜它是空的因为我摧毁了什么?请赐教。
答案 0 :(得分:1)
无法发表评论,但您是否检查过您是否试图从其他地方访问该游戏对象?可能有任何参考?或者您正在使用单身人士?
答案 1 :(得分:0)
我会回答我自己的问题。我在这里做的是这行代码
protected IEnumerator LoadAsync(string prf_path, Transform prt_tf, bool is_enable = true)
{
ResourceRequest res_req = Resources.LoadAsync<GameObject>(string.Format(prf_path, quality));
res_req.priority = 0; // = ThreadPriority.Low;
yield return res_req;
if (res_req == null || res_req.asset == null)
{
res_req = Resources.LoadAsync<GameObject>(string.Format(prf_path, "HIGH"));
res_req.priority = 0; // = ThreadPriority.Low;
yield return res_req;
Debug.LogFormat(prf_path, "HIGH");
}
else
{
Debug.LogFormat(prf_path, quality);
}
GameObject prf = res_req.asset as GameObject;
GameObject obj = Instantiate(prf);
obj.transform.SetParent(prt_tf);
obj.transform.localScale = Vector3.one;
obj.transform.localRotation = prf.transform.localRotation;
obj.transform.localPosition = prf.transform.localPosition;
obj.name = prf.name;
yield return new WaitForEndOfFrame();
obj.SetActive(is_enable);
}
不适用于Android手机。它基本上只适用于PC平台。所以现在我正在制作移动方法。完成后我会编辑我的答案。谢谢你们