This project will integrate the previous Unity program basic small framework column on the basis of the Unity 3D model display project, and record the adjustment process of the original script during the integration process. Added Asset Bundle + ILRuntime hot update technology process.
1. Import the basic small framework of Unity program
- Modify the basic directory of the framework project, so that the directory is clear and clear when importing.
- Add the original script to the namespace, and you can name the namespace according to your situation. Examples are as follows:
namespace BTLF.ProjectBase { //1.C#中 泛型的知识 //2.设计模式中 单例模式的知识 public class BaseManager<T> where T : new() { private static T instance; public static T GetInstance() { if (instance == null) instance = new T(); return instance; } } }
Avoid problems such as script method naming conflicts when importing other projects and existing projects.
- Export the project to a custom package and save it with a nice name.
2. Unity 3D model display project directory organization
Let's organize the previous project directory and create some folders. Classify the corresponding files. Import the framework project package intoplugins
a folder.
After the directory is sorted out, create aTest2
scene to write a new project.
3. Use the framework to load the UI interface
- Set the main page UI as a prefab, save it in
Assets/Resources/Prefabs/UI
, and name itMainPanel.prefab
. - The creation script
MainBaseUI
inherits the BasePanel of the framework and mounts it onMainPanel.prefab
the prefab. - Create a script
UIManagerTest2
to control the loading of the UI.GameManager
And mount it on the created in the scene
MainBaseUI
The script content and mount
public class MainBaseUI : BasePanel
{
public void InitData() {
Debug.Log("初始化信息!");
}
void Start()
{
}
void Update()
{
}
}
UIManagerTest2
The script content and mount
public class UIManagerTest2 : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
UIManager.GetInstance().ShowPanel<MainBaseUI>("Prefabs/UI/MainPanel", "MainPanel", E_UI_Layer.Mid, showPanel);
}
void showPanel(MainBaseUI mainBaseUI)
{
mainBaseUI.InitData();
}
// Update is called once per frame
void Update()
{
}
}
As a result of the operation, the following information appears in the Console window and the UI interface is successfully loaded.
The next article introduces the use of the framework to register events and load the project display body.
Column: Unity 3D model display , Unity program basic small framework
关于框架资源包,评论处留下你的邮箱地址。