如何将 Unity Display 对话框的输出更改为特定的游戏对象?

how to change the output from Unity Display dialog to specific Gameobject?

我是编程初学者,所以我需要了解以下内容:我正在从我的项目调用 REST API 到服务器,但我卡在这里了。

我试图在我的场景中的特定游戏对象上显示我的按钮输出。我想知道有多少 UnityEditor 属性,或者如何将我的游戏对象指向输出而不是 DialogDisplay 弹出窗口?

EditorUtility.DisplayDialog("Posts", JsonHelper.ArrayToJsonString(res, true), "Ok");
return RestClient.GetArray(basePath + "/todos");
}).Then(res => {
EditorUtility.DisplayDialog("Todos", JsonHelper.ArrayToJsonString(res, true), "Ok");
return RestClient.GetArray(basePath + "/users");
}).Then(res => {
EditorUtility.DisplayDialog("Users", JsonHelper.ArrayToJsonString(res, true), "Ok");

我的游戏对象的名称是输出

这是一个非常基本的示例,说明如何使用 Unity 文档EditorUtility.DisplayDialog

// Places the selected Objects on the surface of a terrain.

using UnityEngine;
using UnityEditor;

public class PlaceSelectionOnSurface : ScriptableObject
{
    [MenuItem("Example/Place Selection On Surface")]
    static void CreateWizard()
    {
        Transform[] transforms = Selection.GetTransforms(SelectionMode.Deep |
                SelectionMode.ExcludePrefab | SelectionMode.Editable);

        if (transforms.Length > 0 &&
            EditorUtility.DisplayDialog("Place Selection On Surface?",
                "Are you sure you want to place " + transforms.Length
                + " on the surface?", "Place", "Do Not Place"))
        {
            foreach (Transform transform in transforms)
            {
                RaycastHit hit;
                if (Physics.Raycast(transform.position, -Vector3.up, out hit))
                {
                    transform.position = hit.point;
                    Vector3 randomized = Random.onUnitSphere;
                    randomized = new Vector3(randomized.x, 0F, randomized.z);
                    transform.rotation = Quaternion.LookRotation(randomized, hit.normal);
                }
            }
        }
    }
}

所以我认为您可以制作类似的东西并使用 Selection.gameobjects 访问该对象,这会为您提供所选游戏对象的列表,然后您可以对它们进行任何操作。

GameObject[] objects = Selection.gameObjects;
if (EditorUtility.DisplayDialog("Title", "Msg", "Ok"))
{
    Debug.Log(objects[0]);

    // ... //
}