12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using KairoEngine.Core;
- using KairoEngine.Core.ModuleSystem;
- using Sirenix.OdinInspector;
- namespace KairoEngine.UI
- {
- [Serializable, HideReferenceObjectPicker]
- public class UiSystemModule : GameModuleBase
- {
- public override string name => "UI Module";
- public UiSystemModule(GameConfig config) : base(config)
- {
- this.gameConfig = config;
- this.className = this.GetType().AssemblyQualifiedName;
- this.typeName = "UiSystemModule";
- }
- public override void Load(Transform parent)
- {
- Transform uiParent = CreateUiManager(parent);
- Debug.Log("UI System has been loaded");
- }
- public override void Reset()
- {
- }
- public override void Destroy()
- {
-
- }
- private Transform CreateUiManager(Transform parent)
- {
- Transform UiTransform = parent.Find("UI");
- GameObject uiObj;
- if(UiTransform == null)
- {
- uiObj = GameObject.Instantiate(new GameObject(), new Vector3(), Quaternion.identity, parent);
- uiObj.name = "UI";
- }
- else uiObj = UiTransform.gameObject;
- uiObj.AddComponent<UiManager>();
- return uiObj.transform;
- }
- public static UiSystemModule JSONToUiSystemModule(string data)
- {
- try
- {
- return JsonUtility.FromJson<UiSystemModule>(data);
- }
- catch (System.Exception e)
- {
- Debug.LogError($"Could not deserialize UiSystemModule: \n{e}");
- return new UiSystemModule(null);
- }
- }
- public override void OnBeforeSerialize(ObjectSerializer serializer) { }
- public override void OnBeforeDeserialize(ObjectSerializer serializer) { }
- }
- }
|