Last active
July 4, 2023 14:50
-
-
Save thoraxe/65b5c011980c25018fc514206e30f67e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Clicked system: THX-1138 | |
Planet:OnMouseDown() (at Assets/Scripts/Planets/Planet.cs:34) | |
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32) | |
Object clicked: Planet1 (Planet) | |
UIManager:OnClickedPlanet(ClickedPlanetEvent) (at Assets/Scripts/UIManager.cs:50) | |
EventBus.EventBus`1:Raise(ClickedPlanetEvent) (at Assets/Plugins/EventBus/EventBus.cs:227) | |
Planet:OnMouseDown() (at Assets/Scripts/Planets/Planet.cs:36) | |
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32) | |
Instantiating panel for THX-1138 | |
UIManager:OnClickedPlanet(ClickedPlanetEvent) (at Assets/Scripts/UIManager.cs:64) | |
EventBus.EventBus`1:Raise(ClickedPlanetEvent) (at Assets/Plugins/EventBus/EventBus.cs:227) | |
Planet:OnMouseDown() (at Assets/Scripts/Planets/Planet.cs:36) | |
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32) | |
Initializing panel for THX-1138 | |
UIManager:OnClickedPlanet(ClickedPlanetEvent) (at Assets/Scripts/UIManager.cs:67) | |
EventBus.EventBus`1:Raise(ClickedPlanetEvent) (at Assets/Plugins/EventBus/EventBus.cs:227) | |
Planet:OnMouseDown() (at Assets/Scripts/Planets/Planet.cs:36) | |
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32) | |
Initializing with Planet1 (Planet) | |
PlanetDetails:InitializeDetails(Planet) (at Assets/Scripts/Planets/PlanetDetails.cs:38) | |
UIManager:OnClickedPlanet(ClickedPlanetEvent) (at Assets/Scripts/UIManager.cs:68) | |
EventBus.EventBus`1:Raise(ClickedPlanetEvent) (at Assets/Plugins/EventBus/EventBus.cs:227) | |
Planet:OnMouseDown() (at Assets/Scripts/Planets/Planet.cs:36) | |
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32) | |
Planet THX-1138 has 2 slots | |
PlanetDetails:Start() (at Assets/Scripts/Planets/PlanetDetails.cs:18) | |
PlanetDetailsPanel is PlanetDetailsPanel (UnityEngine.GameObject) | |
PlanetDetails:Start() (at Assets/Scripts/Planets/PlanetDetails.cs:21) | |
Adding improvement button 0 | |
PlanetDetails:Start() (at Assets/Scripts/Planets/PlanetDetails.cs:25) | |
Adding improvement button 1 | |
PlanetDetails:Start() (at Assets/Scripts/Planets/PlanetDetails.cs:25) | |
Clicked system: Grogu | |
Planet:OnMouseDown() (at Assets/Scripts/Planets/Planet.cs:34) | |
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32) | |
Object clicked: Planet2 (Planet) | |
UIManager:OnClickedPlanet(ClickedPlanetEvent) (at Assets/Scripts/UIManager.cs:50) | |
EventBus.EventBus`1:Raise(ClickedPlanetEvent) (at Assets/Plugins/EventBus/EventBus.cs:227) | |
Planet:OnMouseDown() (at Assets/Scripts/Planets/Planet.cs:36) | |
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32) | |
Deleting panel PlanetDetails(Clone) (UnityEngine.GameObject) | |
UIManager:OnClickedPlanet(ClickedPlanetEvent) (at Assets/Scripts/UIManager.cs:57) | |
EventBus.EventBus`1:Raise(ClickedPlanetEvent) (at Assets/Plugins/EventBus/EventBus.cs:227) | |
Planet:OnMouseDown() (at Assets/Scripts/Planets/Planet.cs:36) | |
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32) | |
Instantiating panel for Grogu | |
UIManager:OnClickedPlanet(ClickedPlanetEvent) (at Assets/Scripts/UIManager.cs:64) | |
EventBus.EventBus`1:Raise(ClickedPlanetEvent) (at Assets/Plugins/EventBus/EventBus.cs:227) | |
Planet:OnMouseDown() (at Assets/Scripts/Planets/Planet.cs:36) | |
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32) | |
Initializing panel for Grogu | |
UIManager:OnClickedPlanet(ClickedPlanetEvent) (at Assets/Scripts/UIManager.cs:67) | |
EventBus.EventBus`1:Raise(ClickedPlanetEvent) (at Assets/Plugins/EventBus/EventBus.cs:227) | |
Planet:OnMouseDown() (at Assets/Scripts/Planets/Planet.cs:36) | |
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32) | |
Initializing with Planet2 (Planet) | |
PlanetDetails:InitializeDetails(Planet) (at Assets/Scripts/Planets/PlanetDetails.cs:38) | |
UIManager:OnClickedPlanet(ClickedPlanetEvent) (at Assets/Scripts/UIManager.cs:68) | |
EventBus.EventBus`1:Raise(ClickedPlanetEvent) (at Assets/Plugins/EventBus/EventBus.cs:227) | |
Planet:OnMouseDown() (at Assets/Scripts/Planets/Planet.cs:36) | |
UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32) | |
Planet Grogu has 1 slots | |
PlanetDetails:Start() (at Assets/Scripts/Planets/PlanetDetails.cs:18) | |
PlanetDetailsPanel is PlanetDetailsPanel (UnityEngine.GameObject) | |
PlanetDetails:Start() (at Assets/Scripts/Planets/PlanetDetails.cs:21) | |
Adding improvement button 0 | |
PlanetDetails:Start() (at Assets/Scripts/Planets/PlanetDetails.cs:25) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using Unity.Logging; | |
using EventBus; | |
using TMPro; | |
public class PlanetDetails : MonoBehaviour | |
{ | |
Planet myPlanet; | |
public BuildImprovementButton buildImprovementButton; | |
Transform planetDetailsPanelTransform; | |
// Start is called before the first frame update | |
void Start() | |
{ | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
UpdatePlanetNameText(); | |
} | |
public void InitializeDetails(Planet thePlanet, Transform myTransform) | |
{ | |
Log.Debug($"Initializing with {thePlanet}"); | |
myPlanet = thePlanet; | |
Log.Debug($"Planet {myPlanet.planetName} has {myPlanet.improvementSlots} slots"); | |
UpdatePlanetNameText(); | |
planetDetailsPanelTransform = myTransform.Find("PlanetDetailsPanel"); | |
Log.Debug($"PlanetDetailsPanel is {planetDetailsPanelTransform} {planetDetailsPanelTransform.GetInstanceID()}"); | |
for ( int i = 0; i < myPlanet.improvementSlots; i++ ) | |
{ | |
Log.Debug($"Adding improvement button {i}"); | |
Instantiate(buildImprovementButton, planetDetailsPanelTransform); | |
//BuildImprovementButton theButton = Instantiate(buildImprovementButton, planetDetailsPanelTransform); | |
//theButton.Initialize(myPlanet); | |
} | |
} | |
void UpdatePlanetNameText() | |
{ | |
TextMeshProUGUI planetName = GameObject.Find("PlanetName").GetComponent<TextMeshProUGUI>(); | |
planetName.text = myPlanet.planetName; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using Unity.Logging; | |
using EventBus; | |
using GameEvents.UIEventSystem; | |
using System; | |
using Unity.VisualScripting; | |
namespace GameEvents.UIEventSystem | |
{ | |
public struct ClickedPlanetEvent : IEvent | |
{ | |
public Planet clickedPlanet; | |
} | |
} | |
public class UIManager : MonoBehaviour | |
{ | |
private GameObject objectDetails; | |
EventBinding<ClickedPlanetEvent> _onClickedPlanetEvent; | |
private void Awake() | |
{ | |
_onClickedPlanetEvent = new EventBinding<ClickedPlanetEvent>(OnClickedPlanet); | |
// find the object details empty on the canvas | |
objectDetails = GameObject.Find("ObjectDetails"); | |
} | |
// Start is called before the first frame update | |
void Start() | |
{ | |
} | |
// Update is called once per frame | |
void Update() | |
{ | |
} | |
// When a planet is clicked, its details screen should be displayed | |
private void OnClickedPlanet(ClickedPlanetEvent @event) | |
{ | |
// find any details panels and destroy them | |
GameObject[] panels = GameObject.FindGameObjectsWithTag("DetailsPanel"); | |
foreach (GameObject panel in panels) | |
{ | |
Log.Debug($"Deleting panel {panel.name}/{panel.GetInstanceID()}"); | |
Destroy(panel); | |
} | |
Planet clickedPlanet = @event.clickedPlanet; | |
// add the object's details panel | |
Log.Debug($"Instantiating panel for {clickedPlanet.planetName}"); | |
PlanetDetails planetDetails = Instantiate(clickedPlanet.planetDetails, objectDetails.transform); | |
Log.Debug($"Initializing panel for {clickedPlanet.planetName}"); | |
planetDetails.InitializeDetails(clickedPlanet, planetDetails.transform); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment