コード例 #1
0
        static void PreferencesGUI()
        {
            EditorGUILayout.LabelField("TransformInspector", (GUIStyle)"ShurikenModuleTitle");

            PreferenceSettings.i.LocalizeJP.Value = EditorGUILayout.ToggleLeft("日本語化", PreferenceSettings.i.LocalizeJP, GUILayout.ExpandWidth(false));
            TransformInspector.s_Contents         = null;

            var typeInspctWindow = System.Reflection.Assembly.Load("UnityEditor.dll").GetType("UnityEditor.InspectorWindow");
            var InspctWindow     = EditorWindow.GetWindow(typeInspctWindow, false, "Inspector", false);

            InspctWindow.Repaint();
        }
コード例 #2
0
        /// <summary>
        ///
        /// </summary>
        public override void OnInspectorGUI()
        {
            if (TransformInspector.s_Contents == null)
            {
                TransformInspector.s_Contents = new TransformInspector.Contents();
                //if( m_RotationGUI == null ) {
                m_RotationGUI = new TransformRotationGUIRefrection();
                m_RotationGUI.OnEnable(serializedObject.FindProperty("m_LocalRotation"), new GUIContent(Localization.GetLocalizedString("Rotation")));
                //}
            }

            if (!EditorGUIUtility.wideMode)
            {
                EditorGUIUtility.wideMode   = true;
                EditorGUIUtility.labelWidth = EditorGUIUtility.currentViewWidth - 212f;
            }

            this.serializedObject.Update();

            using (var h = new EditorGUILayout.HorizontalScope()) {
                EditorGUILayout.PropertyField(m_positionProperty, TransformInspector.s_Contents.positionContent);
                if (IsLabelClick(s_Contents.positionContent, m_positionProperty))
                {
                    var menu = new GenericMenu();
                    menu.AddItem(s_Contents.RevertValuetoPrefabContent, false, Helper.SetPrefabOverride, m_positionProperty);
                    menu.AddItem(s_Contents.CopyContent, false, MenuCopyPos, m_positionProperty);
                    menu.AddItem(s_Contents.PasteContent, false, MenuPastePos, m_positionProperty);
                    menu.AddItem(s_Contents.ToggleWorldPosContnte, PreferenceSettings.i.TransformInspector_ShowWorld.Value, PosMenu_ShowWorldPos);
                    menu.AddItem(s_Contents.FitGroundContent, false, Menu_FitGround, m_positionProperty);
                    menu.ShowAsContext();
                }

                if (GUIResetButton())
                {
                    m_positionProperty.vector3Value = Vector3.zero;
                    GUI.FocusControl("");
                }
            }
            if (PreferenceSettings.i.TransformInspector_ShowWorld.Value)
            {
                using (var h = new EditorGUILayout.HorizontalScope()) {
                    using (new EditorGUI.DisabledGroupScope(true)){
                        EditorGUILayout.Vector3Field(TransformInspector.s_Contents.worldPosContent, self.position);
                    }
                }
            }

            using (var h = new EditorGUILayout.HorizontalScope()) {
                m_RotationGUI.RotationField();

                if (IsLabelClick(TransformInspector.s_Contents.positionContent, m_rotationProperty))
                {
                    var menu = new GenericMenu();
                    menu.AddItem(s_Contents.RevertValuetoPrefabContent, false, Helper.SetPrefabOverride, m_rotationProperty);
                    menu.ShowAsContext();
                }

                if (GUIResetButton())
                {
                    if (m_rotationProperty == null)
                    {
                        Debug.Log("m_rotationProperty is null.");
                    }
                    else
                    {
                        Debug.Log("m_rotationProperty is reset value.");
                        m_rotationProperty.quaternionValue = Quaternion.Euler(Vector3.zero);
                        GUI.FocusControl("");
                    }
                }
            }


            using (new EditorGUILayout.HorizontalScope()) {
                if (s_scaleMode)
                {
                    float f = m_scaleProperty.vector3Value.x;
                    f = EditorGUILayout.FloatField(TransformInspector.s_Contents.scaleXYZContent, f, GUILayout.ExpandWidth(true));
                    if (IsLabelClick(TransformInspector.s_Contents.scaleXYZContent, m_scaleProperty))
                    {
                        var menu = new GenericMenu();
                        menu.AddItem(s_Contents.RevertValuetoPrefabContent, false, Helper.SetPrefabOverride, m_scaleProperty);
                        menu.AddItem(s_Contents.ScaleXYZModeContent, s_scaleMode, SclMenu_ScaleXYZMode);
                        menu.ShowAsContext();
                    }

                    m_scaleProperty.vector3Value = new Vector3(f, f, f);
                }
                else
                {
                    EditorGUILayout.PropertyField(m_scaleProperty, s_Contents.scaleContent);
                    if (IsLabelClick(s_Contents.scaleContent, m_scaleProperty))
                    {
                        var menu = new GenericMenu();
                        menu.AddItem(s_Contents.RevertValuetoPrefabContent, false, Helper.SetPrefabOverride, m_scaleProperty);
                        menu.AddItem(s_Contents.ScaleXYZModeContent, s_scaleMode, SclMenu_ScaleXYZMode);
                        menu.ShowAsContext();
                    }
                }

                if (GUIResetButton())
                {
                    m_scaleProperty.vector3Value = Vector3.one;                     // Scaleの初期値はVector3(1f,1f,1f)
                    GUI.FocusControl("");
                }
            }


            Transform transform = base.target as Transform;
            Vector3   position  = transform.position;

            if (Mathf.Abs(position.x) > 100000f || Mathf.Abs(position.y) > 100000f || Mathf.Abs(position.z) > 100000f)
            {
                EditorGUILayout.HelpBox(TransformInspector.s_Contents.floatingPointWarning, MessageType.Warning);
            }

            serializedObject.ApplyModifiedProperties();
        }