Exemple #1
0
        private void AddOnSuccess(object asset, object cookie)
        {
            AddOnViewParams addOnViewParams = (AddOnViewParams)cookie;

            if (addOnViewParams.Entity == null)
            {
                return;
            }
            GameObjectViewComponent gameObjectViewComp = addOnViewParams.Entity.GameObjectViewComp;

            if (gameObjectViewComp == null || gameObjectViewComp.MainGameObject == null)
            {
                return;
            }
            string    parentName = addOnViewParams.ParentName;
            Transform transform  = gameObjectViewComp.MainGameObject.transform.Find(parentName);

            if (transform == null)
            {
                Service.Logger.ErrorFormat("Add On Parent not found!  There's a mismatch between the CMS AddOn parent name ({0}) and the loaded model ({1})", new object[]
                {
                    parentName,
                    gameObjectViewComp.MainGameObject.name
                });
                return;
            }
            GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(asset as GameObject);

            gameObject.transform.parent        = transform;
            gameObject.transform.localPosition = Vector3.zero;
            gameObject.transform.localScale    = Vector3.one;
            gameObject.transform.localRotation = Quaternion.identity;
        }
Exemple #2
0
        private bool LoadAddOns(EntityViewParams viewParams)
        {
            TrapComponent trapComp = viewParams.Entity.TrapComp;

            if (trapComp == null)
            {
                return(false);
            }
            if (trapComp.Type.AddOns == null || trapComp.Type.AddOns.Count == 0)
            {
                return(false);
            }
            AssetManager  assetManager = Service.AssetManager;
            List <string> list         = new List <string>();
            List <object> list2        = new List <object>();
            int           i            = 0;
            int           count        = trapComp.Type.AddOns.Count;

            while (i < count)
            {
                AssetHandle item = AssetHandle.Invalid;
                viewParams.Entity.AssetComp.AddOnsAssetHandles.Add(item);
                AddOnMapping    addOnMapping = trapComp.Type.AddOns[i];
                string          model        = addOnMapping.Model;
                AddOnViewParams item2        = new AddOnViewParams(viewParams.Entity, addOnMapping.Parent);
                list.Add(model);
                list2.Add(item2);
                assetManager.RegisterPreloadableAsset(model);
                i++;
            }
            assetManager.MultiLoad(viewParams.Entity.AssetComp.AddOnsAssetHandles, list, new AssetSuccessDelegate(this.AddOnSuccess), null, list2, new AssetsCompleteDelegate(this.OnAllAddonsLoaded), viewParams);
            return(true);
        }