Пример #1
0
 //省略 前缀 加载资源
 public static UnityEngine.Object AwayPrefixGetAsset(this ResourcesComponent resourcesComponent, string assetBundleName, string prefab)
 {
     assetBundleName = assetBundleName.ToLower();
     if (ResourcesComponent.bundlesNameDictionary.ContainsKey(assetBundleName))
     {
         return(resourcesComponent.BundleNameGetAsset(ResourcesComponent.bundlesNameDictionary[assetBundleName] + "/" + assetBundleName, prefab));
     }
     else
     {
         return(resourcesComponent.BundleNameGetAsset(assetBundleName, prefab));
     }
 }
Пример #2
0
        public static Unit Create(long id)
        {
            ResourcesComponent resourcesComponent = Game.Scene.GetComponent <ResourcesComponent>();
            GameObject         bundleGameObject   = (GameObject)resourcesComponent.BundleNameGetAsset("Unit.unity3d", "Unit");
            GameObject         prefab             = bundleGameObject.Get <GameObject>("Skeleton");

            UnitComponent unitComponent = Game.Scene.GetComponent <UnitComponent>();

            Unit unit = ComponentFactory.CreateWithId <Unit>(id);

            unit.GameObject = UnityEngine.Object.Instantiate(prefab);
            GameObject parent = GameObject.Find($"/Global/Unit");

            unit.GameObject.transform.SetParent(parent.transform, false);
            unit.AddComponent <AnimatorComponent>();
            unit.AddComponent <MoveComponent>();

            unitComponent.Add(unit);
            return(unit);
        }