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 /
avatar image
0
Question by pianobry · Dec 13, 2016 at 06:07 AM · scriptableobjectcustom editor

Why isn't my CustomEditor's OnInspectorGUI() running?

Hi,

I hope someone can help. I've been scouring the forums, working on a solution and I think I'm just missing something. The OnInspectorGUI in my CustomEditor is never being run. I placed a breakpoint inside and it doesn't get hit. Here's my code. Any advice is GREATLY appreciated!

 using System;
 using UnityEngine;
 using UnityEditor;
 
 [CustomEditor(typeof(Row))]
 public class RowEditor : Editor {
 
     bool toggle1, toggle2, toggle3, toggle4;
 
     public override void OnInspectorGUI() {
         GUILayoutOption toggleOption = GUILayout.Width (EditorGUIUtility.currentViewWidth / 4);
         EditorGUILayout.BeginHorizontal ();
         toggle1 = EditorGUILayout.Toggle ("", toggle1, toggleOption);
         toggle2 = EditorGUILayout.Toggle ("", toggle2, toggleOption);
         toggle3 = EditorGUILayout.Toggle ("", toggle3, toggleOption);
         toggle4 = EditorGUILayout.Toggle ("", toggle4, toggleOption);
         EditorGUILayout.EndHorizontal ();
     }
 }


 using System;
 using UnityEngine;
 
 [Serializable]
 public class Row : ScriptableObject {
 
     public bool track1;
     public bool track2;
     public bool track3;
     public bool track4;
 
 }


 using UnityEngine;
 using System.Collections;
 
 public class SpawnManager : MonoBehaviour {
 
     public Row spawnRow;
 
 }
Comment
Add comment · Show 2
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 hexagonius · Dec 13, 2016 at 07:28 AM 0
Share

is the script placed in a folder named editor?

avatar image pianobry hexagonius · Dec 13, 2016 at 12:36 PM 0
Share

The editor script is in Assets > Scripts > Editor ... The others are in in Assets > Scripts > ScriptableObjects and Assets > Scripts

1 Reply

· Add your reply
  • Sort: 
avatar image
3
Best Answer

Answer by Adam-Mechtley · Dec 13, 2016 at 12:47 PM

This editor will be displayed when you have a Row asset selected. It will not appear when you have your SpawnManager selected, as you will just see an object reference field. You need to either:

  1. Add CreateAssetMenuAttribute to your Row class and then create one in your project to select or

  2. Make Row inherit from System.Object and create a custom PropertyDrawer for it, rather than creating a custom Editor for it

Comment
Add comment · Show 1 · 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
avatar image pianobry · Dec 13, 2016 at 02:00 PM 0
Share

I did not realize that. Thank you very much. You saved me a lot of additional time.

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

6 People are following this question.

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

Related Questions

Custom Inspector doesn't show changes immediatley 2 Answers

Drag from custom editor ObjectField 0 Answers

Calling OnValidate on a ScriptableObject with a list of ScriptableObjects 1 Answer

[Custom Editor] MonoBehaviour vs Scriptable Object 0 Answers

Object field not working in custom editor for scriptable object? 0 Answers


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