davidf-dev / unity-developerconsole Goto Github PK
View Code? Open in Web Editor NEWA Unity package that provides an in-game developer console, allowing developers or users to execute commands or view incoming Unity messages.
License: MIT License
A Unity package that provides an in-game developer console, allowing developers or users to execute commands or view incoming Unity messages.
License: MIT License
Would be helpful and nice to have a command parameter autocompletion (like the command autocomplete). A way to use it could be to pass a list of values like in the example below.
Usage:
private static void ConfigureGiveCollectibleCommand()
{
DevConsole.AddCommand(Command.Create(
name: "collectible_give",
aliases: "",
helpText: "Gives collectibles to the player",
p1: Parameter.Create(
name: "collectible type",
helpText: "The collectible type to give to the player"
---> autocompletion: new List<CollectibleType>() { CollectibleType.Life, CollectibleType.Ammo, CollectibleType.Mana }
),
p2: Parameter.Create(
name: "amount",
helpText: "The amount you want to give to the player"
),
callback: (CollectibleType type, int amount) => GiveCollectible(type, amount)
));
}
Hello really like this console.
I found a Issue for too long Log-Texts, the long texts create too many vertices for the text mesh.
Error-Message:
ArgumentException: Mesh can not have more than 65000 vertices
UnityEngine.UI.VertexHelper.FillMesh (UnityEngine.Mesh mesh) (at Library/PackageCache/[email protected]/Runtime/UI/Core/Utility/VertexHelper.cs:226)
UnityEngine.UI.Graphic.DoMeshGeneration () (at Library/PackageCache/[email protected]/Runtime/UI/Core/Graphic.cs:709)
UnityEngine.UI.Graphic.UpdateGeometry () (at Library/PackageCache/[email protected]/Runtime/UI/Core/Graphic.cs:690)
UnityEngine.UI.Text.UpdateGeometry () (at Library/PackageCache/[email protected]/Runtime/UI/Core/Text.cs:580)
UnityEngine.UI.Graphic.Rebuild (UnityEngine.UI.CanvasUpdate update) (at Library/PackageCache/[email protected]/Runtime/UI/Core/Graphic.cs:648)
UnityEngine.UI.CanvasUpdateRegistry.PerformUpdate () (at Library/PackageCache/[email protected]/Runtime/UI/Core/CanvasUpdateRegistry.cs:215)
UnityEngine.Canvas:SendWillRenderCanvases()
The Error is thrown by the LogText Object multiple times
This also creates a Memory Problem. about 60MB is used for the UIVertex Meshes that the console creates. The Memory snapshot comes directly from a iOS Development Build.
Unity Version: Unity 2021.3.14f1
When running the command showfps 1
and if devconsole.dat
file is missing the following exception is raised:
NullReferenceException: Object reference not set to an instance of an object DavidFDev.DevConsole.DevConsoleMono.OnGUI () (at Library/PackageCache/com.davidfdev.devconsole@3d2a0ad071/Runtime/DevConsoleMono.cs:1409) UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr, Boolean&)
However, setting any other stat beforehand, for example stats_set "test" 123
seems to prevent this error.
Package version: 1.04
Unity version: 2021.2.14
Developer console initialization fails in builds (Mono and IL2CPP), the exception raised is different for each of the scripting backends:
Mono
PlatformNotSupportedException: Operation is not supported on this platform.
at System.AppDomain.DefineDynamicAssembly (System.Reflection.AssemblyName name, System.Reflection.Emit.AssemblyBuilderAccess access) [0x00000] in <a1e9f114a6e64f4eacb529fc802ec93d>:0
at (wrapper remoting-invoke-with-check) System.AppDomain.DefineDynamicAssembly(System.Reflection.AssemblyName,System.Reflection.Emit.AssemblyBuilderAccess)
at Mono.CSharp.AssemblyDefinitionDynamic.Create (System.AppDomain domain, System.Reflection.Emit.AssemblyBuilderAccess access) [0x00029] in <f3e97a84a64644d49c74874c23e0fb80>:0
at Mono.CSharp.Evaluator.CompileBlock (Mono.CSharp.Class host, Mono.CSharp.Undo undo, Mono.CSharp.Report Report) [0x00066] in <f3e97a84a64644d49c74874c23e0fb80>:0
at Mono.CSharp.Evaluator.Compile (System.String input, Mono.CSharp.CompiledMethod& compiled) [0x000cf] in <f3e97a84a64644d49c74874c23e0fb80>:0
at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object& result, System.Boolean& result_set) [0x00006] in <f3e97a84a64644d49c74874c23e0fb80>:0
at Mono.CSharp.Evaluator.Run (System.String statement) [0x00000] in <f3e97a84a64644d49c74874c23e0fb80>:0
at DavidFDev.DevConsole.DevConsoleMono.InitMonoEvaluator () [0x00096] in C:\Users\Sam\Source\test\Library\PackageCache\com.davidfdev.devconsole@e89e21ab28\Runtime\DevConsoleMono.cs:3512
at DavidFDev.DevConsole.DevConsoleMono.Awake () [0x00138] in C:\Users\Sam\Source\test\Library\PackageCache\com.davidfdev.devconsole@e89e21ab28\Runtime\DevConsoleMono.cs:1163
UnityEngine.Object:Internal_CloneSingle(Object)
UnityEngine.Object:Instantiate(GameObject)
DavidFDev.DevConsole.DevConsole:Init()
IL2CPP
ArgumentException: Invalid path
at System.IO.Path.GetDirectoryName (System.String path) [0x00000] in <00000000000000000000000000000000>:0
at Mono.CSharp.Evaluator.Init () [0x00000] in <00000000000000000000000000000000>:0
at Mono.CSharp.Evaluator.Compile (System.String input, Mono.CSharp.CompiledMethod& compiled) [0x00000] in <00000000000000000000000000000000>:0
at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object& result, System.Boolean& result_set) [0x00000] in <00000000000000000000000000000000>:0
at Mono.CSharp.Evaluator.Run (System.String statement) [0x00000] in <00000000000000000000000000000000>:0
at DavidFDev.DevConsole.DevConsoleMono.InitMonoEvaluator () [0x00000] in <00000000000000000000000000000000>:0
at DavidFDev.DevConsole.DevConsoleMono.Awake () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.Object.Instantiate[T] (T original) [0x00000] in <00000000000000000000000000000000>:0
at DavidFDev.DevConsole.DevConsole.Init () [0x00000] in <00000000000000000000000000000000>:0
UnityEngine.Object:Instantiate(T)
DavidFDev.DevConsole.DevConsole:Init()
However both point to the DevConsoleMono.InitMonoEvaluator()
method. I found this post in the Unity forums that seemed related:
https://forum.unity.com/threads/released-roslyn-c-runtime-c-compiler.651505/page-5#post-7549093
Looks like runtime code compilation is not supported in IL2CPP platforms, and neither Mono in this case. I tried looking at the changes made in v1.0.2 and I believe the root cause could be this commit: 8d1590c
The Mono evaluator in v1.0.0 was initialized only when commands that used it were executed, so the error only happened when running commands such as cs_evaluate
in builds, but in v1.0.2 the evaluator is always initialized.
Note: Everything works fine when playing in the Editor.
After updating from Unity 2021.1 to 2021.2 the following exception is thrown in builds (both development and release):
InvalidCastException: Object must implement IConvertible.
at System.Convert.ChangeType (System.Object value, System.Type conversionType, System.IFormatProvider provider) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.Serialization.SerializationInfo.GetValue (System.String name, System.Type type) [0x00000] in <00000000000000000000000000000000>:0
at System.Collections.Generic.Dictionary`2[TKey,TValue].OnDeserialization (System.Object sender) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.Serialization.Formatters.Binary.ObjectReader.Deserialize (System.Runtime.Remoting.Messaging.HeaderHandler handler, System.Runtime.Serialization.Formatters.Binary.__BinaryParser serParser, System.Boolean fCheck) [0x00000] in <00000000000000000000000000000000>:0
at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Deserialize (System.IO.Stream serializationStream) [0x00000] in <00000000000000000000000000000000>:0
at DavidFDev.DevConsole.DevConsoleData.Load () [0x00000] in <00000000000000000000000000000000>:0
at DavidFDev.DevConsole.DevConsoleMono.LoadPreferences () [0x00000] in <00000000000000000000000000000000>:0
at DavidFDev.DevConsole.DevConsoleMono.Awake () [0x00000] in <00000000000000000000000000000000>:0
at UnityEngine.Object.Instantiate[T] (T original) [0x00000] in <00000000000000000000000000000000>:0
at DavidFDev.DevConsole.DevConsole.Init () [0x00000] in <00000000000000000000000000000000>:0
UnityEngine.Object:Instantiate(T)
DavidFDev.DevConsole.DevConsole:Init()
The error happens only when building with IL2CPP scripting backend, everything seems to be fine when building with Mono scripting backend or if running in the Editor.
Package version: 1.0.0
OS: Windows 10
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.