0
\$\begingroup\$

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);
}

obj.SetActive(is_enable); when i click the error it's pointing me here

LOBBYUI: I have an option which is Option Rendering and Option Livestreaming. Now here's the problem . When i tried to run my program for the very first time and choose Option Livestreaming it will work then i'll logout then it will go back to my LobbyUI and choose the Option Rendering. Then this error will come out

Object of type 'GameObject' has been destroyed but you are still trying to access it.

Now when i tried this line of code

if (obj != null)
    {
        obj.SetActive(is_enable);
    }

It will point out to my object which is initiated and that's pretty weird . Any idea?

EDIT:MORE INFO

I load my resources using this line of code:

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%.

So it's something like . Is there any other way load some of my UserInterface if i'm from Livestreaming(which i do not load some UI) to Rendering (which i load some UI).

EntryPointA:EntryPoint

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 컴포넌트 삭제.
}

EDITTED QUESTION

I guess the information I provided was a bit stiff so i edited it. And i'm guessing that it is null because I destroy something??? Please enlighten me.

\$\endgroup\$
2
  • \$\begingroup\$ This is indeed a strange problem. It may help to try to create a Minimal, Complete, Verifiable Example: make a copy of your project, and try to remove code & objects one by one, testing to see if the problem still occurs after each change. Keep paring it down until you have the smallest & most self-contained example that still exhibits the problem. This helps eliminate excess moving parts that can distract from the root cause of the issue, and isolate which parts are most relevant. \$\endgroup\$
    – DMGregory
    Commented Feb 2, 2018 at 3:02
  • \$\begingroup\$ Hmm i did some debugs on it and removing some codes for like Destroy(loading.gameObjects); and Destroy(this);. But it still occurs. I'm very curious because what i just did was if it is livestreaming remove unnecessary UI but not destroying them What i did was just not instantiate them . \$\endgroup\$ Commented Feb 2, 2018 at 3:06

1 Answer 1

2
\$\begingroup\$

I'll answer my own question . What i did here is that this line of code

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);
}

Doesn't work on Android Phone . It's basically for PC Platform only . So right now currently I'm making a method for Mobile. I'll edit my answer after i finish this up. Thanks guys

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .