From b2fca31e4b23de2844d08e2c310601d8d6f726c9 Mon Sep 17 00:00:00 2001 From: SamsamTS Date: Tue, 29 May 2018 01:01:09 +0200 Subject: [PATCH] 1.3.7 --- AirportRoads/AirportRoads.cs | 95 ++++++++++++------------------------ 1 file changed, 32 insertions(+), 63 deletions(-) diff --git a/AirportRoads/AirportRoads.cs b/AirportRoads/AirportRoads.cs index 3a775d0..41537a9 100644 --- a/AirportRoads/AirportRoads.cs +++ b/AirportRoads/AirportRoads.cs @@ -9,7 +9,6 @@ using System; using System.IO; using System.Reflection; -using System.Collections.Generic; namespace AirportRoads { @@ -27,25 +26,27 @@ public string Description } #endregion - public const string version = "1.3.6"; - - public static AirportRoads instance; - private GameObject m_gameObject; + public const string version = "1.3.7"; public override void OnLevelLoaded(LoadMode mode) { - instance = this; - if (mode == LoadMode.LoadAsset || mode == LoadMode.NewAsset) + try { - if (m_gameObject == null || m_gameObject.name != "AirportRoads") + if (ToolManager.instance.m_properties.m_mode.IsFlagSet(ItemClass.Availability.AssetEditor)) { - m_gameObject = new GameObject("AirportRoads"); - m_gameObject.AddComponent(); + ToolsModifierControl.toolController.eventEditPrefabChanged += (p) => + { + panelGameObject = GameObject.Find("LandscapingPathsPanel"); + + if (panelGameObject == null) return; + + //DebugUtils.Log(AirportRoads.panelGameObject.name + " found."); + + LoadResources(); + InitMod(); + }; } - } - else if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame) - { - try + else { panelGameObject = GameObject.Find("PublicTransportPlanePanel"); @@ -60,21 +61,14 @@ public override void OnLevelLoaded(LoadMode mode) LoadResources(); InitMod(); } - catch (Exception e) - { - //DebugUtils.Log("Failed to load."); - Debug.LogException(e); - } - } - } - public override void OnLevelUnloading() - { - if (m_gameObject != null) + } + catch (Exception e) { - GameObject.Destroy(m_gameObject); - m_gameObject = null; + //DebugUtils.Log("Failed to load."); + Debug.LogException(e); } + } public static GameObject panelGameObject; @@ -154,18 +148,18 @@ public void LoadResources() if (m_atlas == null) { string[] spriteNames = new string[] - { - "Runway", - "RunwayDisabled", - "RunwayFocused", - "RunwayHovered", - "RunwayPressed", - "Taxiway", - "TaxiwayDisabled", - "TaxiwayFocused", - "TaxiwayHovered", - "TaxiwayPressed" - }; + { + "Runway", + "RunwayDisabled", + "RunwayFocused", + "RunwayHovered", + "RunwayPressed", + "Taxiway", + "TaxiwayDisabled", + "TaxiwayFocused", + "TaxiwayHovered", + "TaxiwayPressed" + }; m_atlas = CreateTextureAtlas("AirportRoads", spriteNames, "AirportRoads.Icons."); } } @@ -281,29 +275,4 @@ public static UITextureAtlas GetAtlas(string name) return UIView.GetAView().defaultAtlas; } } - - public class AirportRoadsRoutine : MonoBehaviour - { - public void Update() - { - if (AirportRoads.panelGameObject != null) return; - - try - { - AirportRoads.panelGameObject = GameObject.Find("LandscapingPathsPanel"); - - if (AirportRoads.panelGameObject == null) return; - - //DebugUtils.Log(AirportRoads.panelGameObject.name + " found."); - - AirportRoads.instance.LoadResources(); - AirportRoads.instance.InitMod(); - } - catch (Exception e) - { - //DebugUtils.Log("Failed to load."); - Debug.LogException(e); - } - } - } } \ No newline at end of file