Gameplay Ingredients是一组用于 Unity 游戏的运行时和编辑器工具:一组脚本的集合,可在制作游戏和原型时简化简单的任务。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

57 行
1.5 KiB

using UnityEditor;
using UnityEngine;
namespace GameplayIngredients.Comments.Editor
{
[CustomEditor(typeof(CommentAsset))]
public class CommentAssetEditor : UnityEditor.Editor
{
[SerializeField]
CommentAsset commentAsset;
[SerializeField]
SerializedProperty m_Comment;
[SerializeField]
CommentEditor m_CommentEditor;
public static void RequestEdit() { m_NeedEditNext = true; }
public static bool m_NeedEditNext = false;
private void OnEnable()
{
UpdateComment();
if (commentAsset.comment.focus)
EditorGUIUtility.PingObject(commentAsset);
}
void UpdateComment()
{
if (m_Comment == null)
m_Comment = serializedObject.FindProperty("m_Comment");
if (m_CommentEditor == null)
m_CommentEditor = new CommentEditor(serializedObject, m_Comment, true);
commentAsset = (serializedObject.targetObject as CommentAsset);
if (commentAsset.firstTimeEdit)
RequestEdit();
}
public override void OnInspectorGUI()
{
UpdateComment();
GUILayout.Space(4);
m_CommentEditor.DrawComment(commentAsset.comment, m_NeedEditNext);
if (m_NeedEditNext)
{
m_NeedEditNext = false;
commentAsset.firstTimeEdit = false;
}
GUILayout.Space(16);
}
}
}