diff --git a/ComputerInterface/CustomComputer.cs b/ComputerInterface/CustomComputer.cs index 3bedf8f..ca0d6f2 100644 --- a/ComputerInterface/CustomComputer.cs +++ b/ComputerInterface/CustomComputer.cs @@ -253,12 +253,12 @@ private async Task ReplaceKeys(GameObject computer) nameToEnum.Add(key, (EKeyboardKey)Enum.Parse(typeof(EKeyboardKey), enumString)); } - foreach (var button in computer.GetComponentsInChildren()) + foreach (var button in computer.GetComponentsInChildren(true)) { if (button.characterString == "up" || button.characterString == "down") { - button.GetComponentInChildren().material.color = new Color(0.1f, 0.1f, 0.1f); + button.GetComponentInChildren(true).material.color = new Color(0.1f, 0.1f, 0.1f); button.transform.localPosition -= new Vector3(0, 0.6f, 0); DestroyImmediate(button.GetComponent()); if(FindText(button.gameObject, button.name + "text")?.GetComponent() is Text arrowBtnText) @@ -392,23 +392,21 @@ private CustomKeyboardKey CreateKey(GameObject prefab, string goName, Vector3 of newKeyText.transform.localPosition += offset; var customKeyboardKey = newKey.GetComponent(); + if (label.IsNullOrWhiteSpace()) { customKeyboardKey.Init(this, key); } + else if (color.HasValue) + { + customKeyboardKey.Init(this, key, newKeyText, label, color.Value); + } else { - if (color.HasValue) - { - customKeyboardKey.Init(this, key, newKeyText, label, color.Value); - } - else - { - customKeyboardKey.Init(this, key, newKeyText, label); - } + customKeyboardKey.Init(this, key, newKeyText, label); } - _keys.Add(customKeyboardKey); + _keys.Add(customKeyboardKey); return customKeyboardKey; } @@ -482,11 +480,18 @@ private void RemoveMonitor(GameObject computer, MonitorLocation monitorIndex) // Currently, This is broken as the combined mesh has isReadable set to false // so all the mesh info lives on the GPU, which makes it unaccessabel afaik + // https://github.com/legoandmars/Utilla/blob/457bc612eda8e63b989dcdb219e04e8e7f06393a/Utilla/GamemodeManager.cs#L54 + ZoneManagement zoneManager = FindObjectOfType(); + + // https://github.com/legoandmars/Utilla/blob/457bc612eda8e63b989dcdb219e04e8e7f06393a/Utilla/GamemodeManager.cs#L56 + ZoneData FindZoneData(GTZone zone) + => (ZoneData)AccessTools.Method(typeof(ZoneManagement), "GetZoneData").Invoke(zoneManager, new object[] { zone }); + GameObject combinedScene = monitorIndex switch { - MonitorLocation.Treehouse => GameObject.Find("LocalObjects_Prefab/Forest/Terrain/Uncover ForestCombined/").GetComponentInChildren().gameObject, - MonitorLocation.Mountains => GameObject.Find("Mountain/Mountain Texture Baker/Uncover Mountain Lit/").GetComponentInChildren().gameObject, - MonitorLocation.Beach => GameObject.Find("Beach/Beach Texture Baker - ABOVE WATER/Uncover Beach Lit/").GetComponentInChildren().gameObject, + MonitorLocation.Treehouse => FindZoneData(GTZone.forest).rootGameObjects[1].transform.Find("Terrain/Uncover ForestCombined/").GetComponentInChildren(true).gameObject, + MonitorLocation.Mountains => FindZoneData(GTZone.mountain).rootGameObjects[0].transform.Find("Mountain Texture Baker/Uncover Mountain Lit/").GetComponentInChildren(true).gameObject, + MonitorLocation.Beach => FindZoneData(GTZone.beach).rootGameObjects[0].transform.Find("Beach Texture Baker - ABOVE WATER/Uncover Beach Lit/").GetComponentInChildren(true).gameObject, _ => null, }; diff --git a/ComputerInterface/CustomKeyboardKey.cs b/ComputerInterface/CustomKeyboardKey.cs index b23d1b3..2d209c4 100644 --- a/ComputerInterface/CustomKeyboardKey.cs +++ b/ComputerInterface/CustomKeyboardKey.cs @@ -87,9 +87,28 @@ public void Init(CustomComputer computer, EKeyboardKey key, Text keyboardText, s public void Init(CustomComputer computer, EKeyboardKey key, Text keyboardText, string text, Color buttonColor) { Init(computer, key, keyboardText, text); + + if (_material == null) + { + _originalColor = buttonColor; + + var baseRenderer = GetComponent(); + if (baseRenderer.material == null) + { + _material = new Material(Shader.Find("Legacy Shaders/Diffuse")) + { + color = buttonColor + }; + goto PrepareColour; + } + baseRenderer.material.color = buttonColor; + goto PrepareColour; + } + _material.color = buttonColor; _originalColor = buttonColor; + PrepareColour: Color.RGBToHSV(buttonColor, out float H, out float S, out float _); _pressedColor = Color.HSVToRGB(H, S, 0.6f); }