Project organization of Unity 3D model display framework

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.
    insert image description here
  • 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.
    insert image description here
    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 into pluginsa folder.
    insert image description here
    After the directory is sorted out, create a Test2scene 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 it MainPanel.prefab.
  • The creation script MainBaseUIinherits the BasePanel of the framework and mounts it on MainPanel.prefabthe prefab.
  • Create a script UIManagerTest2to control the loading of the UI. GameManagerAnd 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()
  {
  }
}

insert image description here
UIManagerTest2The 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()
    {
    }
}

insert image description here
As a result of the operation, the following information appears in the Console window and the UI interface is successfully loaded.
insert image description here
insert image description here

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

关于框架资源包,评论处留下你的邮箱地址。

Guess you like

Origin blog.csdn.net/yxl219/article/details/124949327