�
���g@4 � �L � d dl mZmZ d dlmZmZmZmZ d dlZd dl m
Z
defd�Zy)� )�FastMCP�Context)�List�Dict�Any�OptionalN)�get_unity_connection�mcpc � � | j � dt dt fd�� }| j � dt dt dt fd�� }| j � dt dt fd�� }| j � ddt dt dt dt fd�� }| j � ddt dt d t dt fd
�� }| j � dt dt dt fd�� }| j � ddt dt dt dt t
dt t
dt t
dt dt fd�� }| j � ddt dt dt t t
dt t t
dt t t
dt t dt t dt t dt t dt t t t f dt fd�� }| j � ddt dt dt dt fd�� } y
) z5Register all scene-related tools with the MCP server.�ctx�returnc � � t � }|j d� }t j |d�� S # t $ r}dt |� � �cY d}~S d}~ww xY w)z5Retrieve detailed info about the current Unity scene.�GET_SCENE_INFO� ��indentzError getting scene info: N�r �send_command�json�dumps� Exception�str�r �unity�result�es ��C:\1_Sagyo\VRchat\Project\IshouJidouChouseiToul\Library\PackageCache\com.zundamonnovrchat.unity-mcp-ollama@994ecdcda9\Python\tools\scene_tools.py�get_scene_infoz,register_scene_tools.<locals>.get_scene_info sR � � 9�(�*�E��'�'�(8�9�F��:�:�f�Q�/�/��� 9�/��A��x�8�8�� 9�s �14 � A�
A�
A�A�
scene_pathc
� �� t � }|j dd�j d� d dj �j d� dd � xs dd�� j dg � }t �fd �|D � � }|sd
�� d�S |j dd
�i� }|j dd� S # t $ r}dt |� � �cY d}~S d}~ww xY w)z�Open a specified scene in the Unity editor.
Args:
scene_path: Full path to the scene file (e.g., "Assets/Scenes/MyScene.unity")
Returns:
str: Success message or error details
�GET_ASSET_LIST�Scene�/�����N�Assets��type�search_pattern�folder�assetsc 3 �F �K � | ] }|j d � �k( �� � y�w��pathN��get��.0�scener s �r � <genexpr>z;register_scene_tools.<locals>.open_scene.<locals>.<genexpr>( � �� �� �S�F�5�u�y�y��0�J�>�F�� �!�
Scene at 'z' not found in the project.�
OPEN_SCENEr �messagezScene opened successfullyzError opening scene: �r r �split�joinr/ �anyr r )r r r �scenes�scene_existsr r s ` r �
open_scenez(register_scene_tools.<locals>.open_scene s� �� � 4�(�*�E� �'�'�(8��",�"2�"2�3�"7��";��(�(�:�#3�#3�C�#8��"�#=�>�J�(�;� � �s�8�R� �
� �S�F�S�S�L��#�J�<�/J�K�K��'�'��|�Z�6P�Q�F��:�:�i�)D�E�E��� 4�*�3�q�6�(�3�3�� 4�s$ �BB, �%B, �, C
�5
C�C
�C
c � � t � }|j d� }|j dd� S # t $ r}dt |� � �cY d}~S d}~ww xY w)zxSave the current scene to its file.
Returns:
str: Success message or error details
�
SAVE_SCENEr8 zScene saved successfullyzError saving scene: N�r r r/ r r r s r �
save_scenez(register_scene_tools.<locals>.save_scene1 sR � � 3�(�*�E��'�'��5�F��:�:�i�)C�D�D��� 3�)�#�a�&��2�2�� 3�s �,/ � A�
A�A�A� overwritec
�� �� t � }|j dd�j d� d dj �j d� dd � xs dd�� j dg � }t �fd �|D � � }|r|sd
�� d�S |j d�|d
�� }|j d� |j d� }|j dd� S # t $ r}dt |� � �cY d}~S d}~ww xY w)a_ Create a new empty scene in the Unity editor.
Args:
scene_path: Full path where the new scene should be saved (e.g., "Assets/Scenes/NewScene.unity")
overwrite: Whether to overwrite if scene already exists (default: False)
Returns:
str: Success message or error details
r! r"