Hello,
I have been looking on the internet to solve this problem but did not find any solution. So basically I have this editor script:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[CustomEditor(typeof(HexagonalGrid))]
public class HexagonalGridEditor : GridEditor
{
private HexagonalGrid m_hexagonalGrid = null;
/*******************************************************************/
/************************ grid properties **************************/
/*******************************************************************/
private SerializedProperty m_orientation = null;
private SerializedProperty m_type = null;
private SerializedProperty m_pointToppedClassicType = null;
private SerializedProperty m_flatToppedClassicType = null;
/*******************************************************************/
/********************** grid box properties ************************/
/*******************************************************************/
private SerializedProperty m_hexagonRadius = null;
private void OnEnable()
{
m_hexagonalGrid = (HexagonalGrid)target;
m_orientation = serializedObject.FindProperty("m_orientation");
m_type = serializedObject.FindProperty("m_type");
m_pointToppedClassicType = serializedObject.FindProperty("m_pointToppedClassicType");
m_flatToppedClassicType = serializedObject.FindProperty("m_flatToppedClassicType");
m_hexagonRadius = serializedObject.FindProperty("m_hexagonRadius");
}
public override void PropertiesInspector()
{
EditorGUILayout.Space();
EditorGUILayout.LabelField("Grid", EditorStyles.boldLabel);
EditorGUILayout.BeginHorizontal();
EditorGUILayout.PropertyField(m_type);
EditorGUILayout.PropertyField(m_orientation);
EditorGUILayout.EndHorizontal();
if (m_hexagonalGrid.m_type == HexagonalGrid.Type.Classic)
{
if (m_hexagonalGrid.m_orientation == HexagonalGrid.Orientation.PointyTopped)
{
EditorGUILayout.PropertyField(m_pointToppedClassicType, new GUIContent("Subtype"));
}
else if (m_hexagonalGrid.m_orientation == HexagonalGrid.Orientation.FlatTopped)
{
EditorGUILayout.PropertyField(m_flatToppedClassicType, new GUIContent("Subtype"));
}
}
EditorGUILayout.Space();
EditorGUILayout.LabelField("Hexagon", EditorStyles.boldLabel);
EditorGUILayout.PropertyField(m_hexagonRadius, new GUIContent("Radius"));
EditorGUILayout.Space();
}
}
My problem is at the beginning of the PropertiesInspector method (which is called by the mother class in the OnInspectorGUI method). I want to put the two enums m_type and m_pointToppedClassicType on the same row, but using BeginHorizontal gives me a result where the second enum is not entirely drawed in the inspector (and there is no scrollbar):
Any idea how to solve this ?