public static void Initialize() { if (_instance == null) { /* * GameObject gameController = GameObject.FindWithTag("GameController"); * _instance = gameController.AddComponent<PloppableTool>(); * _instance.name = "PloppableTool"; * _instance.DrawPloppablePanel(); * _instance.PopulateAssets(); * _instance.enabled = false; * //GameObject.FindObjectOfType<ToolController>().Tools[0].enabled = true; */ try { // Destroy the UI if already exists //_gameObject = GameObject.Find("PloppableTool"); //Destroy(); // Creating our own gameObect, helps finding the UI in ModTools _gameObject = new GameObject("PloppableTool"); _gameObject.transform.parent = UIView.GetAView().transform; _instance = _gameObject.AddComponent <PloppableTool>(); //_instance.name = "PloppableTool"; _instance.DrawPloppablePanel(); _instance.PopulateAssets(); //_instance.enabled = false; } catch (Exception e) { Debug.LogException(e); } } }
public static void Initialize() { if (_instance == null) { GameObject gameController = GameObject.FindWithTag("GameController"); _instance = gameController.AddComponent <PloppableTool>(); _instance.name = "PloppableTool"; _instance.DrawPloppablePanel(); _instance.PopulateAssets(); _instance.enabled = false; GameObject.FindObjectOfType <ToolController>().Tools[0].enabled = true; } }