mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-03 12:02:28 +08:00
a bit more scene page development, cleaned up console page a bit
This commit is contained in:
@ -24,21 +24,21 @@ namespace Explorer.UI.Main.Pages.Console
|
|||||||
public static KeywordMatch validKeywordMatcher = new KeywordMatch
|
public static KeywordMatch validKeywordMatcher = new KeywordMatch
|
||||||
{
|
{
|
||||||
highlightColor = new Color(0.33f, 0.61f, 0.83f, 1.0f),
|
highlightColor = new Color(0.33f, 0.61f, 0.83f, 1.0f),
|
||||||
keywords = @"add as ascending await base bool break by byte
|
keywords = @"add as ascending await bool break by byte
|
||||||
case catch char checked const continue decimal default descending do dynamic
|
case catch char checked const continue decimal default descending do dynamic
|
||||||
else enum equals false finally fixed float for foreach from global goto group
|
else equals false finally float for foreach from global goto group
|
||||||
if in int into is join let lock long new null object on orderby out params
|
if in int into is join let lock long new null object on orderby out
|
||||||
ref remove return sbyte select short sizeof stackalloc string
|
ref remove return sbyte select short sizeof stackalloc string
|
||||||
struct switch this throw true try typeof uint ulong unchecked unsafe ushort
|
struct switch throw true try typeof uint ulong ushort
|
||||||
value var where while yield"
|
value var where while yield"
|
||||||
};
|
};
|
||||||
|
|
||||||
public static KeywordMatch invalidKeywordMatcher = new KeywordMatch()
|
public static KeywordMatch invalidKeywordMatcher = new KeywordMatch()
|
||||||
{
|
{
|
||||||
highlightColor = new Color(0.95f, 0.10f, 0.10f, 1.0f),
|
highlightColor = new Color(0.95f, 0.10f, 0.10f, 1.0f),
|
||||||
keywords = @"abstract async class delegate explicit extern get
|
keywords = @"abstract async base class delegate enum explicit extern fixed get
|
||||||
implicit interface internal namespace operator override private protected public
|
implicit interface internal namespace operator override params private protected public
|
||||||
using partial readonly sealed set static virtual volatile void"
|
using partial readonly sealed set static this unchecked unsafe virtual volatile void"
|
||||||
};
|
};
|
||||||
|
|
||||||
private static char[] delimiterSymbolCache = null;
|
private static char[] delimiterSymbolCache = null;
|
||||||
|
@ -94,20 +94,20 @@ namespace Explorer.UI.Main.Pages
|
|||||||
|
|
||||||
m_evaluator.Compile(str, out var compiled);
|
m_evaluator.Compile(str, out var compiled);
|
||||||
|
|
||||||
try
|
if (compiled == null)
|
||||||
{
|
|
||||||
if (compiled == null)
|
|
||||||
{
|
|
||||||
throw new Exception("Mono.Csharp Service was unable to compile the code provided.");
|
|
||||||
}
|
|
||||||
|
|
||||||
compiled.Invoke(ref ret);
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
{
|
||||||
if (!suppressWarning)
|
if (!suppressWarning)
|
||||||
|
ExplorerCore.LogWarning("Unable to compile the code!");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
ExplorerCore.LogWarning(e.GetType() + ", " + e.Message);
|
compiled.Invoke(ref ret);
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
ExplorerCore.LogWarning($"Exception executing code: {e.GetType()}, {e.Message}\r\n{e.StackTrace}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ using ExplorerBeta;
|
|||||||
using ExplorerBeta.UI;
|
using ExplorerBeta.UI;
|
||||||
using ExplorerBeta.UI.Main;
|
using ExplorerBeta.UI.Main;
|
||||||
using ExplorerBeta.UI.Shared;
|
using ExplorerBeta.UI.Shared;
|
||||||
|
using ExplorerBeta.Unstrip.Resources;
|
||||||
using ExplorerBeta.Unstrip.Scenes;
|
using ExplorerBeta.Unstrip.Scenes;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
@ -17,43 +18,65 @@ namespace Explorer.UI.Main.Pages
|
|||||||
{
|
{
|
||||||
public override string Name => "Home";
|
public override string Name => "Home";
|
||||||
|
|
||||||
// private PageHandler m_sceneListPages;
|
private const float UPDATE_INTERVAL = 1f;
|
||||||
|
private float m_timeOfLastUpdate;
|
||||||
|
|
||||||
|
// ~~ Scene pane ~~
|
||||||
|
|
||||||
private Dropdown m_sceneDropdown;
|
private Dropdown m_sceneDropdown;
|
||||||
|
|
||||||
private Dictionary<string, int> m_sceneHandles = new Dictionary<string, int>();
|
|
||||||
|
|
||||||
// is tihs needed?
|
|
||||||
private int m_currentSceneHandle;
|
private int m_currentSceneHandle;
|
||||||
|
private readonly Dictionary<string, int> m_sceneHandles = new Dictionary<string, int>();
|
||||||
|
|
||||||
private List<GameObject> m_currentObjectList = new List<GameObject>();
|
private List<GameObject> m_currentObjectList = new List<GameObject>();
|
||||||
|
private int m_lastMaxIndex;
|
||||||
|
// todo
|
||||||
|
private GameObject m_selectedSceneObject;
|
||||||
|
|
||||||
private GameObject m_sceneListContent;
|
private GameObject m_sceneListContent;
|
||||||
private readonly List<Text> m_sceneListTexts = new List<Text>();
|
private readonly List<Text> m_sceneListTexts = new List<Text>();
|
||||||
// todo
|
|
||||||
private GameObject m_currentSceneObject;
|
|
||||||
|
|
||||||
private int m_lastMaxIndex;
|
// ~~ Inspector pane ~~ TODO
|
||||||
|
|
||||||
public override void Init()
|
public override void Init()
|
||||||
{
|
{
|
||||||
ConstructMenu();
|
ConstructMenu();
|
||||||
|
|
||||||
// get DontDestroyScene handle
|
// Get DontDestroyOnLoad scene handle. I think it's always -12, but best to be safe.
|
||||||
var test = new GameObject();
|
var test = new GameObject();
|
||||||
GameObject.DontDestroyOnLoad(test);
|
GameObject.DontDestroyOnLoad(test);
|
||||||
GetSceneHandle(test.scene);
|
StoreScenehandle(test.scene);
|
||||||
GameObject.Destroy(test);
|
GameObject.Destroy(test);
|
||||||
|
|
||||||
RefreshActiveScenes();
|
RefreshActiveScenes();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
// refresh active scenes? maybe on a timer to limit frequency
|
// TODO update inspector tabs
|
||||||
|
|
||||||
// refresh scene objects on limited frequency
|
|
||||||
|
// update scene pane
|
||||||
|
|
||||||
|
if (Time.realtimeSinceStartup - m_timeOfLastUpdate < UPDATE_INTERVAL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_timeOfLastUpdate = Time.realtimeSinceStartup;
|
||||||
|
|
||||||
|
RefreshActiveScenes();
|
||||||
|
|
||||||
|
if (!m_selectedSceneObject)
|
||||||
|
{
|
||||||
|
SetSceneObjectList(SceneUnstrip.GetRootGameObjects(m_currentSceneHandle));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// TODO refresh objects from inspected transform
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int GetSceneHandle(Scene scene)
|
private int StoreScenehandle(Scene scene)
|
||||||
{
|
{
|
||||||
if (!m_sceneHandles.ContainsKey(scene.name))
|
if (!m_sceneHandles.ContainsKey(scene.name))
|
||||||
{
|
{
|
||||||
@ -87,7 +110,9 @@ namespace Explorer.UI.Main.Pages
|
|||||||
SetSceneObjectList(rootObjs);
|
SetSceneObjectList(rootObjs);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void RefreshActiveScenes(bool firstTime = false)
|
private bool m_doneFirstSceneRefresh;
|
||||||
|
|
||||||
|
private void RefreshActiveScenes()
|
||||||
{
|
{
|
||||||
var activeScene = SceneManager.GetActiveScene().name;
|
var activeScene = SceneManager.GetActiveScene().name;
|
||||||
var otherScenes = new List<string>();
|
var otherScenes = new List<string>();
|
||||||
@ -95,16 +120,16 @@ namespace Explorer.UI.Main.Pages
|
|||||||
for (int i = 0; i < SceneManager.sceneCount; i++)
|
for (int i = 0; i < SceneManager.sceneCount; i++)
|
||||||
{
|
{
|
||||||
var scene = SceneManager.GetSceneAt(i);
|
var scene = SceneManager.GetSceneAt(i);
|
||||||
GetSceneHandle(scene);
|
StoreScenehandle(scene);
|
||||||
|
|
||||||
if (!firstTime || scene.name != activeScene)
|
if (m_doneFirstSceneRefresh || scene.name != activeScene)
|
||||||
otherScenes.Add(scene.name);
|
otherScenes.Add(scene.name);
|
||||||
}
|
}
|
||||||
otherScenes.Add("DontDestroyOnLoad");
|
otherScenes.Add("DontDestroyOnLoad");
|
||||||
|
|
||||||
m_sceneDropdown.options.Clear();
|
m_sceneDropdown.options.Clear();
|
||||||
|
|
||||||
if (firstTime)
|
if (!m_doneFirstSceneRefresh)
|
||||||
{
|
{
|
||||||
m_sceneDropdown.options.Add(new Dropdown.OptionData
|
m_sceneDropdown.options.Add(new Dropdown.OptionData
|
||||||
{
|
{
|
||||||
@ -120,7 +145,10 @@ namespace Explorer.UI.Main.Pages
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
SetScene(activeScene);
|
if (!m_doneFirstSceneRefresh)
|
||||||
|
SetScene(activeScene);
|
||||||
|
|
||||||
|
m_doneFirstSceneRefresh = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SceneButtonClicked(int index)
|
private void SceneButtonClicked(int index)
|
||||||
@ -128,6 +156,9 @@ namespace Explorer.UI.Main.Pages
|
|||||||
var obj = m_currentObjectList[index];
|
var obj = m_currentObjectList[index];
|
||||||
|
|
||||||
ExplorerCore.Log("Clicked " + obj.name);
|
ExplorerCore.Log("Clicked " + obj.name);
|
||||||
|
m_selectedSceneObject = obj;
|
||||||
|
|
||||||
|
// TODO ?
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetSceneObjectList(IEnumerable<GameObject> objects)
|
private void SetSceneObjectList(IEnumerable<GameObject> objects)
|
||||||
@ -241,18 +272,12 @@ namespace Explorer.UI.Main.Pages
|
|||||||
SetScene(scene);
|
SetScene(scene);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Scene list(TODO)
|
|
||||||
|
|
||||||
//m_sceneListPages = new PageHandler(100);
|
|
||||||
//m_sceneListPages.ConstructUI(leftPane);
|
|
||||||
//m_sceneListPages.OnPageChanged += RefreshSceneObjectList;
|
|
||||||
|
|
||||||
var scrollTest = UIFactory.CreateScrollView(leftPane, out m_sceneListContent, new Color(0.15f, 0.15f, 0.15f, 1));
|
var scrollTest = UIFactory.CreateScrollView(leftPane, out m_sceneListContent, new Color(0.15f, 0.15f, 0.15f, 1));
|
||||||
for (int i = 0; i < 50; i++)
|
for (int i = 0; i < 50; i++)
|
||||||
{
|
{
|
||||||
AddSceneButton();
|
AddSceneButton();
|
||||||
}
|
}
|
||||||
m_lastMaxIndex = 51;
|
m_lastMaxIndex = 50;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void AddSceneButton()
|
private void AddSceneButton()
|
||||||
@ -279,6 +304,8 @@ namespace Explorer.UI.Main.Pages
|
|||||||
m_sceneListTexts.Add(text);
|
m_sceneListTexts.Add(text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// todo construct inspector pane
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user