Skip to main content
Glama
ExtensionsRuntimeGameObjectRef.cs1.91 kB
/* ┌──────────────────────────────────────────────────────────────────┐ │ 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 com.IvanMurzak.Unity.MCP.Runtime.Data; using com.IvanMurzak.Unity.MCP.Runtime.Utils; using UnityEngine; namespace com.IvanMurzak.Unity.MCP.Runtime.Extensions { public static class ExtensionsRuntimeGameObjectRef { public static GameObject? FindGameObject(this GameObjectRef? objectRef) => FindGameObject(objectRef, out _); public static GameObject? FindGameObject(this GameObjectRef? objectRef, out string? error) { if (objectRef == null) { error = null; return null; } var go = GameObjectUtils.FindBy(objectRef, out error); if (go == null) go = ExtensionsRuntimeAssetObjectRef.FindAssetObject(objectRef) as GameObject; if (go != null) error = null; return go; } public static GameObjectRef? ToGameObjectRef(this GameObject? obj) { if (obj == null) return new GameObjectRef(); return new GameObjectRef(obj.GetInstanceID()); } } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/IvanMurzak/Unity-MCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server