Coder Social home page Coder Social logo

davidf-dev / unity-developerconsole Goto Github PK

View Code? Open in Web Editor NEW
61.0 61.0 8.0 1.42 MB

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

C# 100.00%
unity unity-asset unity3d

unity-developerconsole's People

Contributors

davidf-dev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

unity-developerconsole's Issues

Feature Request: parameter autocompletion

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)
            ));
        }

LogText creates ArgumentException because of too high vertex count

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
grafik

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.
grafik

Unity Version: Unity 2021.3.14f1

'showfps' command fails when 'devconsole.dat' file is missing

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

Initialization fails in builds

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.

InvalidCastException in IL2CPP builds (Unity 2021.2)

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.