public static ProgressBar Show(string bgPath, string fgPath, Action onFinished = null, Image.FillMethod fillMethod = Image.FillMethod.Horizontal, bool leftFill = true) { if (barGo != null) { GameObject.DestroyImmediate(barGo); } barGo = null; curProgressBar = null; var tempGo = Instantiate(ResourceManager.LoadGameObjectAssets(PrefabResourceName)); barGo = tempGo; GameObject.DontDestroyOnLoad(barGo); curProgressBar = tempGo.GetComponent <ProgressBar>(); curProgressBar.onFinish = onFinished; curProgressBar.progressBg.sprite = UR.Load <Sprite>(bgPath) as Sprite; curProgressBar.progressBg.SetNativeSize(); curProgressBar.progress.sprite = UR.Load <Sprite>(fgPath) as Sprite; curProgressBar.progress.SetNativeSize(); curProgressBar.progress.type = Image.Type.Filled; curProgressBar.progress.fillMethod = fillMethod; curProgressBar.progress.fillOrigin = leftFill ? 0 : 1; curProgressBar.progress.fillAmount = 0; return(curProgressBar); }
/// <summary> /// 加载子弹型npc /// </summary> /// <returns>The bullet npc.</returns> /// <param name="num">Number.</param> /// <param name="camp">Camp.</param> /// <param name="pos">Position.</param> /// <param name="rot">Rot.</param> public GameObject LoadBulletNpc(int num, CAMP camp, Vector3 pos, Quaternion rot) { if (NpcModel == null) { NpcModel = Core.Data.getIModelConfig <NPCModel>(); } NPCConfigData configData = NpcModel.get(num); #if DEBUG Utils.Assert(configData == null, "Virtual Npc load can't find npc configure. NPC id = " + num); #endif string path = SPath.Combine(ResourceSetting.PACKROOT, NPC); path = SPath.Combine(path, "ServerBulletNpc"); UObj obj = URes.Load(path); GameObject go = GameObject.Instantiate(obj) as GameObject; go.transform.position = pos; go.transform.rotation = rot; ServerNPC npc = go.GetComponent <ServerNPC>(); if (npc != null) { DynamicDataInit(npc, configData, camp); } return(go); }
// Start is called before the first frame update public void Start() { _game = Manager.Instance.game; Assert.IsNotNull(_game); _clientInfo = Manager.Instance.clientInfo; Assert.IsNotNull(_clientInfo); Assert.IsNotNull(Manager.Instance.tablePositions); _radialBarGameStart = gameStartsRadialBar.GetComponent <QUI_Bar>(); buttonToken.SetActive(false); smallBlindToken.SetActive(false); bigBlindToken.SetActive(false); foreach (TablePosition t in Manager.Instance.tablePositions) { t.nameText.SetText(""); t.stackText.SetText(""); t.radialBar.gameObject.SetActive(false); } cardBlankPrefab = (GameObject)Resources.Load(Cards.BlankCard()); if (cardBlankPrefab == null) { throw new FileNotFoundException(Cards.BlankCard() + " no file found - please check the configuration"); } }
private void EnsureMappingsExist() { if (xnaBundles == null && !Game.IsDummy) { string streamingAssetsPath; if (PlatformInstances.IsEditor) { streamingAssetsPath = string.Format("file://{0}/", Application.streamingAssetsPath); } else #if U_WINDOWS || U_PS4 { streamingAssetsPath = string.Format("file://{0}/", Application.streamingAssetsPath); } #else { streamingAssetsPath = string.Format("{0}/", Application.streamingAssetsPath); } #endif Log.WriteT("Initializing Mapped Content..."); xnaBundles = new BundleManager(streamingAssetsPath, new StringReader(UResources.Load <TextAsset>("AssetBundleMappings").text), true); streams = new StreamedContentManager(streamingAssetsPath, new StringReader(UResources.Load <TextAsset>("StreamedMappings").text)); Log.WriteT("Mapped Content Initialized"); } }
private UObject NativeLoad(string fileName, Type type) { UObject res = UResources.Load(UnityResourcePath(fileName), type); if (res == null) { throw new ContentLoadException("Failed to load " + fileName + " as " + type); } return(res); }
public static string ReadTextFile(string assetName) { TextAsset textasset = UResources.Load(assetName, typeof(TextAsset)) as TextAsset; if (textasset == null) { throw new ContentLoadException("Failed to load " + assetName + " as " + typeof(TextAsset)); } return(textasset.text); }
public ItemController Create(RavenNest.Models.Item item, bool useMalePrefab) { definition = item; gameObject.name = item.Name; transform.localPosition = Vector3.zero; transform.localRotation = Quaternion.identity; Id = item.Id; Name = item.Name; Level = item.Level; WeaponAim = item.WeaponAim; WeaponPower = item.WeaponPower; ArmorPower = item.ArmorPower; RequiredAttackLevel = item.RequiredAttackLevel; RequiredDefenseLevel = item.RequiredDefenseLevel; Category = item.Category; Type = item.Type; Material = item.Material; FemaleModelID = item.FemaleModelId; MaleModelID = item.MaleModelId; GenericPrefabPath = item.GenericPrefab; MalePrefabPath = item.MalePrefab; FemalePrefabPath = item.FemalePrefab; IsGenericModel = item.IsGenericModel.GetValueOrDefault(); if (!prefab) { var path = IsGenericModel ? GenericPrefabPath : useMalePrefab ? MalePrefabPath : FemalePrefabPath; if (string.IsNullOrEmpty(path)) { return(this); } prefab = Resources.Load <GameObject>(path); if (!prefab) { //Debug.LogError(this.name + " failed to load prefab: " + path); return(this); } model = Instantiate(prefab, transform) as GameObject; } return(this); }
} // end read // Read from the file and store the data public void Read_From_Resource(string _fileName) { Object obj = UR.Load <Object>(_fileName); if (debug) { Debug.Log("IniFile Read File from Resource:\n" + obj); } Read_From_String(obj.ToString()); } // end read
private GameObject CreateInstance(string asset, Transform bone) { var model = Resources.Load(asset); if (!model) { Debug.LogError("Failed to load " + asset); return(null); } return(Instantiate(model, bone) as GameObject); }
public static Stream ReadBytesFileToStream(string fileName) { fileName = fileName.ToLower().Replace("\\", "/"); TextAsset binData = UResources.Load(fileName, typeof(TextAsset)) as TextAsset; if (binData == null) { throw new ContentLoadException("Failed to load " + fileName + " as " + typeof(TextAsset)); } return(new MemoryStream(binData.bytes)); }
public void Create(RavenNest.Models.Item item, bool useMalePrefab) { this.definition = item; this.gameObject.name = item.Name; this.transform.localPosition = Vector3.zero; this.transform.localRotation = Quaternion.identity; this.Id = item.Id; this.Name = item.Name; this.Level = item.Level; this.WeaponAim = item.WeaponAim; this.WeaponPower = item.WeaponPower; this.ArmorPower = item.ArmorPower; this.RequiredAttackLevel = item.RequiredAttackLevel; this.RequiredDefenseLevel = item.RequiredDefenseLevel; this.Category = item.Category; this.Type = item.Type; this.Material = item.Material; this.FemaleModelID = item.FemaleModelId; this.MaleModelID = item.MaleModelId; this.GenericPrefabPath = item.GenericPrefab; this.MalePrefabPath = item.MalePrefab; this.FemalePrefabPath = item.FemalePrefab; this.IsGenericModel = item.IsGenericModel.GetValueOrDefault(); if (!prefab) { var path = IsGenericModel ? this.GenericPrefabPath : useMalePrefab ? this.MalePrefabPath : this.FemalePrefabPath; if (string.IsNullOrEmpty(path)) { return; } this.prefab = Resources.Load <GameObject>(path); if (!prefab) { //Debug.LogError(this.name + " failed to load prefab: " + path); return; } this.model = Instantiate(prefab, this.transform) as GameObject; } }
UObj RefResource(string filename) { UObj obj = lstRefAsset.Get(filename); if (obj == null) { obj = URes.Load(filename); //加入引用列表的同时,释放资源 releaseRes(lstRefAsset.Add(filename, obj)); } return(obj); }
// // Debug Only public static GameObject Load(string name) { if (string.IsNullOrEmpty(name)) { return(null); } string path = Path.Combine(ResourceSetting.WAR_EFFECT, name); path = Path.Combine(ResourceSetting.UNPACKROOT, path); return(URes.Load(path) as GameObject); }
public ExternalBehavior load(string name, bool cached = true) { strBld.Remove(0, strBld.Length); strBld.Append(AI_PATH); strBld.Append(name); Object obj = URes.Load(strBld.ToString()); if (obj != null) { return((ExternalBehavior)obj); } ConsoleEx.DebugWarning("not find ai tree in path :: " + strBld.ToString()); return(null); }
public Fireball(GameObject prefab) : base(prefab) { AbilityName = "Fireball"; Description = "A 'fire' ball."; Animation = new SpellAnimations.Fireball(); CanSplash = true; DamagePerHit = 150.0f; ShotsPerMinute = 60; MaxUpwardAngleCorrection = 3.0f; TowerShotRange = 50.0f; IconTex = Resources.Load <Texture2D>("Images/Spells/Fireball"); SpellTowerTurretOffset = Vector3.zero; Price = 250; }
/// <summary> /// 加载Resources目录资源 /// </summary> /// <param name="assetName"></param> /// <returns></returns> private static T loadResources <T>(string assetName) where T : UnityEngine.Object { string resAssetPath = assetName; string ext = Path.GetExtension(assetName); if (!string.IsNullOrEmpty(ext)) { resAssetPath = assetName.Replace(ext, ""); } T res = UR.Load <T>(resAssetPath); if (res == null) { Debug.LogError(string.Format("Cant find resource: ", assetName)); } return(res); }
/// <summary> /// 加载Resources目录资源 /// </summary> /// <param name="assetName"></param> /// <returns></returns> public static UO LoadResource(string assetName, Type type) { string resAssetPath = assetName; string ext = Path.GetExtension(assetName); if (!string.IsNullOrEmpty(ext)) { resAssetPath = assetName.Replace(ext, ""); } UO res = UR.Load(resAssetPath, type); if (res == null) { Debug.LogError(string.Format("Cant find resource: ", assetName)); } return(res); }
/// <summary> /// Loads from unpack folder. country参数决定是否要读取 国家分类 /// </summary> /// <returns>The Object from unack.</returns> /// <param name="name">Name.</param> GameObject loadFromUnPack(string name, Quaternion qua, Vector3 pos, bool country, bool cached, bool ignoreSetting) { Object obj = null; GameObject go = null; if (!string.IsNullOrEmpty(name)) { string path = string.Empty; if (country) { path = Path.Combine(CountryRegion.country, ResourceSetting.UNPACKROOT); path = Path.Combine(path, name); } else { path = Path.Combine(ResourceSetting.UNPACKROOT, name); } if (cached) { obj = ObjLoader.Load(path); } else { obj = URes.Load(path); } if (obj == null) { ConsoleEx.DebugWarning(path + " is not find"); return(null); } if (ignoreSetting) { go = GameObject.Instantiate(obj) as GameObject; } else { go = GameObject.Instantiate(obj, pos, qua) as GameObject; } } return(go); }
public void SetAttributesFromPlayerData(PlayerData data) { SpriteController.sprite = data.Portrait; Portrait = data.Portrait; Name = data.Name; var collider = gameObject.AddComponent <PolygonCollider2D>(); collider.autoTiling = true; HealthPointsMax = data.HealthPointsMax; HealthPointsCurrent = data.HealthPointsMax; ActionPointsMax = data.ActionPointsMax; ActionPointsCurrent = data.ActionPointsMax; Accuracy = data.Accuracy; Strength = data.Strength; Agility = data.Agility; Reaction = data.Reaction; _animator.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animation/Controllers/" + data.ControllerPath); }
/// ///填写预设体的名字,其他都不包括 /// public UObj Load(string filename) { Utils.Assert(string.IsNullOrEmpty(filename), "Can't Load Empty Resource"); UObj obj = null; #if Package AssetBundle asset = RefAsset(filename); if (asset != null) { obj = asset.Load(filename); } #else obj = URes.Load <UObj>(filename); #endif return(obj); }
private void Plugin_start() { var card = Resources.Load <CharacterSpawnCard>("SpawnCards/CharacterSpawnCards/Titan/cscGrandparent"); if (!card || card is null) { Log.Error("No card found"); } this.dirCard = new DirectorCard { spawnCard = card, selectionWeight = 500, spawnDistance = DirectorCore.MonsterSpawnDistance.Standard, allowAmbushSpawn = true, preventOverhead = false, minimumStageCompletions = 0, forbiddenUnlockable = "", requiredUnlockable = "", }; }
private static GameObject LoadPrefabLabel() { return((GameObject)Resources.Load("Label")); }
public void UpdateAppearance() { if (Base) { appearanceUpdateRequired = true; Destroy(Base); Base = null; } var gender = Gender.ToString(); var skin = SkinColor + " Skin"; var skinColor = SkinColor.ToString().ToUpper()[0] + "S"; var baseModelName = $"{skinColor} {gender} 01 {BaseModelNumber:00}"; var rsxChar = System.IO.Path.Combine("Character/"); var rsxGender = System.IO.Path.Combine(rsxChar, gender + "/"); var rsxBase = System.IO.Path.Combine(rsxGender, "Base/", skin + "/"); var rsxBaseModel = System.IO.Path.Combine(rsxBase, baseModelName); var rsxHeads = System.IO.Path.Combine(rsxGender, "Heads/"); var rsxMouth = System.IO.Path.Combine(rsxHeads, "Mouths/", $"Mouth {MouthModelNumber:00} {skin}"); var rsxBrows = System.IO.Path.Combine(rsxHeads, "Brows/", $"Brow {BrowsModelNumber:00} {BrowColor}"); var rsxEyes = System.IO.Path.Combine(rsxHeads, "Eyes/", $"Eyes {EyesModelNumber:00} {EyeColor}"); var rsxBeard = System.IO.Path.Combine(rsxHeads, "Beards/", $"Beard {BeardModelNumber:00} {BeardColor}"); var hairNumber = Gender == Gender.Male ? MaleHairModelNumber : FemaleHairModelNumber; var rsxHair = System.IO.Path.Combine(rsxHeads, "Hair/", $"Hair {gender} {hairNumber:00} {HairColor}"); var baseModel = Resources.Load(rsxBaseModel); Base = Instantiate(baseModel, transform) as GameObject; if (Base) { var pelvis = Base.transform.Find("RigPelvis"); EquipLKnee = pelvis.Find("RigLThigh/RigLCalf/+ L Knee"); EquipRKnee = pelvis.Find("RigRThigh/RigRCalf/+ R Knee"); var ribcage = pelvis.Find("RigSpine1/RigSpine2/RigSpine3/RigRibcage"); EquipBack = ribcage.Find("+ Back"); //if (this.Gender == Gender.Female) //{ // this.EquipNeck = ribcage.Find("RigNeck"); //} //else //{ EquipNeck = ribcage.Find("+ Neck"); if (!EquipNeck) { EquipNeck = ribcage.Find("RigNeck/+ Neck"); } //} var lupperarm = ribcage.Find("RigLCollarbone/RigLUpperarm"); EquipLShoulder = ribcage.Find("RigLCollarbone/+ L Shoulder"); EquipLWrist = lupperarm.Find("RigLForearm/+ L Wrist"); EquipLHand = lupperarm.Find("RigLForearm/RigLPalm/+ L Hand"); var rupperarm = ribcage.Find("RigRCollarbone/RigRUpperarm"); EquipRShoulder = ribcage.Find("RigRCollarbone/+ R Shoulder"); EquipRWrist = rupperarm.Find("RigRForearm/+ R Wrist"); EquipRHand = rupperarm.Find("RigRForearm/RigRPalm/+ R Hand"); var rhead = ribcage.Find("RigNeck/RigHead"); EquipHead = rhead.Find("+ Head"); EquipREar = rhead.Find("+ R Ear"); EquipLEar = rhead.Find("+ L Ear"); if (TorsoModelNumber > 0) { var torso = Math.Min(Gender == Gender.Male ? 18 : 21, TorsoModelNumber); //if (Deactivate("Torso")) Deactivate("Torso"); (torsoModel = Base.transform.Find($"02 Torso {torso:00}"))?.gameObject.SetActive(true); if (TorsoMaterial > 0) { var torsoMaterial = Resources.Load <Material>($"Materials/Armor/{TorsoMaterial}"); if (torsoMaterial && torsoModel) { torsoModel.GetComponent <SkinnedMeshRenderer>().material = torsoMaterial; } } } if (BottomModelNumber > 0) { Deactivate("Bottom"); (bottomModel = Base.transform.Find($"03 Bottom {BottomModelNumber:00}"))?.gameObject.SetActive(true); if (BottomMaterial > 0) { var material = Resources.Load <Material>($"Materials/Armor/{BottomMaterial}"); if (material && bottomModel) { bottomModel.GetComponent <SkinnedMeshRenderer>().material = material; } } } if (FeetModelNumber > 0) { Deactivate("Feet"); (feetModel = Base.transform.Find($"04 Feet {FeetModelNumber:00}"))?.gameObject.SetActive(true); if (FeetMaterial > 0) { var material = Resources.Load <Material>($"Materials/Armor/{FeetMaterial}"); if (material && feetModel) { feetModel.GetComponent <SkinnedMeshRenderer>().material = material; } } } if (HandModelNumber > 0) { Deactivate("Hand"); (handModel = Base.transform.Find($"05 Hand {HandModelNumber:00}"))?.gameObject.SetActive(true); if (HandMaterial > 0) { var material = Resources.Load <Material>($"Materials/Armor/{HandMaterial}"); if (material && handModel) { handModel.GetComponent <SkinnedMeshRenderer>().material = material; } } } if (BeltModelNumber > 0) { Deactivate("Belt"); Base.transform.Find($"06 Belt {BeltModelNumber:00}")?.gameObject.SetActive(true); } if (Gender == Gender.Male) { if (BeardModelNumber > 0) { CreateInstance(rsxBeard, EquipHead); } if (MaleHairModelNumber > 0) { hair = CreateInstance(rsxHair, EquipHead); } } else if (FemaleHairModelNumber > 0) { hair = CreateInstance(rsxHair, EquipHead); } if (EyesModelNumber > 0) { CreateInstance(rsxEyes, EquipHead); } if (BrowsModelNumber > 0) { CreateInstance(rsxBrows, EquipHead); } if (MouthModelNumber > 0) { CreateInstance(rsxMouth, EquipHead); } } var animEventController = Base.GetComponent <AnimationEventController>(); if (!animEventController) { Base.AddComponent <AnimationEventController>(); } }
/// <summary> /// Loads the bullet. /// </summary> /// <returns>The bullet.</returns> /// <param name="num">Number.</param> /// <param name="camp">Camp.</param> /// <param name="pos">Position.</param> /// <param name="rot">Rot.</param> public GameObject LoadNpcObj(int num, CAMP camp, Vector3 pos, Quaternion rot) { if (NpcModel == null) { NpcModel = Core.Data.getIModelConfig <NPCModel>(); } NPCConfigData configData = NpcModel.get(num); #if DEBUG Utils.Assert(configData == null, "Virtual Npc load can't find npc configure. NPC id = " + num); #endif string path = SPath.Combine(ResourceSetting.PACKROOT, NPC); if (configData.healthpoint > 0) { path = SPath.Combine(path, "LifeSummonNpc"); } else { path = SPath.Combine(path, "NoneLifeSummonNpc"); } UObj obj = URes.Load(path); GameObject go = GameObject.Instantiate(obj) as GameObject; go.transform.position = pos; go.transform.rotation = rot; if (configData.moveable == Moveable.Movable) { Seeker seek = go.AddComponent <Seeker>(); seek.drawGizmos = false; AIPath pathFinding = go.AddComponent <AIPath>(); pathFinding.speed = configData.speed; pathFinding.slowdownDistance = 0.0f; pathFinding.pickNextWaypointDist = 2; pathFinding.forwardLook = 1f; FunnelModifier modifer = go.AddComponent <FunnelModifier>(); modifer.Priority = 2; CharacterController box = go.AddComponent <CharacterController>(); box.radius = configData.radius; box.height = 2; if (box.radius >= box.height) { box.center = Vector3.up * box.radius; } else { box.center = Vector3.up * box.height / 2; } } else if (configData.radius > 0) { CapsuleCollider cap = go.AddComponent <CapsuleCollider>(); cap.radius = configData.radius; cap.height = 2; if (cap.radius >= cap.height) { cap.center = Vector3.up * cap.radius; } else { cap.center = Vector3.up * cap.height / 2; } NavmeshCut cut = go.AddComponent <NavmeshCut>(); cut.type = NavmeshCut.MeshType.Circle; cut.circleRadius = configData.radius; cut.height = 10; cut.center = Vector3.up * 5; } ServerNPC npc = go.GetComponent <ServerNPC>(); if (npc != null) { DynamicDataInit(npc, configData, camp); } return(go); }
public ServerNPC Load(int num, CAMP camp, GameObject WarPoint) { if (NpcModel == null) { NpcModel = Core.Data.getIModelConfig <NPCModel>(); } NPCConfigData configData = NpcModel.get(num); #if DEBUG Utils.Assert(configData == null, "Virtual Npc load can't find npc configure. NPC id = " + num); #endif if (cached == null) { string path = SPath.Combine(ResourceSetting.PACKROOT, NPC); path = SPath.Combine(path, VIRTUAL); cached = URes.Load(path); } GameObject go = GameObject.Instantiate(cached) as GameObject; UnityUtils.AddChild_Reverse(go, WarPoint); if (configData.type == LifeNPCType.Build) { go.layer = LayerMask.NameToLayer(Consts.LAYER_BUILD); } else { go.layer = LayerMask.NameToLayer(Consts.LAYER_NPC); } ServerNPC npc = null; if (configData.healthpoint > 0) { npc = go.AddComponent <ServerLifeNpc>(); } else { npc = go.AddComponent <ServerNPC>(); } //如果是可以移动的,添加寻路脚本 if (configData.moveable == Moveable.Movable) { Seeker seek = go.AddComponent <Seeker>(); seek.drawGizmos = false; AIPath pathFinding = go.AddComponent <AIPath>(); pathFinding.speed = configData.speed; pathFinding.slowdownDistance = 0.0f; pathFinding.pickNextWaypointDist = 2; pathFinding.forwardLook = 1f; FunnelModifier modifer = go.AddComponent <FunnelModifier>(); modifer.Priority = 2; CharacterController box = go.AddComponent <CharacterController>(); box.radius = configData.radius; box.height = 2; if (box.radius >= box.height) { box.center = Vector3.up * box.radius; } else { box.center = Vector3.up * box.height / 2; } } else if (configData.radius > 0) { CapsuleCollider cap = go.AddComponent <CapsuleCollider>(); cap.radius = configData.radius; cap.height = 2; if (cap.radius >= cap.height) { cap.center = Vector3.up * cap.radius; } else { cap.center = Vector3.up * cap.height / 2; } NavmeshCut cut = go.AddComponent <NavmeshCut>(); cut.type = NavmeshCut.MeshType.Circle; cut.circleRadius = configData.radius; cut.height = 10; cut.center = Vector3.up * 5; } DynamicDataInit(npc, configData, camp); go.name = "NPC_" + configData.ID + "_" + npc.UniqueID; return(npc); }