如何将EditorGUILayout.PropertyField的内容显示到文本框?

问题描述 投票:0回答:1

有没有办法将EditorGUILayout.PropertyField的输入显示到文本框中?

enter image description here

这是我想出的:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class clue : MonoBehaviour
{
public Text hintText;  

void Start()
{
    HintText.Text = EditorGUILayout.PropertyField(levelInfo.FindPropertyRelative("clue"));
}
}

我试过了。感谢任何可以提供帮助的人。

c# unity3d
1个回答
0
投票

难道你不能只在类中添加公共字符串字段吗?

它将显示在Inspector中,您可以在其中输入,然后将此字符串值分配给hintText.text

如果您使用自定义Inspector抽屉来制作一些自定义的复杂结构,请考虑创建一个具有所需结构的单独的非MonoBehaviour类,并使用System.Serializable属性使该类的对象在Inspector中可见。像这样:

https://docs.unity3d.com/ScriptReference/Serializable.html

© www.soinside.com 2019 - 2024. All rights reserved.