English       FAQ
简体中文     常见问题解答

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.
      The non hot update code CAN'T reference the hot update code, 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.
  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 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.6 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.

Question: How my non hot update code call the hot update code?

Answer: 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.

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