//**********************************************************************
// 文件名(File Name): TransformInspector.cs
// 作者(Author): 钱何飞
// 创建时间(CreateTime): 5/13/2019
// **********************************************************************
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
namespace FrameWork.IEditor
{
[CustomEditor(typeof(Transform))]
[CanEditMultipleObjects]
public class TransformInspector : Editor
{
private class Contents
{
public GUIContent positionContent = new GUIContent(LocalizationDatabase.GetLocalizedString("Position"), LocalizationDatabase.GetLocalizedString("The local position of this Game Object relative to the parent."));
public GUIContent scaleContent = new GUIContent(LocalizationDatabase.GetLocalizedString("Scale"), LocalizationDatabase.GetLocalizedString("The local scaling of this Game Object relative to the parent."));
public string floatingPointWarning = LocalizationDatabase.GetLocalizedString("Due to floating-point precision limitations, it is recommended to bring the world coordinates of the GameObject within a smaller range.");
}
private SerializedProperty m_Position;
private SerializedProperty m_Scale;
//private SerializedProperty m_Rotation;
private TransformRotationGUI m_RotationGUI;
private static Contents s_Contents;
public void OnEnable()
{
m_Position = base.serializedObject.FindProperty("m_LocalPosition");
m_Scale = base.serializedObject.FindProperty("m_LocalScale");
//m_Rotation = base.serializedObject.FindProperty("m_LocalRotation");
if (m_RotationGUI == null)
{
m_RotationGUI = new TransformRotationGUI();
}
m_RotationGUI.OnEnable(base.serializedObject.FindProperty("m_LocalRotation"), new GUIContent(LocalizationDatabase.GetLocalizedString("Rotation")));
}
Transform transform;
public override void OnInspectorGUI()
{
if (s_Contents == null)
{
s_Contents = new Contents();
}
if (!EditorGUIUtility.wideMode)
{
EditorGUIUtility.wideMode = true;
EditorGUIUtility.labelWidth = EditorGUIUtility.currentViewWidth - 212f;
}
base.serializedObject.Update();
原生Transform编辑器,这个两个脚本能直接更改检视窗口的Tranform的显示
最新推荐文章于 2024-04-18 10:05:45 发布
本文介绍如何使用两个脚本来修改Unity编辑器的检视窗口,以实现Transform组件属性的自定义显示,方便在开发过程中进行更直观的操作。
摘要由CSDN通过智能技术生成