首次提交
This commit is contained in:
48
Assets/Scripts/Fishing/Helper/PrefabsHelper.cs
Normal file
48
Assets/Scripts/Fishing/Helper/PrefabsHelper.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using Fantasy;
|
||||
using NBC;
|
||||
using NBC.Asset;
|
||||
using NBF.Utils;
|
||||
using UnityEngine;
|
||||
|
||||
namespace NBF.Fishing2
|
||||
{
|
||||
public static class PrefabsHelper
|
||||
{
|
||||
public static GameObject LoadPrefab(string path, Transform parent = null)
|
||||
{
|
||||
var prefab = Assets.Load<GameObject>(path);
|
||||
if (prefab == null)
|
||||
{
|
||||
|
||||
}
|
||||
return parent == null ? Object.Instantiate(prefab) : Object.Instantiate(prefab, parent);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建角色预制体
|
||||
/// </summary>
|
||||
/// <param name="parent"></param>
|
||||
/// <param name="modelName"></param>
|
||||
/// <returns></returns>
|
||||
public static GameObject CreatePlayer(Transform parent, string modelName = "Player")
|
||||
{
|
||||
var model = LoadPrefab($"Assets/ResRaw/Prefabs/Player/{modelName}.prefab", parent);
|
||||
return model;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 创建物品预制体
|
||||
/// </summary>
|
||||
/// <param name="config"></param>
|
||||
/// <param name="isPreview">是否预览模式</param>
|
||||
/// <returns></returns>
|
||||
public static GameObject CreateItem(cfg.Item config, bool isPreview = false)
|
||||
{
|
||||
//创建主物体
|
||||
var mainObject = LoadPrefab(config.GetFullModelPath());
|
||||
//创建配件
|
||||
|
||||
return mainObject;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user