It’s strange few days ago everything was running fine now i getting 2 IndexOutOFRange Exception errors. Does anyone have any ideas how to fix this …
using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(SpawningMachyne))]
public class SpawnEditor : Editor
{
public override void OnInspectorGUI()
{
SpawningMachyne SM = target as SpawningMachyne;
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(serializedObject.FindProperty("m_Script"));
SerializedProperty ob = serializedObject.FindProperty("holder");
EditorGUILayout.PropertyField(ob);
if(ob.isExpanded)
{
EditorGUI.indentLevel += 1;
EditorGUILayout.PropertyField(ob.FindPropertyRelative("Array.size"));
for (int i=0; i < ob.arraySize; i++ )
{
SerializedProperty el = ob.GetArrayElementAtIndex(i);
EditorGUILayout.PropertyField(el);
if (el.isExpanded)
{
EditorGUI.indentLevel += 1;
EditorGUILayout.PropertyField(el.FindPropertyRelative("go"));
switch (DoShipChecking(SM, i))
{
case 0: break;
case 1:
GUILayout.Space(10);
GUILayout.BeginVertical("box");
EditorGUILayout.LabelField("Eship1");
GUILayout.Space(5);
EditorGUILayout.PropertyField(el.FindPropertyRelative("flypoints"), true);
EditorGUILayout.PropertyField(el.FindPropertyRelative("onfinish"), true);
GUILayout.EndVertical();
GUILayout.Space(10);
break;
case 4:
GUILayout.Space(10);
GUILayout.BeginVertical("box");
EditorGUILayout.LabelField("Eship4");
GUILayout.Space(5);
EditorGUILayout.PropertyField(el.FindPropertyRelative("flypoints"), true);
EditorGUILayout.PropertyField(el.FindPropertyRelative("onfinish"), true);
GUILayout.EndVertical();
GUILayout.Space(10);
break;
}
EditorGUILayout.PropertyField(el.FindPropertyRelative("Start_Wait"));
EditorGUILayout.PropertyField(el.FindPropertyRelative("Spawn_Wait"));
EditorGUILayout.PropertyField(el.FindPropertyRelative("Count"));
EditorGUILayout.PropertyField(el.FindPropertyRelative("spawntype"));
if (SM.holder_.spawntype == SpawnType.Random) **// exception error Here**_
{
EditorGUILayout.PropertyField(el.FindPropertyRelative(“randomdir”));
}
EditorGUILayout.PropertyField(el.FindPropertyRelative(“Spawn_Pos”));
EditorGUI.indentLevel -= 1;
}
}
EditorGUI.indentLevel -= 1;
}
//EditorGUILayout.PropertyField(serializedObject.FindProperty(“objects”), true);
if (EditorGUI.EndChangeCheck())
serializedObject.ApplyModifiedProperties();
}
int DoShipChecking(SpawningMachyne SM, int i)
{
if (SM.holder.go.GetComponent<E_Ship_1>() != null) // and another Here
return 1;
if (SM.holder*.go.GetComponent<E_Ship_4>() != null)
return 4;
return 0;
_}
}*_