English       FAQ(e.g how to update old project to hot update project.)
简体中文     常见问题解答(例如如何把旧项目升级为可热更新项目)

C#Like Question and Answer

We'll collect some question and answer from user and update here.

Question: How to turn my none hot update projects into hot update projects?

Answer: we try to turn the 'Tower Defense Template' that make by 'Unity Technologies' into hot update project by C#Like or C#LikeFree.

The sample cs files :

1 Download Tower Defense Template plugin from AssetStore and import it.

2 Download C#LikeFree or C#Like plugin from AssetStore and import it.

3 Open scenes : 'Assets\UnityTechnologies\TowerDefenseTemplate\Scenes\MainMenu.unity'

4 Turn the C# code into hot update script.

  4.1 We divide all code into two categories: non hot update code and hot update code.
        We call hot update code by 'HotUpdateBehaviourXXXX' component automatically, that component will bind the class inherit 'LikeBehaviour'.
      The non hot update code CAN'T reference the hot update code directly, you can think of this as the hot update code was deleted from project. Both your non hot update code or prefab can't reference to them directly. The prefab bind hot update code by component 'HotUpdateManagerXXXX' with class name with full namespace.
      The hardest work is make sure all your non hot update code and prefab not direct reference to hot update script.
        How my non hot update code call the hot update code manually?
      You can get the 'HotUpdateBehaviour' component first, and then call function by HotUpdateBehaviour instance. e.g. we want to call the function 'AddFunc' of class 'PauseMenu' in non hot update code.
  4.2 The class inherit from MonoBehaviour. e.g. we convert 'Assets\UnityTechnologies\TowerDefenseTemplate\Scripts\TowerDefense\UI\PauseMenu.cs' to hot update code.

    4.2.1 Modify the binding of prefab before modify the script, or else your prefab will missing script. Open 'Assets\UnityTechnologies\TowerDefenseTemplate\Prefabs\UI\HUD\PauseMenu.prefab' to edit in Unity. Select 'PauseMenu' in Hierarchy panel, and will find the 'Pause Menu(Script)', and then click 'Add Component' to add 'Hot Update Behaviour Update(Script)'(Select which one in 'HotUpdateBehaviourXXXX' depend on your logic. If you are lazy you can choose HotUpdateBehaviourAll but not recommend.) Bind the the component that you are using in PauseMenu:
    Bind Button click event('Pause()' 'Unpause()' 'RestartPressed' 'LevelSelectPressed').
      e.g. PauseMenu/Button
    Remove the 'Pause Menu(Script)' component.
      4.2.2 Cut your original file to hot update script folder, default is 'Assets/C#Like/HotUpdateScripts/', you can change it at C#Like setting panel.
      e.g. Cut from 'Assets\UnityTechnologies\TowerDefenseTemplate\Scripts\TowerDefense\UI\PauseMenu.cs' to 'Assets\C#Like\HotUpdateScripts\TowerDefense\UI\PauseMenu.cs'
      4.2.3 Change base class MonoBehaviour to LikeBehaviour
      'public class PauseMenu : MonoBehaviour' modify to 'public class PauseMenu : LikeBehaviour'
      4.2.4 Bind the prefab component at code.
      4.2.5 FREE version NOT support enumeration.
      You can use integer number instead.
      Delete enumeration and replace with number.
      4.2.6 Issue: Not support the enum define in class in non hot update code yet.
      'TowerDefense.UI.HUD.GameUI.State' move out of class 'TowerDefense.UI.HUD.GameUI', to be ''TowerDefense.UI.HUD.State''.
That will occur many error, you should modify them.
      4.2.7 Init Hot update code
      Modify public class SimpleMainMenuPage : MonoBehaviour, IMainMenuPage

  4.3 The class NOT inherit from MonoBehaviour
      Just as normal C# code, pay attention to the difference between FULL version and FREE version.

  4.5 FREE version NOT support class inherit except inherit LikeBehaviour.
      e.g. FREE version NOT support like this:
      public abstract class Affector : LikeBehaviour
      public class AttackAffector : Affector, ITowerRadiusProvider

  4.6 NOT support template class both FULL and FREE version
      e.g. Not support 'public class LevelManager : Singleton<LevelManager>' or define class like 'public class TemplateClass<T>'.
      You can modify like this:

Contact me: 465583519@qq.com      粤ICP备2022042034号-1