I feel I am very close but for the life of me I cannot figure this out as I keep getting funky results. In the image below I am wanting to make multiple of these but I just cant figure it out:
As you can see that I can see in the image above I would like there to be another "Size" which I can set a number and multiple of what you see in the red box would show up.
At the moment I have a Camera_Positioning script with an Editor, a [System.Serializable] script that hold the variables and a Drawer that goes with it.
I have tried making a script that would make an array of Camera_Positioning and I also attempted something along the lines of 2D arrays but I doesn't work or I am doing something wrong. Anyone have any ideas on how to make an array of the red boxes I have?
EDIT : Here is the code that I have currently :
My Camera_Positioning and Camera_Positioning_Editor script. The Camera_Positioning is what I attach to my GameObject.
public class Camera_Positioning : MonoBehaviour {
public CamPosLookArray[] PosLook;
}
[CanEditMultipleObjects]
[CustomEditor(typeof(Camera_Positioning))]
public class Camera_Positioning_Editor : Editor {
SerializedProperty posLook;
void OnEnable()
{
// Setup the SerializedProperties.
posLook = serializedObject.FindProperty("PosLook");
}
public override void OnInspectorGUI()
{
// Set the indentLevel to 0 as default (no indent).
EditorGUI.indentLevel = 0;
// Update
serializedObject.Update();
EditorGUILayout.PropertyField(posLook.FindPropertyRelative("Array.size"));
EditorGUILayout.BeginHorizontal();
EditorGUILayout.LabelField("Camera Position", EditorStyles.boldLabel, GUILayout.Width(Screen.width / 2.8f));
EditorGUILayout.LabelField("Camera Look", EditorStyles.boldLabel, GUILayout.Width(Screen.width / 2.8f));
EditorGUILayout.LabelField("Story", EditorStyles.boldLabel, GUILayout.Width(75f));
EditorGUILayout.EndHorizontal();
for (int i = 0; i < posLook.arraySize; i++)
{
EditorGUILayout.PropertyField(posLook.GetArrayElementAtIndex(i), GUIContent.none);
}
// Apply.
serializedObject.ApplyModifiedProperties();
}
}
My CamPosLookArray script:
[System.Serializable]
public class CamPosLookArray {
public CameraPos_CameraLook[] PosLookArray;
}
My CameraPos_CameraLook and CameraPos_CameraLook_Editor script:
[System.Serializable]
public class CameraPos_CameraLook {
public Transform CameraPosition;
public Transform CameraLook;
public int CameraStory;
}
[CustomPropertyDrawer(typeof(CameraPos_CameraLook))]
public class CameraPos_CameraLook_Drawer : PropertyDrawer {
// Draw the property inside the given rect
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
// Using BeginProperty / EndProperty on the parent property means that
// prefab override logic works on the entire property.
EditorGUI.BeginProperty(position, label, property);
// Draw label
position = EditorGUI.PrefixLabel(position, GUIUtility.GetControlID(FocusType.Passive), label);
// Don't make child fields be indented
var indent = EditorGUI.indentLevel;
EditorGUI.indentLevel = 0;
// Calculate rects
Rect camPos = new Rect(position.x, position.y, Screen.width / 3f, position.height);
Rect camLook = new Rect(position.x + Screen.width / 2.75f, position.y, Screen.width / 3f, position.height);
Rect camStory = new Rect(position.x + (2.2f *Screen.width) / 3f, position.y, 75f, position.height);
// Draw fields - passs GUIContent.none to each so they are drawn without labels
EditorGUI.PropertyField(camPos, property.FindPropertyRelative("CameraPosition"), GUIContent.none);
EditorGUI.PropertyField(camLook, property.FindPropertyRelative("CameraLook"), GUIContent.none);
EditorGUI.PropertyField(camStory, property.FindPropertyRelative("CameraStory"), GUIContent.none);
// Set indent back to what it was
EditorGUI.indentLevel = indent;
EditorGUI.EndProperty();
}
}
When I have all that I get :
What I am trying to achieve in the picture above is everywhere you see a triangle (2 of them) should be what is in the first picture at the top in the red box.


