原生Transform编辑器,这个两个脚本能直接更改检视窗口的Tranform的显示

本文介绍如何使用两个脚本来修改Unity编辑器的检视窗口,以实现Transform组件属性的自定义显示,方便在开发过程中进行更直观的操作。
摘要由CSDN通过智能技术生成
//**********************************************************************
// 文件名(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();
      
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值