添加debug工具

This commit is contained in:
2024-09-03 19:56:21 +08:00
parent 187407cedb
commit aa4595f290
554 changed files with 59600 additions and 9992 deletions

View File

@ -0,0 +1,58 @@
using UnityEngine;
namespace IngameDebugConsole.Commands
{
public class PlayerPrefsCommands
{
[ConsoleMethod( "prefs.int", "Returns the value of an Integer PlayerPrefs field" ), UnityEngine.Scripting.Preserve]
public static string PlayerPrefsGetInt( string key )
{
if( !PlayerPrefs.HasKey( key ) ) return "Key Not Found";
return PlayerPrefs.GetInt( key ).ToString();
}
[ConsoleMethod( "prefs.int", "Sets the value of an Integer PlayerPrefs field" ), UnityEngine.Scripting.Preserve]
public static void PlayerPrefsSetInt( string key, int value )
{
PlayerPrefs.SetInt( key, value );
}
[ConsoleMethod( "prefs.float", "Returns the value of a Float PlayerPrefs field" ), UnityEngine.Scripting.Preserve]
public static string PlayerPrefsGetFloat( string key )
{
if( !PlayerPrefs.HasKey( key ) ) return "Key Not Found";
return PlayerPrefs.GetFloat( key ).ToString();
}
[ConsoleMethod( "prefs.float", "Sets the value of a Float PlayerPrefs field" ), UnityEngine.Scripting.Preserve]
public static void PlayerPrefsSetFloat( string key, float value )
{
PlayerPrefs.SetFloat( key, value );
}
[ConsoleMethod( "prefs.string", "Returns the value of a String PlayerPrefs field" ), UnityEngine.Scripting.Preserve]
public static string PlayerPrefsGetString( string key )
{
if( !PlayerPrefs.HasKey( key ) ) return "Key Not Found";
return PlayerPrefs.GetString( key );
}
[ConsoleMethod( "prefs.string", "Sets the value of a String PlayerPrefs field" ), UnityEngine.Scripting.Preserve]
public static void PlayerPrefsSetString( string key, string value )
{
PlayerPrefs.SetString( key, value );
}
[ConsoleMethod( "prefs.delete", "Deletes a PlayerPrefs field" ), UnityEngine.Scripting.Preserve]
public static void PlayerPrefsDelete( string key )
{
PlayerPrefs.DeleteKey( key );
}
[ConsoleMethod( "prefs.clear", "Deletes all PlayerPrefs fields" ), UnityEngine.Scripting.Preserve]
public static void PlayerPrefsClear()
{
PlayerPrefs.DeleteAll();
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 33fb3ee25c8764f4c905fa3ac7c4eb89
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,58 @@
using UnityEngine;
using UnityEngine.SceneManagement;
namespace IngameDebugConsole.Commands
{
public class SceneCommands
{
[ConsoleMethod( "scene.load", "Loads a scene" ), UnityEngine.Scripting.Preserve]
public static void LoadScene( string sceneName )
{
LoadSceneInternal( sceneName, false, LoadSceneMode.Single );
}
[ConsoleMethod( "scene.load", "Loads a scene" ), UnityEngine.Scripting.Preserve]
public static void LoadScene( string sceneName, LoadSceneMode mode )
{
LoadSceneInternal( sceneName, false, mode );
}
[ConsoleMethod( "scene.loadasync", "Loads a scene asynchronously" ), UnityEngine.Scripting.Preserve]
public static void LoadSceneAsync( string sceneName )
{
LoadSceneInternal( sceneName, true, LoadSceneMode.Single );
}
[ConsoleMethod( "scene.loadasync", "Loads a scene asynchronously" ), UnityEngine.Scripting.Preserve]
public static void LoadSceneAsync( string sceneName, LoadSceneMode mode )
{
LoadSceneInternal( sceneName, true, mode );
}
private static void LoadSceneInternal( string sceneName, bool isAsync, LoadSceneMode mode )
{
if( SceneManager.GetSceneByName( sceneName ).IsValid() )
{
Debug.Log( "Scene " + sceneName + " is already loaded" );
return;
}
if( isAsync )
SceneManager.LoadSceneAsync( sceneName, mode );
else
SceneManager.LoadScene( sceneName, mode );
}
[ConsoleMethod( "scene.unload", "Unloads a scene" ), UnityEngine.Scripting.Preserve]
public static void UnloadScene( string sceneName )
{
SceneManager.UnloadSceneAsync( sceneName );
}
[ConsoleMethod( "scene.restart", "Restarts the active scene" ), UnityEngine.Scripting.Preserve]
public static void RestartScene()
{
SceneManager.LoadScene( SceneManager.GetActiveScene().name, LoadSceneMode.Single );
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 45984eacd62d9a3489fd62689265a23c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,19 @@
using UnityEngine;
namespace IngameDebugConsole.Commands
{
public class TimeCommands
{
[ConsoleMethod( "time.scale", "Sets the Time.timeScale value" ), UnityEngine.Scripting.Preserve]
public static void SetTimeScale( float value )
{
Time.timeScale = Mathf.Max( value, 0f );
}
[ConsoleMethod( "time.scale", "Returns the current Time.timeScale value" ), UnityEngine.Scripting.Preserve]
public static float GetTimeScale()
{
return Time.timeScale;
}
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: bb12a1f557fffa541909fcfe92d9c1bf
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: