Add button to inspect scene of a GameObject

This commit is contained in:
Sinai 2022-05-05 19:52:25 +10:00
parent a25017df69
commit 76c77fb082

View File

@ -33,7 +33,8 @@ namespace UnityExplorer.UI.Widgets
Text ActiveSelfText; Text ActiveSelfText;
Toggle IsStaticToggle; Toggle IsStaticToggle;
InputFieldRef SceneInput; ButtonRef SceneButton;
InputFieldRef InstanceIDInput; InputFieldRef InstanceIDInput;
InputFieldRef TagInput; InputFieldRef TagInput;
@ -100,7 +101,7 @@ namespace UnityExplorer.UI.Widgets
if (force || Target.scene.handle != lastSceneHandle) if (force || Target.scene.handle != lastSceneHandle)
{ {
lastSceneHandle = Target.scene.handle; lastSceneHandle = Target.scene.handle;
SceneInput.Text = Target.scene.IsValid() ? Target.scene.name : "None (Asset/Resource)"; SceneButton.ButtonText.text = Target.scene.IsValid() ? Target.scene.name : "None (Asset/Resource)";
} }
if (force || (!TagInput.Component.isFocused && Target.tag != lastTag)) if (force || (!TagInput.Component.isFocused && Target.tag != lastTag))
@ -228,6 +229,11 @@ namespace UnityExplorer.UI.Widgets
ExplorerCore.LogWarning($"Exception setting tag! {ex.ReflectionExToString()}"); ExplorerCore.LogWarning($"Exception setting tag! {ex.ReflectionExToString()}");
} }
} }
void OnSceneButtonClicked()
{
InspectorManager.Inspect(Target.scene);
}
void OnExploreButtonClicked() void OnExploreButtonClicked()
{ {
@ -383,10 +389,9 @@ namespace UnityExplorer.UI.Widgets
Text sceneLabel = UIFactory.CreateLabel(thirdrow, "SceneLabel", "Scene:", TextAnchor.MiddleLeft, Color.grey); Text sceneLabel = UIFactory.CreateLabel(thirdrow, "SceneLabel", "Scene:", TextAnchor.MiddleLeft, Color.grey);
UIFactory.SetLayoutElement(sceneLabel.gameObject, minHeight: 25, minWidth: 50); UIFactory.SetLayoutElement(sceneLabel.gameObject, minHeight: 25, minWidth: 50);
SceneInput = UIFactory.CreateInputField(thirdrow, "SceneInput", "untitled"); SceneButton = UIFactory.CreateButton(thirdrow, "SceneButton", "untitled");
UIFactory.SetLayoutElement(SceneInput.Component.gameObject, minHeight: 25, minWidth: 120, flexibleWidth: 999); UIFactory.SetLayoutElement(SceneButton.Component.gameObject, minHeight: 25, minWidth: 120, flexibleWidth: 999);
SceneInput.Component.readOnly = true; SceneButton.OnClick += OnSceneButtonClicked;
SceneInput.Component.textComponent.color = new Color(0.7f, 0.7f, 0.7f);
// Layer // Layer
Text layerLabel = UIFactory.CreateLabel(thirdrow, "LayerLabel", "Layer:", TextAnchor.MiddleLeft, Color.grey); Text layerLabel = UIFactory.CreateLabel(thirdrow, "LayerLabel", "Layer:", TextAnchor.MiddleLeft, Color.grey);