Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
┌──────────────────────────────────────────────────────────────────┐
│ Author: Ivan Murzak (https://github.com/IvanMurzak) │
│ Repository: GitHub (https://github.com/IvanMurzak/Unity-MCP) │
│ Copyright (c) 2025 Ivan Murzak │
│ Licensed under the Apache License, Version 2.0. │
│ See the LICENSE file in the project root for more information. │
└──────────────────────────────────────────────────────────────────┘
*/

#nullable enable
using System.ComponentModel;
using com.IvanMurzak.McpPlugin;
using com.IvanMurzak.ReflectorNet.Utils;
using Extensions.Unity.PlayerPrefsEx;
using UnityEngine;

namespace com.IvanMurzak.Unity.MCP.Editor.API
{
public partial class Tool_PlayerPrefs
{
[McpPluginTool
(
"PlayerPrefs_DeleteAllKeys",
Title = "Delete all PlayerPrefs keys"
)]
[Description("Deletes all keys and values from PlayerPrefs. Use with caution.")]
public string DeleteAllKeys()
=> MainThread.Instance.Run(() =>
{
PlayerPrefsEx.DeleteAll();
return "[Success] Deleted all PlayerPrefs keys.";
});
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
┌──────────────────────────────────────────────────────────────────┐
│ Author: Ivan Murzak (https://github.com/IvanMurzak) │
│ Repository: GitHub (https://github.com/IvanMurzak/Unity-MCP) │
│ Copyright (c) 2025 Ivan Murzak │
│ Licensed under the Apache License, Version 2.0. │
│ See the LICENSE file in the project root for more information. │
└──────────────────────────────────────────────────────────────────┘
*/

#nullable enable
using System.ComponentModel;
using com.IvanMurzak.McpPlugin;
using com.IvanMurzak.ReflectorNet.Utils;
using Extensions.Unity.PlayerPrefsEx;
using UnityEngine;

namespace com.IvanMurzak.Unity.MCP.Editor.API
{
public partial class Tool_PlayerPrefs
{
[McpPluginTool
(
"PlayerPrefs_DeleteKey",
Title = "Delete PlayerPrefs key"
)]
[Description("Deletes a key and its value from PlayerPrefs.")]
public string DeleteKey
(
[Description("The key to delete.")]
string key
)
=> MainThread.Instance.Run(() =>
{
if (string.IsNullOrEmpty(key))
return Error.KeyIsNullOrEmpty();

// Check if key exists in any type and delete it
bool deleted = false;

if (PlayerPrefsEx.HasKey<int>(key))
{
PlayerPrefsEx.DeleteKey<int>(key);
deleted = true;
}

if (PlayerPrefsEx.HasKey<float>(key))
{
PlayerPrefsEx.DeleteKey<float>(key);
deleted = true;
}

if (PlayerPrefsEx.HasKey<string>(key))
{
PlayerPrefsEx.DeleteKey<string>(key);
deleted = true;
}

if (PlayerPrefsEx.HasKey<bool>(key))
{
PlayerPrefsEx.DeleteKey<bool>(key);
deleted = true;
}

if (!deleted)
return Error.KeyDoesNotExist(key);

return $"[Success] Deleted key '{key}' from PlayerPrefs.";
});
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
┌──────────────────────────────────────────────────────────────────┐
│ Author: Ivan Murzak (https://github.com/IvanMurzak) │
│ Repository: GitHub (https://github.com/IvanMurzak/Unity-MCP) │
│ Copyright (c) 2025 Ivan Murzak │
│ Licensed under the Apache License, Version 2.0. │
│ See the LICENSE file in the project root for more information. │
└──────────────────────────────────────────────────────────────────┘
*/

#nullable enable
using System.ComponentModel;
using com.IvanMurzak.McpPlugin;
using com.IvanMurzak.ReflectorNet.Utils;
using Extensions.Unity.PlayerPrefsEx;
using UnityEngine;

namespace com.IvanMurzak.Unity.MCP.Editor.API
{
public partial class Tool_PlayerPrefs
{
[McpPluginTool
(
"PlayerPrefs_ExistsKey",
Title = "Check if PlayerPrefs key exists"
)]
[Description("Checks whether a specified key exists in Unity's PlayerPrefs.")]
public string ExistsKey
(
[Description("The key to check for existence.")]
string key
)
=> MainThread.Instance.Run(() =>
{
if (string.IsNullOrEmpty(key))
return Error.KeyIsNullOrEmpty();

// Check if key exists in any type
bool exists = PlayerPrefsEx.HasKey<int>(key) ||
PlayerPrefsEx.HasKey<float>(key) ||
PlayerPrefsEx.HasKey<string>(key) ||
PlayerPrefsEx.HasKey<bool>(key);

return $"[Success] Key '{key}' existence check completed. Exists: {exists}";
});
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
┌──────────────────────────────────────────────────────────────────┐
│ Author: Ivan Murzak (https://github.com/IvanMurzak) │
│ Repository: GitHub (https://github.com/IvanMurzak/Unity-MCP) │
│ Copyright (c) 2025 Ivan Murzak │
│ Licensed under the Apache License, Version 2.0. │
│ See the LICENSE file in the project root for more information. │
└──────────────────────────────────────────────────────────────────┘
*/

#nullable enable
using System.ComponentModel;
using com.IvanMurzak.McpPlugin;
using com.IvanMurzak.ReflectorNet.Utils;
using Extensions.Unity.PlayerPrefsEx;
using UnityEngine;

namespace com.IvanMurzak.Unity.MCP.Editor.API
{
public partial class Tool_PlayerPrefs
{
[McpPluginTool
(
"PlayerPrefs_GetKeyType",
Title = "Get PlayerPrefs key type"
)]
[Description("Gets the inferred type of a value stored in PlayerPrefs. Returns 'int', 'float', or 'string'.")]
public string GetKeyType
(
[Description("The key to get the type for.")]
string key
)
=> MainThread.Instance.Run(() =>
{
if (string.IsNullOrEmpty(key))
return Error.KeyIsNullOrEmpty();

// Check if key exists in any type
bool keyExists = PlayerPrefsEx.HasKey<int>(key) ||
PlayerPrefsEx.HasKey<float>(key) ||
PlayerPrefsEx.HasKey<string>(key) ||
PlayerPrefsEx.HasKey<bool>(key);

if (!keyExists)
return Error.KeyDoesNotExist(key);

var (_, type) = GetKeyValueAndType(key);
return $"[Success] Key '{key}' has type: {type}";
});
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
┌──────────────────────────────────────────────────────────────────┐
│ Author: Ivan Murzak (https://github.com/IvanMurzak) │
│ Repository: GitHub (https://github.com/IvanMurzak/Unity-MCP) │
│ Copyright (c) 2025 Ivan Murzak │
│ Licensed under the Apache License, Version 2.0. │
│ See the LICENSE file in the project root for more information. │
└──────────────────────────────────────────────────────────────────┘
*/

#nullable enable
using System.ComponentModel;
using com.IvanMurzak.McpPlugin;
using com.IvanMurzak.ReflectorNet.Utils;
using Extensions.Unity.PlayerPrefsEx;
using UnityEngine;

namespace com.IvanMurzak.Unity.MCP.Editor.API
{
public partial class Tool_PlayerPrefs
{
[McpPluginTool
(
"PlayerPrefs_ReadKey",
Title = "Read PlayerPrefs key"
)]
[Description("Reads the value of a key from PlayerPrefs. Returns the value and its inferred type.")]
public string ReadKey
(
[Description("The key to read the value from.")]
string key
)
=> MainThread.Instance.Run(() =>
{
if (string.IsNullOrEmpty(key))
return Error.KeyIsNullOrEmpty();

// Check if key exists in any type
bool keyExists = PlayerPrefsEx.HasKey<int>(key) ||
PlayerPrefsEx.HasKey<float>(key) ||
PlayerPrefsEx.HasKey<string>(key) ||
PlayerPrefsEx.HasKey<bool>(key);

if (!keyExists)
return Error.KeyDoesNotExist(key);

var (value, type) = GetKeyValueAndType(key);
return $"[Success] Key '{key}' value: {value} (type: {type})";
});
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
┌──────────────────────────────────────────────────────────────────┐
│ Author: Ivan Murzak (https://github.com/IvanMurzak) │
│ Repository: GitHub (https://github.com/IvanMurzak/Unity-MCP) │
│ Copyright (c) 2025 Ivan Murzak │
│ Licensed under the Apache License, Version 2.0. │
│ See the LICENSE file in the project root for more information. │
└──────────────────────────────────────────────────────────────────┘
*/

#nullable enable
using System.ComponentModel;
using com.IvanMurzak.McpPlugin;
using com.IvanMurzak.ReflectorNet.Utils;
using Extensions.Unity.PlayerPrefsEx;
using UnityEngine;

namespace com.IvanMurzak.Unity.MCP.Editor.API
{
public partial class Tool_PlayerPrefs
{
[McpPluginTool
(
"PlayerPrefs_Save",
Title = "Save PlayerPrefs to disk"
)]
[Description("Writes all modified PlayerPrefs to disk. On some platforms, PlayerPrefs are not saved until the application quits. Use this to force save.")]
public string Save()
=> MainThread.Instance.Run(() =>
{
PlayerPrefsEx.Save();
return "[Success] PlayerPrefs saved to disk.";
});
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading