mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-01-04 00:23:31 +08:00
more progress, GameObject inspector almost done
This commit is contained in:
parent
b9b5d721c8
commit
a46bc11e42
@ -3,9 +3,9 @@
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using ExplorerBeta.UI;
|
||||
//using UnityExplorer.UI;
|
||||
|
||||
//namespace ExplorerBeta.CacheObject
|
||||
//namespace UnityExplorer.CacheObject
|
||||
//{
|
||||
// public class CacheEnumerated : CacheObjectBase
|
||||
// {
|
||||
|
@ -1,8 +1,8 @@
|
||||
//using System;
|
||||
//using System.Reflection;
|
||||
//using ExplorerBeta.CacheObject;
|
||||
//using UnityExplorer.CacheObject;
|
||||
//using UnityEngine;
|
||||
//using ExplorerBeta.Helpers;
|
||||
//using UnityExplorer.Helpers;
|
||||
|
||||
//namespace Explorer
|
||||
//{
|
||||
|
@ -3,10 +3,10 @@
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using System.Reflection;
|
||||
//using ExplorerBeta.UI;
|
||||
//using ExplorerBeta.Helpers;
|
||||
//using UnityExplorer.UI;
|
||||
//using UnityExplorer.Helpers;
|
||||
|
||||
//namespace ExplorerBeta.CacheObject
|
||||
//namespace UnityExplorer.CacheObject
|
||||
//{
|
||||
// public class CacheField : CacheMember
|
||||
// {
|
||||
|
@ -3,10 +3,10 @@
|
||||
//using System.Linq;
|
||||
//using System.Reflection;
|
||||
//using UnityEngine;
|
||||
//using ExplorerBeta.UI;
|
||||
//using ExplorerBeta.UI.Shared;
|
||||
//using UnityExplorer.UI;
|
||||
//using UnityExplorer.UI.Shared;
|
||||
|
||||
//namespace ExplorerBeta.CacheObject
|
||||
//namespace UnityExplorer.CacheObject
|
||||
//{
|
||||
// public class CacheMember : CacheObjectBase
|
||||
// {
|
||||
|
@ -3,10 +3,10 @@
|
||||
//using System.Linq;
|
||||
//using System.Reflection;
|
||||
//using UnityEngine;
|
||||
//using ExplorerBeta.UI.Shared;
|
||||
//using ExplorerBeta.Helpers;
|
||||
//using UnityExplorer.UI.Shared;
|
||||
//using UnityExplorer.Helpers;
|
||||
|
||||
//namespace ExplorerBeta.CacheObject
|
||||
//namespace UnityExplorer.CacheObject
|
||||
//{
|
||||
// public class CacheMethod : CacheMember
|
||||
// {
|
||||
|
@ -3,11 +3,11 @@
|
||||
//using System.Linq;
|
||||
//using System.Reflection;
|
||||
//using UnityEngine;
|
||||
//using ExplorerBeta.UI;
|
||||
//using ExplorerBeta.UI.Shared;
|
||||
//using ExplorerBeta.Helpers;
|
||||
//using UnityExplorer.UI;
|
||||
//using UnityExplorer.UI.Shared;
|
||||
//using UnityExplorer.Helpers;
|
||||
|
||||
//namespace ExplorerBeta.CacheObject
|
||||
//namespace UnityExplorer.CacheObject
|
||||
//{
|
||||
// public class CacheObjectBase
|
||||
// {
|
||||
|
@ -3,10 +3,10 @@
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using System.Reflection;
|
||||
//using ExplorerBeta.UI;
|
||||
//using ExplorerBeta.Helpers;
|
||||
//using UnityExplorer.UI;
|
||||
//using UnityExplorer.Helpers;
|
||||
|
||||
//namespace ExplorerBeta.CacheObject
|
||||
//namespace UnityExplorer.CacheObject
|
||||
//{
|
||||
// public class CacheProperty : CacheMember
|
||||
// {
|
||||
|
@ -2,7 +2,7 @@
|
||||
using System.Xml.Serialization;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.Config
|
||||
namespace UnityExplorer.Config
|
||||
{
|
||||
public class ModConfig
|
||||
{
|
||||
|
@ -12,9 +12,9 @@ using UnhollowerRuntimeLib;
|
||||
using BepInEx.IL2CPP;
|
||||
#endif
|
||||
|
||||
namespace ExplorerBeta
|
||||
namespace UnityExplorer
|
||||
{
|
||||
[BepInPlugin(ExplorerCore.GUID, "ExplorerBeta", ExplorerCore.VERSION)]
|
||||
[BepInPlugin(ExplorerCore.GUID, "UnityExplorer", ExplorerCore.VERSION)]
|
||||
#if CPP
|
||||
public class ExplorerBepInPlugin : BasePlugin
|
||||
#else
|
||||
|
@ -1,18 +1,18 @@
|
||||
using System;
|
||||
using ExplorerBeta.Config;
|
||||
using ExplorerBeta.Input;
|
||||
using ExplorerBeta.UI;
|
||||
using ExplorerBeta.UI.Main;
|
||||
using UnityExplorer.Config;
|
||||
using UnityExplorer.Input;
|
||||
using UnityExplorer.UI;
|
||||
using UnityExplorer.UI.Main;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta
|
||||
namespace UnityExplorer
|
||||
{
|
||||
public class ExplorerCore
|
||||
{
|
||||
public const string NAME = "Explorer " + VERSION + " (" + PLATFORM + ", " + MODLOADER + ")";
|
||||
public const string NAME = "UnityExplorer " + VERSION + " (" + PLATFORM + ", " + MODLOADER + ")";
|
||||
public const string VERSION = "3.0.0";
|
||||
public const string AUTHOR = "Sinai";
|
||||
public const string GUID = "com.sinai.explorerBETA";
|
||||
public const string GUID = "com.sinai.unityexplorer";
|
||||
|
||||
public const string PLATFORM =
|
||||
#if CPP
|
||||
@ -107,7 +107,7 @@ namespace ExplorerBeta
|
||||
try
|
||||
{
|
||||
UIManager.Init();
|
||||
Log("Initialized Explorer UI.");
|
||||
Log("Initialized UnityExplorer UI.");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
#if ML
|
||||
using MelonLoader;
|
||||
|
||||
namespace ExplorerBeta
|
||||
namespace UnityExplorer
|
||||
{
|
||||
public class ExplorerMelonMod : MelonMod
|
||||
{
|
||||
|
@ -2,9 +2,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using ExplorerBeta.Helpers;
|
||||
using UnityExplorer.Helpers;
|
||||
|
||||
namespace ExplorerBeta
|
||||
namespace UnityExplorer
|
||||
{
|
||||
public static class ReflectionExtensions
|
||||
{
|
||||
|
@ -1,17 +1,17 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta
|
||||
namespace UnityExplorer
|
||||
{
|
||||
public static class UnityExtensions
|
||||
{
|
||||
public static string GetTransformPath(this Transform _transform)
|
||||
public static string GetTransformPath(this Transform t, bool includeThisName = false)
|
||||
{
|
||||
string path = _transform.name;
|
||||
string path = includeThisName ? t.transform.name : "";
|
||||
|
||||
while (_transform.parent != null)
|
||||
while (t.parent != null)
|
||||
{
|
||||
_transform = _transform.parent;
|
||||
path = _transform.name + "/" + path;
|
||||
t = t.parent;
|
||||
path = $"{t.name}/{path}";
|
||||
}
|
||||
|
||||
return path;
|
||||
|
@ -4,7 +4,7 @@ using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ExplorerBeta.Helpers
|
||||
namespace UnityExplorer.Helpers
|
||||
{
|
||||
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "External methods")]
|
||||
public static class ICallHelper
|
||||
|
@ -13,7 +13,7 @@ using UnhollowerRuntimeLib;
|
||||
using System.Runtime.InteropServices;
|
||||
#endif
|
||||
|
||||
namespace ExplorerBeta.Helpers
|
||||
namespace UnityExplorer.Helpers
|
||||
{
|
||||
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "External methods")]
|
||||
public class ReflectionHelpers
|
||||
|
@ -3,10 +3,10 @@ using UnityEngine;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
#if CPP
|
||||
using ExplorerBeta.Unstrip.ImageConversion;
|
||||
using UnityExplorer.Unstrip.ImageConversion;
|
||||
#endif
|
||||
|
||||
namespace ExplorerBeta.Helpers
|
||||
namespace UnityExplorer.Helpers
|
||||
{
|
||||
public static class Texture2DHelpers
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.Helpers
|
||||
namespace UnityExplorer.Helpers
|
||||
{
|
||||
public class UnityHelpers
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.Input
|
||||
namespace UnityExplorer.Input
|
||||
{
|
||||
public interface IHandleInput
|
||||
{
|
||||
|
@ -1,12 +1,12 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using ExplorerBeta.Helpers;
|
||||
using UnityExplorer.Helpers;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
#if CPP
|
||||
using UnhollowerBaseLib;
|
||||
#endif
|
||||
|
||||
namespace ExplorerBeta.Input
|
||||
namespace UnityExplorer.Input
|
||||
{
|
||||
[SuppressMessage("Style", "IDE1006:Naming Styles", Justification = "Unity style")]
|
||||
public static class InputManager
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using ExplorerBeta.Helpers;
|
||||
using UnityExplorer.Helpers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.Input
|
||||
namespace UnityExplorer.Input
|
||||
{
|
||||
public class InputSystem : IHandleInput
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System;
|
||||
using System.Reflection;
|
||||
using ExplorerBeta.Helpers;
|
||||
using UnityExplorer.Helpers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.Input
|
||||
namespace UnityExplorer.Input
|
||||
{
|
||||
public class LegacyInput : IHandleInput
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.Input
|
||||
namespace UnityExplorer.Input
|
||||
{
|
||||
// Just a stub for games where no Input module was able to load at all.
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using ExplorerBeta;
|
||||
using UnityExplorer;
|
||||
|
||||
#if ML
|
||||
using MelonLoader;
|
||||
|
||||
[assembly: MelonInfo(typeof(ExplorerMelonMod), "ExplorerBeta", ExplorerCore.VERSION, ExplorerCore.AUTHOR)]
|
||||
[assembly: MelonInfo(typeof(ExplorerMelonMod), "UnityExplorer", ExplorerCore.VERSION, ExplorerCore.AUTHOR)]
|
||||
[assembly: MelonGame(null, null)]
|
||||
#endif
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using ExplorerBeta.UI;
|
||||
using UnityExplorer.UI;
|
||||
using UnityEngine;
|
||||
#if CPP
|
||||
#endif
|
||||
|
||||
namespace ExplorerBeta.Tests
|
||||
namespace UnityExplorer.Tests
|
||||
{
|
||||
public static class StaticTestClass
|
||||
{
|
||||
|
@ -1,8 +1,8 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using ExplorerBeta.Helpers;
|
||||
using UnityExplorer.Helpers;
|
||||
using UnityEngine.EventSystems;
|
||||
using ExplorerBeta.Input;
|
||||
using UnityExplorer.Input;
|
||||
using BF = System.Reflection.BindingFlags;
|
||||
#if ML
|
||||
using Harmony;
|
||||
@ -10,7 +10,7 @@ using Harmony;
|
||||
using HarmonyLib;
|
||||
#endif
|
||||
|
||||
namespace ExplorerBeta.UI
|
||||
namespace UnityExplorer.UI
|
||||
{
|
||||
public class ForceUnlockCursor
|
||||
{
|
||||
|
@ -3,11 +3,11 @@
|
||||
//using System.Linq;
|
||||
//using System.Reflection;
|
||||
//using UnityEngine;
|
||||
//using ExplorerBeta.CacheObject;
|
||||
//using ExplorerBeta.Helpers;
|
||||
//using ExplorerBeta.UI.Shared;
|
||||
//using UnityExplorer.CacheObject;
|
||||
//using UnityExplorer.Helpers;
|
||||
//using UnityExplorer.UI.Shared;
|
||||
|
||||
//namespace ExplorerBeta.UI
|
||||
//namespace UnityExplorer.UI
|
||||
//{
|
||||
// public class InteractiveValue
|
||||
// {
|
||||
|
@ -7,7 +7,7 @@ using UnityEngine.UI;
|
||||
#if CPP
|
||||
#endif
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Console
|
||||
namespace UnityExplorer.UI.Main.Console
|
||||
{
|
||||
public class AutoCompleter
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using ExplorerBeta.UI.Main.Console.Lexer;
|
||||
using UnityExplorer.UI.Main.Console.Lexer;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Console
|
||||
namespace UnityExplorer.UI.Main.Console
|
||||
{
|
||||
public static class CSharpLexer
|
||||
{
|
||||
@ -73,14 +73,14 @@ namespace ExplorerBeta.UI.Main.Console
|
||||
}
|
||||
}
|
||||
|
||||
private static MatchLexer[] matchers = null;
|
||||
internal static MatchLexer[] Matchers
|
||||
private static Matcher[] matchers = null;
|
||||
internal static Matcher[] Matchers
|
||||
{
|
||||
get
|
||||
{
|
||||
if (matchers == null)
|
||||
{
|
||||
List<MatchLexer> matcherList = new List<MatchLexer>
|
||||
List<Matcher> matcherList = new List<Matcher>
|
||||
{
|
||||
commentMatcher,
|
||||
symbolMatcher,
|
||||
|
@ -1,14 +1,14 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ExplorerBeta.Input;
|
||||
using ExplorerBeta.UI.Main.Console.Lexer;
|
||||
using UnityExplorer.Input;
|
||||
using UnityExplorer.UI.Main.Console.Lexer;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Console
|
||||
namespace UnityExplorer.UI.Main.Console
|
||||
{
|
||||
public class CodeEditor
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
namespace UnityExplorer.UI.Main.Console.Lexer
|
||||
{
|
||||
public sealed class CommentMatch : MatchLexer
|
||||
public sealed class CommentMatch : Matcher
|
||||
{
|
||||
public string lineCommentStart = @"//";
|
||||
public string blockCommentStart = @"/*";
|
||||
@ -12,9 +12,9 @@ namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
public override Color HighlightColor => new Color(0.34f, 0.65f, 0.29f, 1.0f);
|
||||
public override IEnumerable<char> StartChars => new char[] { lineCommentStart[0], blockCommentStart[0] };
|
||||
public override IEnumerable<char> EndChars => new char[] { blockCommentEnd[0] };
|
||||
public override bool IsImplicitMatch(ILexer lexer) => IsMatch(lexer, lineCommentStart) || IsMatch(lexer, blockCommentStart);
|
||||
public override bool IsImplicitMatch(InputLexer lexer) => IsMatch(lexer, lineCommentStart) || IsMatch(lexer, blockCommentStart);
|
||||
|
||||
private bool IsMatch(ILexer lexer, string commentType)
|
||||
private bool IsMatch(InputLexer lexer, string commentType)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(commentType))
|
||||
{
|
||||
@ -44,6 +44,6 @@ namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool IsEndLineOrEndFile(ILexer lexer, char character) => lexer.EndOfStream || character == '\n' || character == '\r';
|
||||
private bool IsEndLineOrEndFile(InputLexer lexer, char character) => lexer.EndOfStream || character == '\n' || character == '\r';
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +0,0 @@
|
||||
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
{
|
||||
public enum SpecialCharacterPosition
|
||||
{
|
||||
Start,
|
||||
End,
|
||||
};
|
||||
|
||||
public interface ILexer
|
||||
{
|
||||
bool EndOfStream { get; }
|
||||
char Previous { get; }
|
||||
|
||||
char ReadNext();
|
||||
void Rollback(int amount = -1);
|
||||
void Commit();
|
||||
bool IsSpecialSymbol(char character, SpecialCharacterPosition position = SpecialCharacterPosition.Start);
|
||||
}
|
||||
}
|
@ -1,18 +1,24 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
namespace UnityExplorer.UI.Main.Console.Lexer
|
||||
{
|
||||
internal struct LexerMatchInfo
|
||||
public struct LexerMatchInfo
|
||||
{
|
||||
public int startIndex;
|
||||
public int endIndex;
|
||||
public string htmlColor;
|
||||
}
|
||||
|
||||
internal class InputLexer : ILexer
|
||||
public enum SpecialCharacterPosition
|
||||
{
|
||||
Start,
|
||||
End,
|
||||
};
|
||||
|
||||
public class InputLexer
|
||||
{
|
||||
private string inputString = null;
|
||||
private MatchLexer[] matchers = null;
|
||||
private Matcher[] matchers = null;
|
||||
private readonly HashSet<char> specialStartSymbols = new HashSet<char>();
|
||||
private readonly HashSet<char> specialEndSymbols = new HashSet<char>();
|
||||
private int currentIndex = 0;
|
||||
@ -26,7 +32,7 @@ namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
get { return currentLookaheadIndex >= inputString.Length; }
|
||||
}
|
||||
|
||||
public void UseMatchers(char[] delimiters, MatchLexer[] matchers)
|
||||
public void UseMatchers(char[] delimiters, Matcher[] matchers)
|
||||
{
|
||||
this.matchers = matchers;
|
||||
|
||||
@ -51,7 +57,7 @@ namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
|
||||
if (matchers != null)
|
||||
{
|
||||
foreach (MatchLexer lexer in matchers)
|
||||
foreach (Matcher lexer in matchers)
|
||||
{
|
||||
foreach (char special in lexer.StartChars)
|
||||
{
|
||||
@ -91,7 +97,7 @@ namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
|
||||
ReadWhiteSpace();
|
||||
|
||||
foreach (MatchLexer matcher in matchers)
|
||||
foreach (Matcher matcher in matchers)
|
||||
{
|
||||
int startIndex = currentIndex;
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
namespace UnityExplorer.UI.Main.Console.Lexer
|
||||
{
|
||||
public sealed class KeywordMatch : MatchLexer
|
||||
public sealed class KeywordMatch : Matcher
|
||||
{
|
||||
public string keywords;
|
||||
|
||||
@ -14,7 +14,7 @@ namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
private readonly Stack<string> removeList = new Stack<string>();
|
||||
public string[] keywordCache = null;
|
||||
|
||||
public override bool IsImplicitMatch(ILexer lexer)
|
||||
public override bool IsImplicitMatch(InputLexer lexer)
|
||||
{
|
||||
BuildKeywordCache();
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using ExplorerBeta.Unstrip.ColorUtility;
|
||||
using UnityExplorer.Unstrip.ColorUtility;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
namespace UnityExplorer.UI.Main.Console.Lexer
|
||||
{
|
||||
public abstract class MatchLexer
|
||||
public abstract class Matcher
|
||||
{
|
||||
public abstract Color HighlightColor { get; }
|
||||
|
||||
@ -14,9 +14,9 @@ namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
public virtual IEnumerable<char> StartChars { get { yield break; } }
|
||||
public virtual IEnumerable<char> EndChars { get { yield break; } }
|
||||
|
||||
public abstract bool IsImplicitMatch(ILexer lexer);
|
||||
public abstract bool IsImplicitMatch(InputLexer lexer);
|
||||
|
||||
public bool IsMatch(ILexer lexer)
|
||||
public bool IsMatch(InputLexer lexer)
|
||||
{
|
||||
if (IsImplicitMatch(lexer))
|
||||
{
|
@ -1,12 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
namespace UnityExplorer.UI.Main.Console.Lexer
|
||||
{
|
||||
public sealed class NumberMatch : MatchLexer
|
||||
public sealed class NumberMatch : Matcher
|
||||
{
|
||||
public override Color HighlightColor => new Color(0.58f, 0.33f, 0.33f, 1.0f);
|
||||
|
||||
public override bool IsImplicitMatch(ILexer lexer)
|
||||
public override bool IsImplicitMatch(InputLexer lexer)
|
||||
{
|
||||
if (!char.IsWhiteSpace(lexer.Previous) &&
|
||||
!lexer.IsSpecialSymbol(lexer.Previous, SpecialCharacterPosition.End))
|
||||
|
@ -1,16 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
namespace UnityExplorer.UI.Main.Console.Lexer
|
||||
{
|
||||
public sealed class StringMatch : MatchLexer
|
||||
public sealed class StringMatch : Matcher
|
||||
{
|
||||
public override Color HighlightColor => new Color(0.79f, 0.52f, 0.32f, 1.0f);
|
||||
|
||||
public override IEnumerable<char> StartChars { get { yield return '"'; } }
|
||||
public override IEnumerable<char> EndChars { get { yield return '"'; } }
|
||||
|
||||
public override bool IsImplicitMatch(ILexer lexer)
|
||||
public override bool IsImplicitMatch(InputLexer lexer)
|
||||
{
|
||||
if (lexer.ReadNext() == '"')
|
||||
{
|
||||
@ -24,7 +24,7 @@ namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
return false;
|
||||
}
|
||||
|
||||
private bool IsClosingQuoteOrEndFile(ILexer lexer, char character)
|
||||
private bool IsClosingQuoteOrEndFile(InputLexer lexer, char character)
|
||||
{
|
||||
if (lexer.EndOfStream == true ||
|
||||
character == '"')
|
||||
|
@ -2,9 +2,9 @@
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
namespace UnityExplorer.UI.Main.Console.Lexer
|
||||
{
|
||||
public sealed class SymbolMatch : MatchLexer
|
||||
public sealed class SymbolMatch : Matcher
|
||||
{
|
||||
public override Color HighlightColor => new Color(0.58f, 0.47f, 0.37f, 1.0f);
|
||||
|
||||
@ -39,7 +39,7 @@ namespace ExplorerBeta.UI.Main.Console.Lexer
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsImplicitMatch(ILexer lexer)
|
||||
public override bool IsImplicitMatch(InputLexer lexer)
|
||||
{
|
||||
if (lexer == null)
|
||||
{
|
||||
|
@ -6,7 +6,7 @@ using Mono.CSharp;
|
||||
|
||||
// Thanks to ManlyMarco for this
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Console
|
||||
namespace UnityExplorer.UI.Main.Console
|
||||
{
|
||||
public class ScriptEvaluator : Evaluator, IDisposable
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using Mono.CSharp;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Console
|
||||
namespace UnityExplorer.UI.Main.Console
|
||||
{
|
||||
public class ScriptInteraction : InteractiveBase
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Console
|
||||
namespace UnityExplorer.UI.Main.Console
|
||||
{
|
||||
public struct Suggestion
|
||||
{
|
||||
|
@ -3,8 +3,8 @@ using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using ExplorerBeta.UI.Main.Console;
|
||||
using ExplorerBeta.Unstrip.Resources;
|
||||
using UnityExplorer.UI.Main.Console;
|
||||
using UnityExplorer.Unstrip.Resources;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@ -12,7 +12,7 @@ using UnityEngine.UI;
|
||||
using UnhollowerRuntimeLib;
|
||||
#endif
|
||||
|
||||
namespace ExplorerBeta.UI.Main
|
||||
namespace UnityExplorer.UI.Main
|
||||
{
|
||||
public class ConsolePage : MainMenu.Page
|
||||
{
|
||||
@ -321,17 +321,24 @@ namespace ExplorerBeta.UI.Main
|
||||
mainTextInput.fontSize = 18;
|
||||
|
||||
var placeHolderText = textAreaObj.transform.Find("Placeholder").GetComponent<TextMeshProUGUI>();
|
||||
placeHolderText.text = @"Welcome to the Explorer C# Console.
|
||||
placeHolderText.text = @"Welcome to the UnityExplorer C# Console.
|
||||
|
||||
The following helper methods are available:
|
||||
|
||||
* <color=#add490>Log(""message"");</color> logs a message to the debug console
|
||||
|
||||
* <color=#add490>CurrentTarget();</color> returns the currently inspected target on the Home page
|
||||
|
||||
* <color=#add490>AllTargets();</color> returns an object[] array containing all inspected instances
|
||||
|
||||
* <color=#add490>Inspect(someObject)</color> to inspect an instance, eg. Inspect(Camera.main);
|
||||
|
||||
* <color=#add490>Inspect(typeof(SomeClass))</color> to inspect a Class with static reflection
|
||||
|
||||
* <color=#add490>AddUsing(""SomeNamespace"");</color> adds a using directive to the C# console
|
||||
|
||||
* <color=#add490>GetUsing();</color> logs the current using directives to the debug console
|
||||
|
||||
* <color=#add490>Reset();</color> resets all using directives and variables
|
||||
";
|
||||
|
||||
|
@ -1,13 +1,13 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ExplorerBeta.Unstrip.ColorUtility;
|
||||
using UnityExplorer.Unstrip.ColorUtility;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
#if CPP
|
||||
#endif
|
||||
|
||||
namespace ExplorerBeta.UI.Main
|
||||
namespace UnityExplorer.UI.Main
|
||||
{
|
||||
public class DebugConsole
|
||||
{
|
||||
|
@ -4,7 +4,7 @@ using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ExplorerBeta.UI.Main
|
||||
namespace UnityExplorer.UI.Main
|
||||
{
|
||||
public class HomePage : MainMenu.Page
|
||||
{
|
||||
|
@ -1,15 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ExplorerBeta.Helpers;
|
||||
using ExplorerBeta.UI.Main.Inspectors;
|
||||
using ExplorerBeta.UI.Shared;
|
||||
using ExplorerBeta.Unstrip.Scenes;
|
||||
using UnityExplorer.Helpers;
|
||||
using UnityExplorer.UI.Main.Inspectors;
|
||||
using UnityExplorer.UI.Shared;
|
||||
using UnityExplorer.Unstrip.Scenes;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ExplorerBeta.UI.Main
|
||||
namespace UnityExplorer.UI.Main
|
||||
{
|
||||
public class InspectorManager
|
||||
{
|
||||
|
@ -1,16 +1,19 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ExplorerBeta.Helpers;
|
||||
using System.Linq;
|
||||
using UnityExplorer.Helpers;
|
||||
using UnityExplorer.UI.Shared;
|
||||
using UnityExplorer.Unstrip.ColorUtility;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityExplorer.Unstrip.LayerMasks;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Inspectors
|
||||
namespace UnityExplorer.UI.Main.Inspectors
|
||||
{
|
||||
// TODO:
|
||||
// make page handler for children and component lists
|
||||
// -- clicking a child.. open new tab or change this tab target?
|
||||
// make top info panel (path, scene, layer, enabled)
|
||||
// fix path and name input for very long input (use content size fitter + preffered size + vert layout group)
|
||||
// make back button (inspect parent button)
|
||||
// make controls panel (transform controls, set parent, etc)
|
||||
|
||||
public class GameObjectInspector : InspectorBase
|
||||
@ -20,9 +23,51 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
||||
// just to help with casting in il2cpp
|
||||
public GameObject TargetGO;
|
||||
|
||||
// static UI elements (only constructed once)
|
||||
|
||||
private static bool m_UIConstructed;
|
||||
|
||||
private static GameObject m_content;
|
||||
public override GameObject Content
|
||||
{
|
||||
get => m_content;
|
||||
set => m_content = value;
|
||||
}
|
||||
|
||||
// cached ui elements
|
||||
public TMP_InputField m_nameInput;
|
||||
public TMP_InputField m_pathInput;
|
||||
public static TMP_InputField m_nameInput;
|
||||
private static string m_lastName;
|
||||
public static TMP_InputField m_pathInput;
|
||||
private static string m_lastPath;
|
||||
private static GameObject m_pathGroupObj;
|
||||
private static Text m_hiddenPathText;
|
||||
|
||||
private static Toggle m_enabledToggle;
|
||||
private static Text m_enabledText;
|
||||
private static bool? m_lastEnabledState;
|
||||
|
||||
private static Dropdown m_layerDropdown;
|
||||
private static int m_lastLayer = -1;
|
||||
|
||||
private static Text m_sceneText;
|
||||
private static string m_lastScene;
|
||||
|
||||
// children list
|
||||
public static PageHandler s_childListPageHandler;
|
||||
private static GameObject[] s_allChildren = new GameObject[0];
|
||||
private static readonly List<GameObject> s_childrenShortlist = new List<GameObject>();
|
||||
private static GameObject s_childListContent;
|
||||
private static readonly List<Text> s_childListTexts = new List<Text>();
|
||||
private static int s_lastChildCount;
|
||||
|
||||
// comp list
|
||||
public static PageHandler s_compListPageHandler;
|
||||
private static Component[] s_allComps = new Component[0];
|
||||
private static readonly List<Component> s_compShortlist = new List<Component>();
|
||||
private static GameObject s_compListContent;
|
||||
private static readonly List<Text> s_compListTexts = new List<Text>();
|
||||
private static int s_lastCompCount;
|
||||
public static readonly List<Toggle> s_compToggles = new List<Toggle>();
|
||||
|
||||
public GameObjectInspector(GameObject target) : base(target)
|
||||
{
|
||||
@ -34,7 +79,12 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
||||
return;
|
||||
}
|
||||
|
||||
// one UI is used for all gameobject inspectors. no point recreating it.
|
||||
if (!m_UIConstructed)
|
||||
{
|
||||
ConstructUI();
|
||||
m_UIConstructed = true;
|
||||
}
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
@ -46,8 +96,204 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
||||
return;
|
||||
}
|
||||
|
||||
m_nameInput.text = TargetGO.name;
|
||||
m_pathInput.text = TargetGO.transform.GetTransformPath();
|
||||
RefreshTopInfo();
|
||||
|
||||
RefreshChildObjectList();
|
||||
|
||||
RefreshComponentList();
|
||||
}
|
||||
|
||||
private void RefreshTopInfo()
|
||||
{
|
||||
if (m_lastName != TargetGO.name)
|
||||
{
|
||||
m_lastName = TargetGO.name;
|
||||
m_nameInput.text = m_lastName;
|
||||
}
|
||||
|
||||
if (TargetGO.transform.parent)
|
||||
{
|
||||
if (!m_pathGroupObj.activeSelf)
|
||||
m_pathGroupObj.SetActive(true);
|
||||
|
||||
var path = TargetGO.transform.GetTransformPath(true);
|
||||
if (m_lastPath != path)
|
||||
{
|
||||
m_lastPath = path;
|
||||
m_pathInput.text = path;
|
||||
m_hiddenPathText.text = path;
|
||||
}
|
||||
}
|
||||
else if (m_pathGroupObj.activeSelf)
|
||||
m_pathGroupObj.SetActive(false);
|
||||
|
||||
if (m_lastEnabledState != TargetGO.activeSelf)
|
||||
{
|
||||
m_lastEnabledState = TargetGO.activeSelf;
|
||||
|
||||
m_enabledToggle.isOn = TargetGO.activeSelf;
|
||||
m_enabledText.text = TargetGO.activeSelf ? "Enabled" : "Disabled";
|
||||
m_enabledText.color = TargetGO.activeSelf ? Color.green : Color.red;
|
||||
}
|
||||
|
||||
if (m_lastLayer != TargetGO.layer)
|
||||
{
|
||||
m_lastLayer = TargetGO.layer;
|
||||
m_layerDropdown.value = TargetGO.layer;
|
||||
}
|
||||
|
||||
if (m_lastScene != TargetGO.scene.name)
|
||||
{
|
||||
m_lastScene = TargetGO.scene.name;
|
||||
|
||||
if (!string.IsNullOrEmpty(TargetGO.scene.name))
|
||||
m_sceneText.text = m_lastScene;
|
||||
else
|
||||
m_sceneText.text = "None (Asset/Resource)";
|
||||
}
|
||||
}
|
||||
|
||||
private void RefreshChildObjectList()
|
||||
{
|
||||
s_allChildren = new GameObject[TargetGO.transform.childCount];
|
||||
for (int i = 0; i < TargetGO.transform.childCount; i++)
|
||||
{
|
||||
var child = TargetGO.transform.GetChild(i);
|
||||
s_allChildren[i] = child.gameObject;
|
||||
}
|
||||
|
||||
var objects = s_allChildren;
|
||||
s_childListPageHandler.ListCount = objects.Length;
|
||||
|
||||
//int startIndex = m_sceneListPageHandler.StartIndex;
|
||||
|
||||
int newCount = 0;
|
||||
|
||||
foreach (var itemIndex in s_childListPageHandler)
|
||||
{
|
||||
newCount++;
|
||||
|
||||
// normalized index starting from 0
|
||||
var i = itemIndex - s_childListPageHandler.StartIndex;
|
||||
|
||||
if (itemIndex >= objects.Length)
|
||||
{
|
||||
if (i > s_lastChildCount || i >= s_childListTexts.Count)
|
||||
break;
|
||||
|
||||
GameObject label = s_childListTexts[i].transform.parent.parent.gameObject;
|
||||
if (label.activeSelf)
|
||||
label.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject obj = objects[itemIndex];
|
||||
|
||||
if (!obj)
|
||||
continue;
|
||||
|
||||
if (i >= s_childrenShortlist.Count)
|
||||
{
|
||||
s_childrenShortlist.Add(obj);
|
||||
AddChildListButton();
|
||||
}
|
||||
else
|
||||
{
|
||||
s_childrenShortlist[i] = obj;
|
||||
}
|
||||
|
||||
var text = s_childListTexts[i];
|
||||
|
||||
var name = obj.name;
|
||||
|
||||
if (obj.transform.childCount > 0)
|
||||
name = $"<color=grey>[{obj.transform.childCount}]</color> {name}";
|
||||
|
||||
text.text = name;
|
||||
text.color = obj.activeSelf ? Color.green : Color.red;
|
||||
|
||||
var label = text.transform.parent.parent.gameObject;
|
||||
if (!label.activeSelf)
|
||||
{
|
||||
label.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s_lastChildCount = newCount;
|
||||
}
|
||||
|
||||
private void RefreshComponentList()
|
||||
{
|
||||
s_allComps = TargetGO.GetComponents<Component>().ToArray();
|
||||
|
||||
var components = s_allComps;
|
||||
s_compListPageHandler.ListCount = components.Length;
|
||||
|
||||
//int startIndex = m_sceneListPageHandler.StartIndex;
|
||||
|
||||
int newCount = 0;
|
||||
|
||||
foreach (var itemIndex in s_compListPageHandler)
|
||||
{
|
||||
newCount++;
|
||||
|
||||
// normalized index starting from 0
|
||||
var i = itemIndex - s_compListPageHandler.StartIndex;
|
||||
|
||||
if (itemIndex >= components.Length)
|
||||
{
|
||||
if (i > s_lastCompCount || i >= s_compListTexts.Count)
|
||||
break;
|
||||
|
||||
GameObject label = s_compListTexts[i].transform.parent.parent.gameObject;
|
||||
if (label.activeSelf)
|
||||
label.SetActive(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
Component comp = components[itemIndex];
|
||||
|
||||
if (!comp)
|
||||
continue;
|
||||
|
||||
if (i >= s_compShortlist.Count)
|
||||
{
|
||||
s_compShortlist.Add(comp);
|
||||
AddCompListButton();
|
||||
}
|
||||
else
|
||||
{
|
||||
s_compShortlist[i] = comp;
|
||||
}
|
||||
|
||||
var text = s_compListTexts[i];
|
||||
|
||||
text.text = ReflectionHelpers.GetActualType(comp).FullName;
|
||||
|
||||
var toggle = s_compToggles[i];
|
||||
if (comp is Behaviour behaviour)
|
||||
{
|
||||
if (!toggle.gameObject.activeSelf)
|
||||
toggle.gameObject.SetActive(true);
|
||||
|
||||
toggle.isOn = behaviour.enabled;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (toggle.gameObject.activeSelf)
|
||||
toggle.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
var label = text.transform.parent.parent.gameObject;
|
||||
if (!label.activeSelf)
|
||||
{
|
||||
label.SetActive(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
s_lastCompCount = newCount;
|
||||
}
|
||||
|
||||
private void ChangeInspectorTarget(GameObject newTarget)
|
||||
@ -56,71 +302,223 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
||||
return;
|
||||
|
||||
this.Target = this.TargetGO = newTarget;
|
||||
|
||||
// ?
|
||||
}
|
||||
|
||||
private static void ApplyNameClicked()
|
||||
{
|
||||
if (!(InspectorManager.Instance.m_activeInspector is GameObjectInspector instance)) return;
|
||||
|
||||
instance.TargetGO.name = m_nameInput.text;
|
||||
}
|
||||
|
||||
private static void OnEnableToggled(bool enabled)
|
||||
{
|
||||
if (!(InspectorManager.Instance.m_activeInspector is GameObjectInspector instance)) return;
|
||||
|
||||
instance.TargetGO.SetActive(enabled);
|
||||
}
|
||||
|
||||
private static void OnLayerSelected(int layer)
|
||||
{
|
||||
if (!(InspectorManager.Instance.m_activeInspector is GameObjectInspector instance)) return;
|
||||
|
||||
instance.TargetGO.layer = layer;
|
||||
}
|
||||
|
||||
private static void OnCompToggleClicked(int index, bool value)
|
||||
{
|
||||
var comp = s_compShortlist[index];
|
||||
|
||||
(comp as Behaviour).enabled = value;
|
||||
}
|
||||
|
||||
#region CHILD LIST
|
||||
|
||||
private static void OnChildListObjectClicked(int index)
|
||||
{
|
||||
if (!(InspectorManager.Instance.m_activeInspector is GameObjectInspector instance)) return;
|
||||
|
||||
if (index >= s_childrenShortlist.Count || !s_childrenShortlist[index])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
instance.ChangeInspectorTarget(s_childrenShortlist[index]);
|
||||
|
||||
instance.Update();
|
||||
}
|
||||
|
||||
private static void OnBackButtonClicked()
|
||||
{
|
||||
if (!(InspectorManager.Instance.m_activeInspector is GameObjectInspector instance)) return;
|
||||
|
||||
instance.ChangeInspectorTarget(instance.TargetGO.transform.parent.gameObject);
|
||||
}
|
||||
|
||||
private static void OnChildListPageTurn()
|
||||
{
|
||||
if (!(InspectorManager.Instance.m_activeInspector is GameObjectInspector instance)) return;
|
||||
|
||||
instance.RefreshChildObjectList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region COMPONENT LIST
|
||||
|
||||
private static void OnCompListObjectClicked(int index)
|
||||
{
|
||||
if (index >= s_compShortlist.Count || !s_compShortlist[index])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
InspectorManager.Instance.Inspect(s_compShortlist[index]);
|
||||
}
|
||||
|
||||
private static void OnCompListPageTurn()
|
||||
{
|
||||
if (!(InspectorManager.Instance.m_activeInspector is GameObjectInspector instance)) return;
|
||||
|
||||
instance.RefreshComponentList();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region UI CONSTRUCTION
|
||||
|
||||
private void ConstructUI()
|
||||
{
|
||||
var parent = InspectorManager.Instance.m_inspectorContent;
|
||||
|
||||
this.Content = UIFactory.CreateScrollView(parent, out GameObject scrollContent, new Color(0.1f, 0.1f, 0.1f, 1));
|
||||
m_content = UIFactory.CreateScrollView(parent, out GameObject scrollContent, new Color(0.1f, 0.1f, 0.1f));
|
||||
|
||||
var scrollLayout = scrollContent.GetComponent<VerticalLayoutGroup>();
|
||||
scrollLayout.childForceExpandHeight = false;
|
||||
scrollLayout.childControlHeight = true;
|
||||
scrollLayout.spacing = 5;
|
||||
var scrollGroup = scrollContent.GetComponent<VerticalLayoutGroup>();
|
||||
scrollGroup.childForceExpandHeight = false;
|
||||
scrollGroup.childControlHeight = true;
|
||||
scrollGroup.spacing = 5;
|
||||
|
||||
ConstructTopArea(scrollContent);
|
||||
|
||||
ConstructChildList(scrollContent);
|
||||
var midGroupObj = UIFactory.CreateHorizontalGroup(scrollContent, new Color(1,1,1,0));
|
||||
var midGroup = midGroupObj.GetComponent<HorizontalLayoutGroup>();
|
||||
midGroup.spacing = 5;
|
||||
midGroup.childForceExpandWidth = true;
|
||||
midGroup.childControlWidth = true;
|
||||
var midlayout = midGroupObj.AddComponent<LayoutElement>();
|
||||
midlayout.minHeight = 40;
|
||||
midlayout.flexibleHeight = 10000;
|
||||
midlayout.flexibleWidth = 25000;
|
||||
midlayout.minWidth = 200;
|
||||
|
||||
ConstructCompList(scrollContent);
|
||||
ConstructChildList(midGroupObj);
|
||||
ConstructCompList(midGroupObj);
|
||||
|
||||
ConstructControls(scrollContent);
|
||||
}
|
||||
|
||||
private void ConstructTopArea(GameObject scrollContent)
|
||||
{
|
||||
// path row
|
||||
|
||||
m_pathGroupObj = UIFactory.CreateHorizontalGroup(scrollContent, new Color(0.1f, 0.1f, 0.1f));
|
||||
var pathGroup = m_pathGroupObj.GetComponent<HorizontalLayoutGroup>();
|
||||
pathGroup.childForceExpandHeight = false;
|
||||
pathGroup.childForceExpandWidth = false;
|
||||
pathGroup.childControlHeight = false;
|
||||
pathGroup.childControlWidth = true;
|
||||
pathGroup.spacing = 5;
|
||||
var pathRect = m_pathGroupObj.GetComponent<RectTransform>();
|
||||
pathRect.sizeDelta = new Vector2(pathRect.sizeDelta.x, 20);
|
||||
var pathLayout = m_pathGroupObj.AddComponent<LayoutElement>();
|
||||
pathLayout.minHeight = 20;
|
||||
pathLayout.flexibleHeight = 75;
|
||||
|
||||
var backButtonObj = UIFactory.CreateButton(m_pathGroupObj);
|
||||
var backButton = backButtonObj.GetComponent<Button>();
|
||||
#if CPP
|
||||
backButton.onClick.AddListener(new Action(OnBackButtonClicked));
|
||||
#else
|
||||
backButton.onClick.AddListener(OnBackButtonClicked());
|
||||
#endif
|
||||
var backText = backButtonObj.GetComponentInChildren<Text>();
|
||||
backText.text = "<";
|
||||
var backLayout = backButtonObj.AddComponent<LayoutElement>();
|
||||
backLayout.minWidth = 55;
|
||||
backLayout.flexibleWidth = 0;
|
||||
backLayout.minHeight = 25;
|
||||
backLayout.flexibleHeight = 0;
|
||||
|
||||
var pathHiddenTextObj = UIFactory.CreateLabel(m_pathGroupObj, TextAnchor.MiddleLeft);
|
||||
m_hiddenPathText = pathHiddenTextObj.GetComponent<Text>();
|
||||
m_hiddenPathText.color = Color.clear;
|
||||
m_hiddenPathText.fontSize = 14;
|
||||
m_hiddenPathText.raycastTarget = false;
|
||||
var hiddenFitter = pathHiddenTextObj.AddComponent<ContentSizeFitter>();
|
||||
hiddenFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
var hiddenLayout = pathHiddenTextObj.AddComponent<LayoutElement>();
|
||||
hiddenLayout.minHeight = 25;
|
||||
hiddenLayout.flexibleHeight = 75;
|
||||
hiddenLayout.minWidth = 400;
|
||||
hiddenLayout.flexibleWidth = 9000;
|
||||
var hiddenGroup = pathHiddenTextObj.AddComponent<HorizontalLayoutGroup>();
|
||||
hiddenGroup.childForceExpandWidth = true;
|
||||
hiddenGroup.childControlWidth = true;
|
||||
hiddenGroup.childForceExpandHeight = true;
|
||||
hiddenGroup.childControlHeight = true;
|
||||
|
||||
var pathInputObj = UIFactory.CreateTMPInput(pathHiddenTextObj, 14, 0, (int)TextAlignmentOptions.MidlineLeft);
|
||||
var pathInputRect = pathInputObj.GetComponent<RectTransform>();
|
||||
pathInputRect.sizeDelta = new Vector2(pathInputRect.sizeDelta.x, 25);
|
||||
m_pathInput = pathInputObj.GetComponent<TMP_InputField>();
|
||||
m_pathInput.text = TargetGO.transform.GetTransformPath();
|
||||
m_pathInput.readOnly = true;
|
||||
var pathInputLayout = pathInputObj.AddComponent<LayoutElement>();
|
||||
pathInputLayout.minHeight = 25;
|
||||
pathInputLayout.flexibleHeight = 75;
|
||||
pathInputLayout.preferredWidth = 400;
|
||||
pathInputLayout.flexibleWidth = 9999;
|
||||
|
||||
// name row
|
||||
|
||||
var nameObj = UIFactory.CreateHorizontalGroup(scrollContent, new Color(0.1f, 0.1f, 0.1f));
|
||||
var nameGroup = nameObj.GetComponent<HorizontalLayoutGroup>();
|
||||
var nameRowObj = UIFactory.CreateHorizontalGroup(scrollContent, new Color(0.1f, 0.1f, 0.1f));
|
||||
var nameGroup = nameRowObj.GetComponent<HorizontalLayoutGroup>();
|
||||
nameGroup.childForceExpandHeight = false;
|
||||
nameGroup.childForceExpandWidth = false;
|
||||
nameGroup.childControlHeight = false;
|
||||
nameGroup.childControlWidth = true;
|
||||
var nameRect = nameObj.GetComponent<RectTransform>();
|
||||
nameGroup.spacing = 5;
|
||||
var nameRect = nameRowObj.GetComponent<RectTransform>();
|
||||
nameRect.sizeDelta = new Vector2(nameRect.sizeDelta.x, 25);
|
||||
var nameLayout = nameObj.AddComponent<LayoutElement>();
|
||||
var nameLayout = nameRowObj.AddComponent<LayoutElement>();
|
||||
nameLayout.minHeight = 25;
|
||||
nameLayout.flexibleHeight = 0;
|
||||
|
||||
var nameTextObj = UIFactory.CreateTMPLabel(nameObj, TextAlignmentOptions.Left);
|
||||
var nameTextObj = UIFactory.CreateTMPLabel(nameRowObj, TextAlignmentOptions.Midline);
|
||||
var nameTextText = nameTextObj.GetComponent<TextMeshProUGUI>();
|
||||
nameTextText.text = "Name:";
|
||||
nameTextText.fontSize = 14;
|
||||
nameTextText.color = Color.grey;
|
||||
var nameTextLayout = nameTextObj.AddComponent<LayoutElement>();
|
||||
nameTextLayout.minHeight = 25;
|
||||
nameTextLayout.flexibleHeight = 0;
|
||||
nameTextLayout.minWidth = 60;
|
||||
nameTextLayout.minWidth = 55;
|
||||
nameTextLayout.flexibleWidth = 0;
|
||||
|
||||
var nameInputObj = UIFactory.CreateTMPInput(nameObj, 14, 0, (int)TextAlignmentOptions.MidlineLeft);
|
||||
var nameInputObj = UIFactory.CreateTMPInput(nameRowObj, 14, 0, (int)TextAlignmentOptions.MidlineLeft);
|
||||
var nameInputRect = nameInputObj.GetComponent<RectTransform>();
|
||||
nameInputRect.sizeDelta = new Vector2(nameInputRect.sizeDelta.x, 25);
|
||||
m_nameInput = nameInputObj.GetComponent<TMP_InputField>();
|
||||
m_nameInput.text = TargetGO.name;
|
||||
m_nameInput.lineType = TMP_InputField.LineType.SingleLine;
|
||||
|
||||
var applyNameBtnObj = UIFactory.CreateButton(nameObj);
|
||||
var applyNameBtnObj = UIFactory.CreateButton(nameRowObj);
|
||||
var applyNameBtn = applyNameBtnObj.GetComponent<Button>();
|
||||
applyNameBtn.onClick.AddListener(new Action(() =>
|
||||
{
|
||||
TargetGO.name = m_nameInput.text;
|
||||
}));
|
||||
#if CPP
|
||||
applyNameBtn.onClick.AddListener(new Action(() => { ApplyNameClicked(); }));
|
||||
#else
|
||||
applyNameBtn.onClick.AddListener(() => { ApplyNameClicked(); });
|
||||
#endif
|
||||
var applyNameText = applyNameBtnObj.GetComponentInChildren<Text>();
|
||||
applyNameText.text = "Apply";
|
||||
applyNameText.fontSize = 14;
|
||||
@ -131,137 +529,319 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
||||
var applyNameRect = applyNameBtnObj.GetComponent<RectTransform>();
|
||||
applyNameRect.sizeDelta = new Vector2(applyNameRect.sizeDelta.x, 25);
|
||||
|
||||
// path row
|
||||
var activeLabel = UIFactory.CreateLabel(nameRowObj, TextAnchor.MiddleCenter);
|
||||
var activeLabelLayout = activeLabel.AddComponent<LayoutElement>();
|
||||
activeLabelLayout.minWidth = 55;
|
||||
activeLabelLayout.minHeight = 25;
|
||||
var activeText = activeLabel.GetComponent<Text>();
|
||||
activeText.text = "Active:";
|
||||
activeText.color = Color.grey;
|
||||
activeText.fontSize = 14;
|
||||
|
||||
var pathObj = UIFactory.CreateHorizontalGroup(scrollContent, new Color(0.1f, 0.1f, 0.1f));
|
||||
var pathGroup = pathObj.GetComponent<HorizontalLayoutGroup>();
|
||||
pathGroup.childForceExpandHeight = false;
|
||||
pathGroup.childForceExpandWidth = false;
|
||||
pathGroup.childControlHeight = false;
|
||||
pathGroup.childControlWidth = true;
|
||||
var pathRect = pathObj.GetComponent<RectTransform>();
|
||||
pathRect.sizeDelta = new Vector2(pathRect.sizeDelta.x, 25);
|
||||
var pathLayout = pathObj.AddComponent<LayoutElement>();
|
||||
pathLayout.minHeight = 25;
|
||||
pathLayout.flexibleHeight = 0;
|
||||
var enabledToggleObj = UIFactory.CreateToggle(nameRowObj, out m_enabledToggle, out m_enabledText);
|
||||
var toggleLayout = enabledToggleObj.AddComponent<LayoutElement>();
|
||||
toggleLayout.minHeight = 25;
|
||||
toggleLayout.minWidth = 100;
|
||||
toggleLayout.flexibleWidth = 0;
|
||||
m_enabledText.text = "Enabled";
|
||||
m_enabledText.color = Color.green;
|
||||
#if CPP
|
||||
m_enabledToggle.onValueChanged.AddListener(new Action<bool>(OnEnableToggled));
|
||||
#else
|
||||
m_enabledToggle.onValueChanged.AddListener(OnEnableToggled);
|
||||
#endif
|
||||
|
||||
var pathTextObj = UIFactory.CreateTMPLabel(pathObj, TextAlignmentOptions.Left);
|
||||
var pathTextText = pathTextObj.GetComponent<TextMeshProUGUI>();
|
||||
pathTextText.text = "Path:";
|
||||
pathTextText.fontSize = 14;
|
||||
var pathTextLayout = pathTextObj.AddComponent<LayoutElement>();
|
||||
pathTextLayout.minHeight = 25;
|
||||
pathTextLayout.flexibleHeight = 0;
|
||||
pathTextLayout.minWidth = 60;
|
||||
pathTextLayout.flexibleWidth = 0;
|
||||
// layer and scene row
|
||||
|
||||
// TODO back button here (if has parent)
|
||||
var sceneLayerRow = UIFactory.CreateHorizontalGroup(scrollContent, new Color(0.1f, 0.1f, 0.1f));
|
||||
var sceneLayerGroup = sceneLayerRow.GetComponent<HorizontalLayoutGroup>();
|
||||
sceneLayerGroup.childForceExpandWidth = false;
|
||||
sceneLayerGroup.childControlWidth = true;
|
||||
sceneLayerGroup.spacing = 5;
|
||||
|
||||
var pathInputObj = UIFactory.CreateTMPInput(pathObj, 14, 0, (int)TextAlignmentOptions.MidlineLeft);
|
||||
var pathInputRect = pathInputObj.GetComponent<RectTransform>();
|
||||
pathInputRect.sizeDelta = new Vector2(pathInputRect.sizeDelta.x, 25);
|
||||
m_pathInput = pathInputObj.GetComponent<TMP_InputField>();
|
||||
m_pathInput.text = TargetGO.transform.GetTransformPath();
|
||||
var pathInputLayout = pathInputObj.AddComponent<LayoutElement>();
|
||||
pathInputLayout.minHeight = 25;
|
||||
pathInputLayout.flexibleHeight = 0;
|
||||
var layerLabel = UIFactory.CreateLabel(sceneLayerRow, TextAnchor. MiddleCenter);
|
||||
var layerText = layerLabel.GetComponent<Text>();
|
||||
layerText.text = "Layer:";
|
||||
layerText.fontSize = 14;
|
||||
layerText.color = Color.grey;
|
||||
var layerTextLayout = layerLabel.AddComponent<LayoutElement>();
|
||||
layerTextLayout.minWidth = 55;
|
||||
layerTextLayout.flexibleWidth = 0;
|
||||
|
||||
var applyPathBtnObj = UIFactory.CreateButton(pathObj);
|
||||
var applyPathBtn = applyPathBtnObj.GetComponent<Button>();
|
||||
applyNameBtn.onClick.AddListener(new Action(() =>
|
||||
var layerDropdownObj = UIFactory.CreateDropdown(sceneLayerRow, out m_layerDropdown);
|
||||
m_layerDropdown.options.Clear();
|
||||
for (int i = 0; i < 32; i++)
|
||||
{
|
||||
ExplorerCore.Log("TODO");
|
||||
}));
|
||||
var applyPathText = applyPathBtnObj.GetComponentInChildren<Text>();
|
||||
applyPathText.text = "Apply";
|
||||
applyPathText.fontSize = 14;
|
||||
var applyBtnLayout = applyPathBtnObj.AddComponent<LayoutElement>();
|
||||
applyBtnLayout.minWidth = 65;
|
||||
applyBtnLayout.minHeight = 25;
|
||||
applyBtnLayout.flexibleHeight = 0;
|
||||
var applyBtnRect = applyPathBtnObj.GetComponent<RectTransform>();
|
||||
applyBtnRect.sizeDelta = new Vector2(applyNameRect.sizeDelta.x, 25);
|
||||
var layer = LayerMaskUnstrip.LayerToName(i);
|
||||
m_layerDropdown.options.Add(new Dropdown.OptionData { text = $"{i}: {layer}" });
|
||||
}
|
||||
var itemText = layerDropdownObj.transform.Find("Label").GetComponent<Text>();
|
||||
itemText.resizeTextForBestFit = true;
|
||||
var layerDropdownLayout = layerDropdownObj.AddComponent<LayoutElement>();
|
||||
layerDropdownLayout.minWidth = 120;
|
||||
layerDropdownLayout.flexibleWidth = 2000;
|
||||
layerDropdownLayout.minHeight = 25;
|
||||
#if CPP
|
||||
m_layerDropdown.onValueChanged.AddListener(new Action<int>(OnLayerSelected));
|
||||
#else
|
||||
m_layerDropdown.onValueChanged.AddListener(OnLayerSelected);
|
||||
#endif
|
||||
|
||||
var scenelabelObj = UIFactory.CreateLabel(sceneLayerRow, TextAnchor.MiddleCenter);
|
||||
var sceneLabel = scenelabelObj.GetComponent<Text>();
|
||||
sceneLabel.text = "Scene:";
|
||||
sceneLabel.color = Color.grey;
|
||||
sceneLabel.fontSize = 14;
|
||||
var sceneLabelLayout = scenelabelObj.AddComponent<LayoutElement>();
|
||||
sceneLabelLayout.minWidth = 55;
|
||||
sceneLabelLayout.flexibleWidth = 0;
|
||||
|
||||
var objectSceneText = UIFactory.CreateLabel(sceneLayerRow, TextAnchor.MiddleLeft);
|
||||
m_sceneText = objectSceneText.GetComponent<Text>();
|
||||
m_sceneText.fontSize = 14;
|
||||
m_sceneText.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||
var sceneTextLayout = objectSceneText.AddComponent<LayoutElement>();
|
||||
sceneTextLayout.minWidth = 120;
|
||||
sceneTextLayout.flexibleWidth = 2000;
|
||||
}
|
||||
|
||||
private void ConstructChildList(GameObject scrollContent)
|
||||
private void ConstructChildList(GameObject parent)
|
||||
{
|
||||
// todo put this in a RefreshChildren method, and use page handler
|
||||
var vertGroupObj = UIFactory.CreateVerticalGroup(parent, new Color(1,1,1,0));
|
||||
var vertGroup = vertGroupObj.GetComponent<VerticalLayoutGroup>();
|
||||
vertGroup.childForceExpandHeight = false;
|
||||
vertGroup.childForceExpandWidth = false;
|
||||
vertGroup.childControlWidth = true;
|
||||
var vertLayout = vertGroupObj.AddComponent<LayoutElement>();
|
||||
vertLayout.minWidth = 120;
|
||||
vertLayout.flexibleWidth = 25000;
|
||||
|
||||
var childTitleObj = UIFactory.CreateLabel(scrollContent, TextAnchor.MiddleLeft);
|
||||
var childTitleObj = UIFactory.CreateLabel(vertGroupObj, TextAnchor.MiddleLeft);
|
||||
var childTitleText = childTitleObj.GetComponent<Text>();
|
||||
childTitleText.text = "Children:";
|
||||
childTitleText.text = "Children";
|
||||
childTitleText.color = Color.grey;
|
||||
childTitleText.fontSize = 14;
|
||||
var childTitleLayout = childTitleObj.AddComponent<LayoutElement>();
|
||||
childTitleLayout.minHeight = 30;
|
||||
|
||||
var childrenScrollObj = UIFactory.CreateScrollView(scrollContent, out GameObject subContent, new Color(0.15f, 0.15f, 0.15f));
|
||||
var childrenScrollObj = UIFactory.CreateScrollView(vertGroupObj, out s_childListContent, new Color(0.07f, 0.07f, 0.07f));
|
||||
var contentLayout = childrenScrollObj.AddComponent<LayoutElement>();
|
||||
contentLayout.minHeight = 50;
|
||||
contentLayout.flexibleHeight = 10000;
|
||||
|
||||
var contentGroup = subContent.GetComponent<VerticalLayoutGroup>();
|
||||
contentGroup.spacing = 4;
|
||||
var horiScroll = childrenScrollObj.transform.Find("Scrollbar Horizontal");
|
||||
horiScroll.gameObject.SetActive(false);
|
||||
|
||||
for (int i = 0; i < TargetGO.transform.childCount; i++)
|
||||
{
|
||||
var child = TargetGO.transform.GetChild(i);
|
||||
var scrollRect = childrenScrollObj.GetComponentInChildren<ScrollRect>();
|
||||
scrollRect.horizontalScrollbar = null;
|
||||
|
||||
var buttonObj = UIFactory.CreateButton(subContent);
|
||||
var childGroup = s_childListContent.GetComponent<VerticalLayoutGroup>();
|
||||
childGroup.childControlHeight = true;
|
||||
childGroup.spacing = 2;
|
||||
|
||||
var btnImage = buttonObj.GetComponent<Image>();
|
||||
btnImage.color = new Color(0.15f, 0.15f, 0.15f);
|
||||
|
||||
var button = buttonObj.GetComponent<Button>();
|
||||
button.onClick.AddListener(new Action(() =>
|
||||
{
|
||||
ChangeInspectorTarget(child?.gameObject);
|
||||
}));
|
||||
|
||||
var buttonText = buttonObj.GetComponentInChildren<Text>();
|
||||
var text = child.name;
|
||||
if (child.childCount > 0)
|
||||
text = $"<color=grey>[{child.childCount}]</color> {text}";
|
||||
buttonText.text = text;
|
||||
buttonText.color = child.gameObject.activeSelf ? Color.green : Color.red;
|
||||
}
|
||||
s_childListPageHandler = new PageHandler();
|
||||
s_childListPageHandler.ConstructUI(vertGroupObj);
|
||||
s_childListPageHandler.OnPageChanged += OnChildListPageTurn;
|
||||
}
|
||||
|
||||
private void ConstructCompList(GameObject scrollContent)
|
||||
private void AddChildListButton()
|
||||
{
|
||||
// todo put this in a RefreshComponents method, and use page handler
|
||||
int thisIndex = s_childListTexts.Count;
|
||||
|
||||
var compTitleObj = UIFactory.CreateLabel(scrollContent, TextAnchor.MiddleLeft);
|
||||
GameObject btnGroupObj = UIFactory.CreateHorizontalGroup(s_childListContent, new Color(0.1f, 0.1f, 0.1f));
|
||||
HorizontalLayoutGroup btnGroup = btnGroupObj.GetComponent<HorizontalLayoutGroup>();
|
||||
btnGroup.childForceExpandWidth = true;
|
||||
btnGroup.childControlWidth = true;
|
||||
btnGroup.childForceExpandHeight = false;
|
||||
btnGroup.childControlHeight = true;
|
||||
LayoutElement btnLayout = btnGroupObj.AddComponent<LayoutElement>();
|
||||
btnLayout.flexibleWidth = 320;
|
||||
btnLayout.minHeight = 25;
|
||||
btnLayout.flexibleHeight = 0;
|
||||
btnGroupObj.AddComponent<Mask>();
|
||||
|
||||
GameObject mainButtonObj = UIFactory.CreateButton(btnGroupObj);
|
||||
LayoutElement mainBtnLayout = mainButtonObj.AddComponent<LayoutElement>();
|
||||
mainBtnLayout.minHeight = 25;
|
||||
mainBtnLayout.flexibleHeight = 0;
|
||||
mainBtnLayout.minWidth = 240;
|
||||
mainBtnLayout.flexibleWidth = 0;
|
||||
Button mainBtn = mainButtonObj.GetComponent<Button>();
|
||||
ColorBlock mainColors = mainBtn.colors;
|
||||
mainColors.normalColor = new Color(0.07f, 0.07f, 0.07f);
|
||||
mainColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f, 1);
|
||||
mainBtn.colors = mainColors;
|
||||
#if CPP
|
||||
mainBtn.onClick.AddListener(new Action(() => { OnChildListObjectClicked(thisIndex); }));
|
||||
#else
|
||||
mainBtn.onClick.AddListener(() => { OnChildListObjectClicked(thisIndex); });
|
||||
#endif
|
||||
|
||||
Text mainText = mainButtonObj.GetComponentInChildren<Text>();
|
||||
mainText.alignment = TextAnchor.MiddleLeft;
|
||||
mainText.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||
s_childListTexts.Add(mainText);
|
||||
}
|
||||
|
||||
private void ConstructCompList(GameObject parent)
|
||||
{
|
||||
var vertGroupObj = UIFactory.CreateVerticalGroup(parent, new Color(1, 1, 1, 0));
|
||||
var vertGroup = vertGroupObj.GetComponent<VerticalLayoutGroup>();
|
||||
vertGroup.childForceExpandHeight = false;
|
||||
vertGroup.childForceExpandWidth = false;
|
||||
vertGroup.childControlWidth = true;
|
||||
var vertLayout = vertGroupObj.AddComponent<LayoutElement>();
|
||||
vertLayout.minWidth = 120;
|
||||
vertLayout.flexibleWidth = 25000;
|
||||
|
||||
var compTitleObj = UIFactory.CreateLabel(vertGroupObj, TextAnchor.MiddleLeft);
|
||||
var compTitleText = compTitleObj.GetComponent<Text>();
|
||||
compTitleText.text = "Components:";
|
||||
compTitleText.text = "Components";
|
||||
compTitleText.color = Color.grey;
|
||||
compTitleText.fontSize = 14;
|
||||
var childTitleLayout = compTitleObj.AddComponent<LayoutElement>();
|
||||
childTitleLayout.minHeight = 30;
|
||||
|
||||
var compScrollObj = UIFactory.CreateScrollView(scrollContent, out GameObject subContent, new Color(0.15f, 0.15f, 0.15f));
|
||||
var compScrollObj = UIFactory.CreateScrollView(vertGroupObj, out s_compListContent, new Color(0.07f, 0.07f, 0.07f));
|
||||
var contentLayout = compScrollObj.AddComponent<LayoutElement>();
|
||||
contentLayout.minHeight = 50;
|
||||
contentLayout.flexibleHeight = 10000;
|
||||
|
||||
var contentGroup = subContent.GetComponent<VerticalLayoutGroup>();
|
||||
contentGroup.spacing = 4;
|
||||
var contentGroup = s_compListContent.GetComponent<VerticalLayoutGroup>();
|
||||
contentGroup.childControlHeight = true;
|
||||
contentGroup.spacing = 2;
|
||||
|
||||
foreach (var comp in TargetGO.GetComponents<Component>())
|
||||
{
|
||||
var buttonObj = UIFactory.CreateButton(subContent);
|
||||
var horiScroll = compScrollObj.transform.Find("Scrollbar Horizontal");
|
||||
horiScroll.gameObject.SetActive(false);
|
||||
|
||||
var btnImage = buttonObj.GetComponent<Image>();
|
||||
btnImage.color = new Color(0.15f, 0.15f, 0.15f);
|
||||
var scrollRect = compScrollObj.GetComponentInChildren<ScrollRect>();
|
||||
scrollRect.horizontalScrollbar = null;
|
||||
|
||||
var button = buttonObj.GetComponent<Button>();
|
||||
button.onClick.AddListener(new Action(() =>
|
||||
{
|
||||
InspectorManager.Instance.Inspect(comp);
|
||||
}));
|
||||
|
||||
var buttonText = buttonObj.GetComponentInChildren<Text>();
|
||||
buttonText.text = ReflectionHelpers.GetActualType(comp).FullName;
|
||||
s_compListPageHandler = new PageHandler();
|
||||
s_compListPageHandler.ConstructUI(vertGroupObj);
|
||||
s_compListPageHandler.OnPageChanged += OnCompListPageTurn;
|
||||
}
|
||||
|
||||
private void AddCompListButton()
|
||||
{
|
||||
int thisIndex = s_compListTexts.Count;
|
||||
|
||||
GameObject btnGroupObj = UIFactory.CreateHorizontalGroup(s_compListContent, new Color(0.07f, 0.07f, 0.07f));
|
||||
HorizontalLayoutGroup btnGroup = btnGroupObj.GetComponent<HorizontalLayoutGroup>();
|
||||
btnGroup.childForceExpandWidth = false;
|
||||
btnGroup.childControlWidth = true;
|
||||
btnGroup.childForceExpandHeight = false;
|
||||
btnGroup.childControlHeight = true;
|
||||
btnGroup.childAlignment = TextAnchor.MiddleLeft;
|
||||
LayoutElement btnLayout = btnGroupObj.AddComponent<LayoutElement>();
|
||||
btnLayout.flexibleWidth = 320;
|
||||
btnLayout.minHeight = 25;
|
||||
btnLayout.flexibleHeight = 0;
|
||||
btnGroupObj.AddComponent<Mask>();
|
||||
|
||||
var toggleObj = UIFactory.CreateToggle(btnGroupObj, out Toggle toggle, out Text toggleText);
|
||||
var togBg = toggleObj.transform.Find("Background").GetComponent<Image>();
|
||||
togBg.color = new Color(0.1f, 0.1f, 0.1f, 1);
|
||||
var toggleLayout = toggleObj.AddComponent<LayoutElement>();
|
||||
toggleLayout.minWidth = 25;
|
||||
toggleLayout.flexibleWidth = 0;
|
||||
toggleLayout.minHeight = 25;
|
||||
toggleLayout.flexibleHeight = 0;
|
||||
#if CPP
|
||||
toggle.onValueChanged.AddListener(new Action<bool>((bool val) => { OnCompToggleClicked(thisIndex, val); }));
|
||||
#else
|
||||
toggle.onValueChanged.AddListener((bool val) => { OnCompToggleClicked(thisIndex, val); });
|
||||
#endif
|
||||
toggleText.text = "";
|
||||
s_compToggles.Add(toggle);
|
||||
|
||||
GameObject mainButtonObj = UIFactory.CreateButton(btnGroupObj);
|
||||
LayoutElement mainBtnLayout = mainButtonObj.AddComponent<LayoutElement>();
|
||||
mainBtnLayout.minHeight = 25;
|
||||
mainBtnLayout.flexibleHeight = 0;
|
||||
mainBtnLayout.minWidth = 240;
|
||||
mainBtnLayout.flexibleWidth = 999;
|
||||
Button mainBtn = mainButtonObj.GetComponent<Button>();
|
||||
ColorBlock mainColors = mainBtn.colors;
|
||||
mainColors.normalColor = new Color(0.07f, 0.07f, 0.07f);
|
||||
mainColors.highlightedColor = new Color(0.2f, 0.2f, 0.2f, 1);
|
||||
mainBtn.colors = mainColors;
|
||||
#if CPP
|
||||
mainBtn.onClick.AddListener(new Action(() => { OnCompListObjectClicked(thisIndex); }));
|
||||
#else
|
||||
mainBtn.onClick.AddListener(() => { OnCompListObjectClicked(thisIndex); });
|
||||
#endif
|
||||
|
||||
Text mainText = mainButtonObj.GetComponentInChildren<Text>();
|
||||
mainText.alignment = TextAnchor.MiddleLeft;
|
||||
mainText.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||
mainText.color = Syntax.Class_Instance.ToColor();
|
||||
s_compListTexts.Add(mainText);
|
||||
}
|
||||
|
||||
private const int CONTROLS_MAX_HEIGHT = 220;
|
||||
|
||||
private void ConstructControls(GameObject scrollContent)
|
||||
{
|
||||
// todo GO controls
|
||||
var controlsObj = UIFactory.CreateVerticalGroup(scrollContent, new Color(0.07f, 0.07f, 0.07f));
|
||||
var controlsGroup = controlsObj.GetComponent<VerticalLayoutGroup>();
|
||||
controlsGroup.childForceExpandWidth = false;
|
||||
controlsGroup.childControlWidth = true;
|
||||
controlsGroup.childForceExpandHeight = false;
|
||||
var controlsLayout = controlsObj.AddComponent<LayoutElement>();
|
||||
controlsLayout.minHeight = CONTROLS_MAX_HEIGHT;
|
||||
controlsLayout.flexibleHeight = 0;
|
||||
controlsLayout.minWidth = 250;
|
||||
controlsLayout.flexibleWidth = 9000;
|
||||
|
||||
// ~~~~~~ Top row ~~~~~~
|
||||
|
||||
var topRow = UIFactory.CreateHorizontalGroup(controlsObj, new Color(1, 1, 1, 0));
|
||||
var topRowGroup = topRow.GetComponent<HorizontalLayoutGroup>();
|
||||
topRowGroup.childForceExpandWidth = false;
|
||||
topRowGroup.childControlWidth = true;
|
||||
topRowGroup.childForceExpandHeight = false;
|
||||
topRowGroup.childControlHeight = true;
|
||||
topRowGroup.spacing = 5;
|
||||
|
||||
var hideButtonObj = UIFactory.CreateButton(topRow);
|
||||
var hideButton = hideButtonObj.GetComponent<Button>();
|
||||
var hideText = hideButtonObj.GetComponentInChildren<Text>();
|
||||
hideText.text = "v";
|
||||
var hideButtonLayout = hideButtonObj.AddComponent<LayoutElement>();
|
||||
hideButtonLayout.minWidth = 40;
|
||||
hideButtonLayout.flexibleWidth = 0;
|
||||
hideButtonLayout.minHeight = 25;
|
||||
hideButtonLayout.flexibleHeight = 0;
|
||||
#if CPP
|
||||
hideButton.onClick.AddListener(new Action(OnHideClicked));
|
||||
#else
|
||||
hideButton.onClick.AddListener(OnHideClicked);
|
||||
#endif
|
||||
void OnHideClicked()
|
||||
{
|
||||
if (controlsLayout.minHeight > 25)
|
||||
{
|
||||
hideText.text = "^";
|
||||
controlsLayout.minHeight = 25;
|
||||
}
|
||||
else
|
||||
{
|
||||
hideText.text = "v";
|
||||
controlsLayout.minHeight = CONTROLS_MAX_HEIGHT;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
var topTitle = UIFactory.CreateLabel(topRow, TextAnchor.MiddleLeft);
|
||||
var topText = topTitle.GetComponent<Text>();
|
||||
topText.text = "GameObject Controls";
|
||||
var titleLayout = topTitle.AddComponent<LayoutElement>();
|
||||
titleLayout.minWidth = 100;
|
||||
titleLayout.flexibleWidth = 9500;
|
||||
titleLayout.minHeight = 25;
|
||||
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,7 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Inspectors
|
||||
namespace UnityExplorer.UI.Main.Inspectors
|
||||
{
|
||||
public abstract class InspectorBase
|
||||
{
|
||||
@ -12,7 +12,7 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
||||
|
||||
public abstract string TabLabel { get; }
|
||||
|
||||
public GameObject Content;
|
||||
public abstract GameObject Content { get; set; }
|
||||
public Button tabButton;
|
||||
public Text tabText;
|
||||
|
||||
@ -54,10 +54,10 @@ namespace ExplorerBeta.UI.Main.Inspectors
|
||||
GameObject.Destroy(tabGroup);
|
||||
}
|
||||
|
||||
if (Content)
|
||||
{
|
||||
GameObject.Destroy(Content);
|
||||
}
|
||||
//if (Content)
|
||||
//{
|
||||
// GameObject.Destroy(Content);
|
||||
//}
|
||||
|
||||
int thisIndex = -1;
|
||||
if (InspectorManager.Instance.m_currentInspectors.Contains(this))
|
||||
|
@ -1,7 +1,7 @@
|
||||
using System;
|
||||
using ExplorerBeta.Helpers;
|
||||
using UnityExplorer.Helpers;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Inspectors
|
||||
namespace UnityExplorer.UI.Main.Inspectors
|
||||
{
|
||||
public class InstanceInspector : ReflectionInspector
|
||||
{
|
||||
|
@ -2,14 +2,22 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using ExplorerBeta.Helpers;
|
||||
using UnityExplorer.Helpers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Inspectors
|
||||
namespace UnityExplorer.UI.Main.Inspectors
|
||||
{
|
||||
public class ReflectionInspector : InspectorBase
|
||||
{
|
||||
public override string TabLabel => m_targetTypeShortName;
|
||||
|
||||
private GameObject m_content;
|
||||
public override GameObject Content
|
||||
{
|
||||
get => m_content;
|
||||
set => m_content = value;
|
||||
}
|
||||
|
||||
private readonly string m_targetTypeShortName;
|
||||
|
||||
public ReflectionInspector(object target) : base(target)
|
||||
|
@ -1,6 +1,6 @@
|
||||
using System;
|
||||
|
||||
namespace ExplorerBeta.UI.Main.Inspectors
|
||||
namespace UnityExplorer.UI.Main.Inspectors
|
||||
{
|
||||
public class StaticInspector : ReflectionInspector
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using ExplorerBeta.UI.Main.Console;
|
||||
using UnityExplorer.UI.Main.Console;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ExplorerBeta.UI.Main
|
||||
namespace UnityExplorer.UI.Main
|
||||
{
|
||||
public class MainMenu
|
||||
{
|
||||
@ -117,7 +117,7 @@ namespace ExplorerBeta.UI.Main
|
||||
|
||||
RectTransform panelRect = MainPanel.GetComponent<RectTransform>();
|
||||
panelRect.anchorMin = new Vector2(0.25f, 0.1f);
|
||||
panelRect.anchorMax = new Vector2(0.75f, 0.95f);
|
||||
panelRect.anchorMax = new Vector2(0.78f, 0.95f);
|
||||
|
||||
ConstructTitleBar(content);
|
||||
|
||||
@ -125,11 +125,6 @@ namespace ExplorerBeta.UI.Main
|
||||
|
||||
ConstructMainViewport(content);
|
||||
|
||||
ConstructDebugConsole(content);
|
||||
}
|
||||
|
||||
private void ConstructDebugConsole(GameObject content)
|
||||
{
|
||||
new DebugConsole(content);
|
||||
}
|
||||
|
||||
@ -158,7 +153,7 @@ namespace ExplorerBeta.UI.Main
|
||||
GameObject textObj = UIFactory.CreateLabel(titleBar, TextAnchor.MiddleLeft);
|
||||
|
||||
Text text = textObj.GetComponent<Text>();
|
||||
text.text = $"<b>Explorer</b> <i>v{ExplorerCore.VERSION}</i>";
|
||||
text.text = $"<b>UnityExplorer</b> <i>v{ExplorerCore.VERSION}</i>";
|
||||
text.resizeTextForBestFit = true;
|
||||
text.resizeTextMinSize = 12;
|
||||
text.resizeTextMaxSize = 20;
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace ExplorerBeta.UI.Main
|
||||
namespace UnityExplorer.UI.Main
|
||||
{
|
||||
public class OptionsPage : MainMenu.Page
|
||||
{
|
||||
|
@ -2,13 +2,13 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using ExplorerBeta.Input;
|
||||
using UnityExplorer.Input;
|
||||
using System.IO;
|
||||
#if CPP
|
||||
using ExplorerBeta.Unstrip.ImageConversion;
|
||||
using UnityExplorer.Unstrip.ImageConversion;
|
||||
#endif
|
||||
|
||||
namespace ExplorerBeta.UI.Main
|
||||
namespace UnityExplorer.UI.Main
|
||||
{
|
||||
// Handles dragging and resizing for the main explorer window.
|
||||
|
||||
|
@ -1,15 +1,15 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using ExplorerBeta.Helpers;
|
||||
using ExplorerBeta.UI.Main.Inspectors;
|
||||
using ExplorerBeta.UI.Shared;
|
||||
using UnityExplorer.Helpers;
|
||||
using UnityExplorer.UI.Main.Inspectors;
|
||||
using UnityExplorer.UI.Shared;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using ExplorerBeta.Unstrip.Scenes;
|
||||
using UnityExplorer.Unstrip.Scenes;
|
||||
|
||||
namespace ExplorerBeta.UI.Main
|
||||
namespace UnityExplorer.UI.Main
|
||||
{
|
||||
public class SceneExplorer
|
||||
{
|
||||
@ -28,30 +28,36 @@ namespace ExplorerBeta.UI.Main
|
||||
private int m_currentSceneHandle = -1;
|
||||
private int m_lastCount;
|
||||
|
||||
public PageHandler m_sceneListPageHandler;
|
||||
|
||||
private GameObject[] m_allSceneListObjects = new GameObject[0];
|
||||
private readonly List<GameObject> m_sceneShortList = new List<GameObject>();
|
||||
private readonly List<Text> m_sceneListTexts = new List<Text>();
|
||||
|
||||
public static int DontDestroyHandle;
|
||||
|
||||
private GameObject m_sceneListCanvas;
|
||||
private Dropdown m_sceneDropdown;
|
||||
private Text m_scenePathText;
|
||||
private GameObject m_mainInspectBtn;
|
||||
private GameObject m_backButtonObj;
|
||||
|
||||
//private readonly Dictionary<string, int> m_sceneHandles = new Dictionary<string, int>();
|
||||
public PageHandler m_sceneListPageHandler;
|
||||
|
||||
private GameObject[] m_allSceneListObjects = new GameObject[0];
|
||||
private readonly List<GameObject> m_sceneShortList = new List<GameObject>();
|
||||
private GameObject m_sceneListContent;
|
||||
private readonly List<Text> m_sceneListTexts = new List<Text>();
|
||||
|
||||
public static int DontDestroyHandle => DontDestroyObject.scene.handle;
|
||||
|
||||
internal static GameObject DontDestroyObject
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!m_dontDestroyObject)
|
||||
{
|
||||
m_dontDestroyObject = new GameObject("DontDestroyMe");
|
||||
GameObject.DontDestroyOnLoad(m_dontDestroyObject);
|
||||
}
|
||||
return m_dontDestroyObject;
|
||||
}
|
||||
}
|
||||
internal static GameObject m_dontDestroyObject;
|
||||
|
||||
public void Init()
|
||||
{
|
||||
// Get DontDestroyOnLoad scene handle. I think it's always -12, but best to be safe.
|
||||
GameObject test = new GameObject();
|
||||
GameObject.DontDestroyOnLoad(test);
|
||||
DontDestroyHandle = test.scene.handle;
|
||||
GameObject.Destroy(test);
|
||||
|
||||
RefreshActiveScenes();
|
||||
}
|
||||
|
||||
@ -77,18 +83,6 @@ namespace ExplorerBeta.UI.Main
|
||||
}
|
||||
}
|
||||
|
||||
//private int StoreScenehandle(Scene scene)
|
||||
//{
|
||||
// if (scene == null || scene.handle == -1)
|
||||
// return -1;
|
||||
|
||||
// if (!m_sceneHandles.ContainsKey(scene.name))
|
||||
// {
|
||||
// m_sceneHandles.Add(scene.name, scene.handle);
|
||||
// }
|
||||
// return scene.handle;
|
||||
//}
|
||||
|
||||
public int GetSceneHandle(string sceneName)
|
||||
{
|
||||
if (sceneName == "DontDestroyOnLoad")
|
||||
@ -190,21 +184,6 @@ namespace ExplorerBeta.UI.Main
|
||||
}
|
||||
}
|
||||
|
||||
private void SceneListObjectClicked(int index)
|
||||
{
|
||||
if (index >= m_sceneShortList.Count || !m_sceneShortList[index])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetTargetObject(m_sceneShortList[index]);
|
||||
}
|
||||
|
||||
private void OnSceneListPageTurn()
|
||||
{
|
||||
SetSceneObjectList(m_allSceneListObjects);
|
||||
}
|
||||
|
||||
private void RefreshSelectedSceneObject()
|
||||
{
|
||||
GameObject[] list = new GameObject[m_selectedSceneObject.transform.childCount];
|
||||
@ -217,21 +196,45 @@ namespace ExplorerBeta.UI.Main
|
||||
}
|
||||
|
||||
private void SetSceneObjectList(GameObject[] objects)
|
||||
{
|
||||
m_allSceneListObjects = objects;
|
||||
RefreshSceneObjectList();
|
||||
}
|
||||
|
||||
private void SceneListObjectClicked(int index)
|
||||
{
|
||||
if (index >= m_sceneShortList.Count || !m_sceneShortList[index])
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
SetTargetObject(m_sceneShortList[index]);
|
||||
}
|
||||
|
||||
private void OnSceneListPageTurn()
|
||||
{
|
||||
RefreshSceneObjectList();
|
||||
}
|
||||
|
||||
private void RefreshSceneObjectList()
|
||||
{
|
||||
m_timeOfLastSceneUpdate = Time.realtimeSinceStartup;
|
||||
|
||||
m_allSceneListObjects = objects;
|
||||
var objects = m_allSceneListObjects;
|
||||
m_sceneListPageHandler.ListCount = objects.Length;
|
||||
|
||||
int startIndex = m_sceneListPageHandler.IndexOffset;
|
||||
//int startIndex = m_sceneListPageHandler.StartIndex;
|
||||
|
||||
int newCount = 0;
|
||||
|
||||
for (int i = 0; i < m_sceneListPageHandler.ItemsPerPage; i++)
|
||||
foreach (var itemIndex in m_sceneListPageHandler)
|
||||
{
|
||||
newCount++;
|
||||
|
||||
if (i + startIndex >= objects.Length)
|
||||
// normalized index starting from 0
|
||||
var i = itemIndex - m_sceneListPageHandler.StartIndex;
|
||||
|
||||
if (itemIndex >= objects.Length)
|
||||
{
|
||||
if (i > m_lastCount || i >= m_sceneListTexts.Count)
|
||||
break;
|
||||
@ -242,7 +245,7 @@ namespace ExplorerBeta.UI.Main
|
||||
}
|
||||
else
|
||||
{
|
||||
GameObject obj = objects[i + startIndex];
|
||||
GameObject obj = objects[itemIndex];
|
||||
|
||||
if (!obj)
|
||||
continue;
|
||||
@ -278,7 +281,7 @@ namespace ExplorerBeta.UI.Main
|
||||
m_lastCount = newCount;
|
||||
}
|
||||
|
||||
#region SCENE PANE
|
||||
#region UI CONSTRUCTION
|
||||
|
||||
public void ConstructScenePane()
|
||||
{
|
||||
@ -399,7 +402,7 @@ namespace ExplorerBeta.UI.Main
|
||||
#else
|
||||
inspectButton.onClick.AddListener(() => { InspectorManager.Instance.Inspect(m_selectedSceneObject); });
|
||||
#endif
|
||||
GameObject scrollObj = UIFactory.CreateScrollView(leftPane, out m_sceneListCanvas, new Color(0.1f, 0.1f, 0.1f));
|
||||
GameObject scrollObj = UIFactory.CreateScrollView(leftPane, out m_sceneListContent, new Color(0.1f, 0.1f, 0.1f));
|
||||
Scrollbar scroll = scrollObj.transform.Find("Scrollbar Vertical").GetComponent<Scrollbar>();
|
||||
ColorBlock colors = scroll.colors;
|
||||
colors.normalColor = new Color(0.6f, 0.6f, 0.6f, 1.0f);
|
||||
@ -411,7 +414,7 @@ namespace ExplorerBeta.UI.Main
|
||||
var scrollRect = scrollObj.GetComponentInChildren<ScrollRect>();
|
||||
scrollRect.horizontalScrollbar = null;
|
||||
|
||||
var sceneGroup = m_sceneListCanvas.GetComponent<VerticalLayoutGroup>();
|
||||
var sceneGroup = m_sceneListContent.GetComponent<VerticalLayoutGroup>();
|
||||
sceneGroup.childControlHeight = true;
|
||||
sceneGroup.spacing = 2;
|
||||
|
||||
@ -424,7 +427,7 @@ namespace ExplorerBeta.UI.Main
|
||||
{
|
||||
int thisIndex = m_sceneListTexts.Count();
|
||||
|
||||
GameObject btnGroupObj = UIFactory.CreateHorizontalGroup(m_sceneListCanvas, new Color(0.1f, 0.1f, 0.1f));
|
||||
GameObject btnGroupObj = UIFactory.CreateHorizontalGroup(m_sceneListContent, new Color(0.1f, 0.1f, 0.1f));
|
||||
HorizontalLayoutGroup btnGroup = btnGroupObj.GetComponent<HorizontalLayoutGroup>();
|
||||
btnGroup.childForceExpandWidth = true;
|
||||
btnGroup.childControlWidth = true;
|
||||
@ -455,6 +458,7 @@ namespace ExplorerBeta.UI.Main
|
||||
|
||||
Text mainText = mainButtonObj.GetComponentInChildren<Text>();
|
||||
mainText.alignment = TextAnchor.MiddleLeft;
|
||||
mainText.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||
m_sceneListTexts.Add(mainText);
|
||||
|
||||
GameObject inspectBtnObj = UIFactory.CreateButton(btnGroupObj);
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace ExplorerBeta.UI.Main
|
||||
namespace UnityExplorer.UI.Main
|
||||
{
|
||||
public class SearchPage : MainMenu.Page
|
||||
{
|
||||
|
@ -1,9 +1,11 @@
|
||||
using System;
|
||||
using ExplorerBeta.Config;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityExplorer.Config;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ExplorerBeta.UI.Shared
|
||||
namespace UnityExplorer.UI.Shared
|
||||
{
|
||||
public enum Turn
|
||||
{
|
||||
@ -11,22 +13,25 @@ namespace ExplorerBeta.UI.Shared
|
||||
Right
|
||||
}
|
||||
|
||||
public class PageHandler
|
||||
public class PageHandler : IEnumerator
|
||||
{
|
||||
public PageHandler()
|
||||
{
|
||||
m_itemsPerPage = ModConfig.Instance?.Default_Page_Limit ?? 20;
|
||||
ItemsPerPage = ModConfig.Instance?.Default_Page_Limit ?? 20;
|
||||
}
|
||||
|
||||
public event Action OnPageChanged;
|
||||
|
||||
// For now this is just set when the PageHandler is created, based on config.
|
||||
// At some point I might make it possible to change this after creation again.
|
||||
public int ItemsPerPage => m_itemsPerPage;
|
||||
private int m_itemsPerPage;
|
||||
public int ItemsPerPage { get; }
|
||||
|
||||
// IEnumerator.Current
|
||||
public object Current => m_currentIndex;
|
||||
private int m_currentIndex = 0;
|
||||
|
||||
private int m_currentPage;
|
||||
public event Action OnPageChanged;
|
||||
|
||||
// ui
|
||||
private GameObject m_pageUIHolder;
|
||||
private Text m_currentPageLabel;
|
||||
|
||||
@ -52,15 +57,14 @@ namespace ExplorerBeta.UI.Shared
|
||||
}
|
||||
}
|
||||
|
||||
// the last page index (not using "index" to avoid confusion with next property)
|
||||
public int LastPage => (int)Math.Ceiling(ListCount / (decimal)m_itemsPerPage) - 1;
|
||||
public int LastPage => (int)Math.Ceiling(ListCount / (decimal)ItemsPerPage) - 1;
|
||||
|
||||
// The index of the first element of the current page
|
||||
public int IndexOffset
|
||||
public int StartIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
int offset = m_currentPage * m_itemsPerPage;
|
||||
int offset = m_currentPage * ItemsPerPage;
|
||||
|
||||
if (offset >= ListCount)
|
||||
{
|
||||
@ -72,6 +76,39 @@ namespace ExplorerBeta.UI.Shared
|
||||
}
|
||||
}
|
||||
|
||||
public int EndIndex
|
||||
{
|
||||
get
|
||||
{
|
||||
int end = StartIndex + ItemsPerPage;
|
||||
if (end >= ListCount)
|
||||
end = ListCount - 1;
|
||||
return end;
|
||||
}
|
||||
}
|
||||
|
||||
// IEnumerator.MoveNext()
|
||||
public bool MoveNext()
|
||||
{
|
||||
m_currentIndex++;
|
||||
return m_currentIndex < StartIndex + ItemsPerPage;
|
||||
}
|
||||
|
||||
// IEnumerator.Reset()
|
||||
public void Reset()
|
||||
{
|
||||
m_currentIndex = StartIndex - 1;
|
||||
}
|
||||
|
||||
public IEnumerator<int> GetEnumerator()
|
||||
{
|
||||
Reset();
|
||||
while (MoveNext())
|
||||
{
|
||||
yield return m_currentIndex;
|
||||
}
|
||||
}
|
||||
|
||||
public void TurnPage(Turn direction)
|
||||
{
|
||||
if (direction == Turn.Left)
|
||||
@ -94,7 +131,7 @@ namespace ExplorerBeta.UI.Shared
|
||||
}
|
||||
}
|
||||
|
||||
#region UI
|
||||
#region UI CONSTRUCTION
|
||||
|
||||
public void Show() => m_pageUIHolder?.SetActive(true);
|
||||
|
||||
@ -121,7 +158,7 @@ namespace ExplorerBeta.UI.Shared
|
||||
LayoutElement parentLayout = m_pageUIHolder.AddComponent<LayoutElement>();
|
||||
parentLayout.minHeight = 20;
|
||||
parentLayout.flexibleHeight = 0;
|
||||
parentLayout.minWidth = 290;
|
||||
parentLayout.minWidth = 200;
|
||||
parentLayout.flexibleWidth = 30;
|
||||
|
||||
GameObject leftBtnObj = UIFactory.CreateButton(m_pageUIHolder);
|
||||
@ -136,7 +173,7 @@ namespace ExplorerBeta.UI.Shared
|
||||
LayoutElement leftBtnLayout = leftBtnObj.AddComponent<LayoutElement>();
|
||||
leftBtnLayout.flexibleHeight = 0;
|
||||
leftBtnLayout.flexibleWidth = 0;
|
||||
leftBtnLayout.minWidth = 50;
|
||||
leftBtnLayout.minWidth = 40;
|
||||
leftBtnLayout.minHeight = 20;
|
||||
|
||||
GameObject labelObj = UIFactory.CreateLabel(m_pageUIHolder, TextAnchor.MiddleCenter);
|
||||
@ -144,7 +181,7 @@ namespace ExplorerBeta.UI.Shared
|
||||
m_currentPageLabel.text = "Page 1 / TODO";
|
||||
LayoutElement textLayout = labelObj.AddComponent<LayoutElement>();
|
||||
textLayout.flexibleWidth = 1.5f;
|
||||
textLayout.preferredWidth = 200;
|
||||
textLayout.preferredWidth = 120;
|
||||
|
||||
GameObject rightBtnObj = UIFactory.CreateButton(m_pageUIHolder);
|
||||
Button rightBtn = rightBtnObj.GetComponent<Button>();
|
||||
@ -158,7 +195,7 @@ namespace ExplorerBeta.UI.Shared
|
||||
LayoutElement rightBtnLayout = rightBtnObj.AddComponent<LayoutElement>();
|
||||
rightBtnLayout.flexibleHeight = 0;
|
||||
rightBtnLayout.flexibleWidth = 0;
|
||||
rightBtnLayout.minWidth = 50;
|
||||
rightBtnLayout.minWidth = 40;
|
||||
rightBtnLayout.minHeight = 20;
|
||||
|
||||
ListCount = 0;
|
||||
|
@ -1,4 +1,4 @@
|
||||
namespace ExplorerBeta.UI.Shared
|
||||
namespace UnityExplorer.UI.Shared
|
||||
{
|
||||
public class Syntax
|
||||
{
|
||||
|
@ -3,7 +3,7 @@ using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ExplorerBeta.UI
|
||||
namespace UnityExplorer.UI
|
||||
{
|
||||
public static class UIFactory
|
||||
{
|
||||
@ -581,6 +581,7 @@ namespace ExplorerBeta.UI
|
||||
templateImage.color = new Color(0.15f, 0.15f, 0.15f, 1.0f);
|
||||
|
||||
ScrollRect scrollRect = templateObj.AddComponent<ScrollRect>();
|
||||
scrollRect.scrollSensitivity = 25;
|
||||
scrollRect.content = contentObj.GetComponent<RectTransform>();
|
||||
scrollRect.viewport = viewportObj.GetComponent<RectTransform>();
|
||||
scrollRect.horizontal = false;
|
||||
|
@ -1,9 +1,9 @@
|
||||
using ExplorerBeta.UI.Main;
|
||||
using UnityExplorer.UI.Main;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace ExplorerBeta.UI
|
||||
namespace UnityExplorer.UI
|
||||
{
|
||||
public static class UIManager
|
||||
{
|
||||
|
@ -23,8 +23,8 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<Prefer32Bit>false</Prefer32Bit>
|
||||
<RootNamespace>ExplorerBeta</RootNamespace>
|
||||
<AssemblyName>ExplorerBeta</AssemblyName>
|
||||
<RootNamespace>UnityExplorer</RootNamespace>
|
||||
<AssemblyName>UnityExplorer</AssemblyName>
|
||||
<!-- Set this to the MelonLoader Il2Cpp Game folder, without the ending '\' character. -->
|
||||
<MLCppGameFolder>D:\Steam\steamapps\common\VRChat</MLCppGameFolder>
|
||||
<!-- Set this to the MelonLoader Mono Game folder, without the ending '\' character. -->
|
||||
@ -359,11 +359,10 @@
|
||||
<Compile Include="UI\Main\Console\CodeEditor.cs" />
|
||||
<Compile Include="UI\Main\Console\CSharpLexer.cs" />
|
||||
<Compile Include="UI\Main\Console\Lexer\CommentMatch.cs" />
|
||||
<Compile Include="UI\Main\Console\Lexer\ILexer.cs" />
|
||||
<Compile Include="UI\Main\Console\Lexer\InputLexer.cs" />
|
||||
<Compile Include="UI\Main\Console\Lexer\KeywordMatch.cs" />
|
||||
<Compile Include="UI\Main\Console\Lexer\StringMatch.cs" />
|
||||
<Compile Include="UI\Main\Console\Lexer\MatchLexer.cs" />
|
||||
<Compile Include="UI\Main\Console\Lexer\Matcher.cs" />
|
||||
<Compile Include="UI\Main\Console\Lexer\NumberMatch.cs" />
|
||||
<Compile Include="UI\Main\Console\Lexer\SymbolMatch.cs" />
|
||||
<Compile Include="UI\Main\Console\Suggestion.cs" />
|
@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 16
|
||||
VisualStudioVersion = 16.0.30128.74
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Explorer", "Explorer.csproj", "{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}"
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityExplorer", "UnityExplorer.csproj", "{B21DBDE3-5D6F-4726-93AB-CC3CC68BAE7D}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
@ -1,9 +1,13 @@
|
||||
using UnityEngine;
|
||||
using System.Globalization;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.Unstrip.ColorUtility
|
||||
namespace UnityExplorer.Unstrip.ColorUtility
|
||||
{
|
||||
public static class ColorUtilityUnstrip
|
||||
{
|
||||
/// <summary>
|
||||
/// Converts Color to 6-digit RGB hex code (without # symbol). Eg, RGBA(1,0,0,1) -> FF0000
|
||||
/// </summary>
|
||||
public static string ToHex(this Color color)
|
||||
{
|
||||
byte r = (byte)Mathf.Clamp(Mathf.RoundToInt(color.r * 255f), 0, 255);
|
||||
@ -12,5 +16,31 @@ namespace ExplorerBeta.Unstrip.ColorUtility
|
||||
|
||||
return $"{r:X2}{g:X2}{b:X2}";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Assumes the string is a 6-digit RGB Hex color code, which it will parse into a UnityEngine.Color.
|
||||
/// Eg, FF0000 -> RGBA(1,0,0,1)
|
||||
/// </summary>
|
||||
public static Color ToColor(this string _string)
|
||||
{
|
||||
_string = _string.Replace("#", "");
|
||||
|
||||
if (_string.Length != 6)
|
||||
return Color.magenta;
|
||||
|
||||
var r = byte.Parse(_string.Substring(0, 2), NumberStyles.HexNumber);
|
||||
var g = byte.Parse(_string.Substring(2, 2), NumberStyles.HexNumber);
|
||||
var b = byte.Parse(_string.Substring(4, 2), NumberStyles.HexNumber);
|
||||
|
||||
var color = new Color
|
||||
{
|
||||
r = (float)(r / (decimal)255),
|
||||
g = (float)(g / (decimal)255),
|
||||
b = (float)(b / (decimal)255),
|
||||
a = 1
|
||||
};
|
||||
|
||||
return color;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
#if CPP
|
||||
using System;
|
||||
using System.IO;
|
||||
using ExplorerBeta.Helpers;
|
||||
using UnityExplorer.Helpers;
|
||||
using UnhollowerBaseLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace ExplorerBeta.Unstrip.ImageConversion
|
||||
namespace UnityExplorer.Unstrip.ImageConversion
|
||||
{
|
||||
public static class ImageConversionUnstrip
|
||||
{
|
||||
|
@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using ExplorerBeta.Helpers;
|
||||
using UnityExplorer.Helpers;
|
||||
using UnityEngine;
|
||||
#if CPP
|
||||
using UnhollowerBaseLib;
|
||||
#endif
|
||||
|
||||
namespace ExplorerBeta.Unstrip.LayerMasks
|
||||
namespace UnityExplorer.Unstrip.LayerMasks
|
||||
{
|
||||
public static class LayerMaskUnstrip
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using ExplorerBeta.Helpers;
|
||||
using UnityExplorer.Helpers;
|
||||
#if CPP
|
||||
using UnhollowerBaseLib;
|
||||
#endif
|
||||
|
||||
namespace ExplorerBeta.Unstrip.Resources
|
||||
namespace UnityExplorer.Unstrip.Resources
|
||||
{
|
||||
public class ResourcesUnstrip
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using ExplorerBeta.Helpers;
|
||||
using ExplorerBeta.UI.Main;
|
||||
using UnityExplorer.Helpers;
|
||||
using UnityExplorer.UI.Main;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace ExplorerBeta.Unstrip.Scenes
|
||||
namespace UnityExplorer.Unstrip.Scenes
|
||||
{
|
||||
public class SceneUnstrip
|
||||
{
|
||||
@ -12,13 +12,23 @@ namespace ExplorerBeta.Unstrip.Scenes
|
||||
public static GameObject[] GetRootGameObjects(Scene scene) => scene.GetRootGameObjects();
|
||||
|
||||
public static GameObject[] GetRootGameObjects(int handle)
|
||||
{
|
||||
Scene scene = default;
|
||||
if (handle == SceneExplorer.DontDestroyHandle)
|
||||
scene = SceneExplorer.DontDestroyObject.scene;
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < SceneManager.sceneCount; i++)
|
||||
{
|
||||
var scene = SceneManager.GetSceneAt(i);
|
||||
if (scene.handle == handle)
|
||||
return scene.GetRootGameObjects();
|
||||
var iscene = SceneManager.GetSceneAt(i);
|
||||
if (iscene.handle == handle)
|
||||
scene = iscene;
|
||||
}
|
||||
}
|
||||
|
||||
if (scene != default && scene.handle != -1)
|
||||
return scene.GetRootGameObjects();
|
||||
|
||||
return new GameObject[0];
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user