A:
E.G. 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 :
Assets\C#Like\HotUpdateScripts\TowerDefense\UI\PauseMenu.cs
Assets\UnityTechnologies\TowerDefenseTemplate\Scripts\TowerDefense\UI\HUD\GameUI.cs
Assets\UnityTechnologies\TowerDefenseTemplate\Scripts\Core\UI\SimpleMainMenuPage.cs
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.
4.2.1.1 Open 'Assets\UnityTechnologies\TowerDefenseTemplate\Prefabs\UI\HUD\PauseMenu.prefab' to edit in Unity.
4.2.1.2 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.)
4.2.1.3 Bind the the component that you are using in PauseMenu:
4.2.1.4 Bind Button click event('Pause()' 'Unpause()' 'RestartPressed' 'LevelSelectPressed').
e.g. PauseMenu/Button
To
4.2.1.5 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.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.
|