Component member function Getting weired NullException

I write a callback function in a Component, which will be called by an asynchronous routine when it’s done. The function body is like below:

    private void CacheUITexture()
    {
        if (uiTexture)
        {
            return;
        }

        if (gameObject == null || gameObject.transform == null)
        {
            return;
        }

        uiTexture = GetComponent<UITexture>();
        if (null == uiTexture)
        {
            Debug.LogError("UIUrlTexture组件缺少UITexture组件");
        }
    }

However, I found in my android log weired NullException happened in this function body:


But how can this happen? I haved already checked null == gameObject, which will return true when gameObject is destroyed. So I have no idea what may cause this exception, can anyone help?

You’ve checked if the GameObject is null and if the transform is null, but not if the GameObject is active.

if(gameObject.activeInHierarchy == false)
 return;