Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
This question was closed Dec 27, 2016 at 12:23 PM by Oziry for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by Oziry · Dec 26, 2016 at 08:00 AM · error-handling

Index Out OF Range Exception

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[i].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[i].go.GetComponent<E_Ship_1>() != null)      **//  and another Here**
         return 1;
     if (SM.holder[i].go.GetComponent<E_Ship_4>() != null)
         return 4;

     return 0;
 }

}

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
0

Answer by Oziry · Dec 27, 2016 at 12:22 PM

 //soliution is to use this to update array making shiure it initiated
 
 if (EditorGUI.EndChangeCheck())
       serializedObject.ApplyModifiedProperties();
 EditorGUI.BeginChangeCheck();
 
 // and use this to bypas emty game objects
 
 if (SM.holder[i].ship)
 {
     //stuff to do if initiated
 }

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

83 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

error CS0118 'charanim.CameraTurn' is a field but a 'type' was 'expected' 1 Answer

Unity Unet spawnig Fail,Unity Unet NetworkManager spawning fail 1 Answer

Webplayer: Catch "Failed to download data file" error 0 Answers

Append log error message 0 Answers

What does this error message mean and how do I fix it? 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges