public void SwitchModelMesh()
 {
     if (null == this.m_kRootGameObj)
     {
         Debug.LogError("Nr3DCharNonePart root go is null at Request! " + this.m_kRootGameObj.name);
     }
     else
     {
         string text = this.GenerateKey_();
         if (!NpcCache.TryCloneObject(text, out this.m_kBaseObject))
         {
             base.bStartDownloadBundle = true;
             base.downloadCounter++;
             NrTSingleton <NkBundleCallBack> .Instance.RequestBundleRuntime(text, NkBundleCallBack.NPCBundleStackName, ItemType.SKIN_BONE, 0, this.m_szCharCode.ToLower(), NkBundleParam.eBundleType.BUNDLE_CHAR_NONEPART, base.GetID().ToString(), true);
         }
         else
         {
             this.FinishDownloadModelSetting();
         }
     }
 }
Beispiel #2
0
    public static GameObject AddAndClone(string key, IDownloadedItem item)
    {
        if (!NpcCache.Enabled)
        {
            GameObject original = item.mainAsset as GameObject;
            return(UnityEngine.Object.Instantiate(original) as GameObject);
        }
        if (string.IsNullOrEmpty(key))
        {
            int startIndex = item.assetPath.IndexOf('.');
            key = item.assetPath.Remove(startIndex);
        }
        GameObject gameObject;

        if (NpcCache.TryCloneObject(key, out gameObject))
        {
            return(gameObject);
        }
        if (NpcCache.mRoot == null)
        {
            NpcCache.mRoot = GameObject.Find("@Internal NPC");
            if (NpcCache.mRoot == null)
            {
                NpcCache.mRoot = new GameObject("@Internal NPC");
                NpcCache.mRoot.SetActive(false);
                UnityEngine.Object.DontDestroyOnLoad(NpcCache.mRoot);
            }
        }
        gameObject                  = (UnityEngine.Object.Instantiate(item.mainAsset) as GameObject);
        gameObject.name             = key;
        NpcCache.mCachedItems[key]  = new NpcCache.CachingItem(gameObject);
        gameObject.transform.parent = NpcCache.mRoot.transform;
        GameObject gameObject2 = UnityEngine.Object.Instantiate(gameObject) as GameObject;

        NpcCache.RegisterAutoRemover(key, gameObject2);
        return(gameObject2);
    }