Skip to content

Commit

Permalink
1.3.7
Browse files Browse the repository at this point in the history
  • Loading branch information
SamsamTS committed May 28, 2018
1 parent 6449032 commit b2fca31
Showing 1 changed file with 32 additions and 63 deletions.
95 changes: 32 additions & 63 deletions AirportRoads/AirportRoads.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using System;
using System.IO;
using System.Reflection;
using System.Collections.Generic;

namespace AirportRoads
{
Expand All @@ -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<AirportRoadsRoutine>();
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");

Expand All @@ -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;
Expand Down Expand Up @@ -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.");
}
}
Expand Down Expand Up @@ -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);
}
}
}
}

0 comments on commit b2fca31

Please sign in to comment.