Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by Lukas_GMC · Oct 09, 2012 at 12:50 AM · editorinspectorcustomeditor

DrawDefaultInspector crash

I have multiple types of creatures the player can be and they all have different options that my game designer can tweak. I use DrawDefaultInspector to show these options but when changing to a different creature the editor crashes when it calls DrawDefaultInspector. This is a crucial piece of what were trying to do and I'd rather not hand code the entire gui for each creature. Thanks in advance.

Comment
Add comment · Show 3
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
avatar image rhys_vdw · Oct 09, 2012 at 03:25 AM 0
Share

The problem is on line 33. :-P

avatar image Lukas_GMC · Oct 09, 2012 at 06:37 AM 0
Share

Wrong. It's actually line 50. If anybody with any actual idea of whats going on please help.

avatar image rhys_vdw · Oct 09, 2012 at 06:41 AM 2
Share

Dude... I was joking. Post your code!

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Lukas_GMC · Oct 10, 2012 at 12:05 AM

 [CustomEditor(typeof(PlayerController))]
 public class PlayerEditor : Editor 
 {
     string[] CHARACTER_TYPE = {"NULL", "Frog", "Snake", "Armadillo"};
     public PlayerController m_player;
 
     public int Type
     {
         get 
         { 
             for(int i = 0; i < CHARACTER_TYPE.Length; ++i)
                 if(CHARACTER_TYPE[i] == m_player.Type())
                     return i;
             return 0;
         }
         set
         {
             if (value == Type || value <= 0)
                 return;
 
             GameObject newPlayer = (GameObject)Instantiate(Resources.Load("Prefabs/" + CHARACTER_TYPE[value], typeof(GameObject)), m_player.transform.position, m_player.transform.rotation);
             Debug.Log(newPlayer);
             DestroyImmediate(m_player.gameObject);
             m_player = newPlayer.GetComponent<PlayerController>();
             Selection.activeGameObject = newPlayer;
             newPlayer.name = "player";
         }
     }
 
 
 
     virtual public void OnEnable()
     {
         m_player = (PlayerController)target;
     }
 
     public override void OnInspectorGUI()
     {
         DrawPlayerGUI();
     }
 
     public void DrawPlayerGUI()
     {
         Type = EditorGUILayout.Popup("Type", Type, CHARACTER_TYPE, GUILayout.ExpandWidth(true));
         DrawDefaultInspector();
     }
 }
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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

10 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

Related Questions

Change variable in inspector depending on enum using struct 0 Answers

Property values changed by custom editor are reset when start playing 2 Answers

How to add UnityEvent using Custom Inspector? 1 Answer

CustomEditor and inherited components 1 Answer

How to update objects material on Editor 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