Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 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 Jan 09 at 03:03 AM by dark9spring for the following reason:

不可重现或已经过期的问题

avatar image
0
Question by dark9spring · Jan 01 at 12:46 PM · script errorcustom-inspectorcustomeditor

Using CustomEditor caused error which was CS0246.

I have two classes of my project. First one is some data to show up.

 using System;
 using UnityEngine;
 
 public class InspectorTest : MonoBehaviour
 {
     public int a;
     public float b;
     public string c;
     public DataBase d;
 }
 [Serializable]
 public class DataBase
 {
     public int a;
     public float b;
 }

Second one is used to exhibit those data onto inspector.

 using UnityEditor;
 
 [CustomEditor(typeof(InspectorTest))]
 public class InspectorEditor : Editor
 {
     public SerializedObject inspectorTest;
     public SerializedProperty aInteger;
     public SerializedProperty bFloat;
     public SerializedProperty cString;
     public SerializedProperty dDataBase;
 
     private void OnEnable()
     {
         inspectorTest = new SerializedObject(target);
         aInteger = inspectorTest.FindProperty("a");
         bFloat = inspectorTest.FindProperty("b");
         cString = inspectorTest.FindProperty("c");
         dDataBase = inspectorTest.FindProperty("d");
     }
 
     public override void OnInspectorGUI()
     {
         base.OnInspectorGUI();
         EditorGUILayout.PropertyField(aInteger);
         EditorGUILayout.PropertyField(cString);
         EditorGUILayout.PropertyField(bFloat);
         EditorGUILayout.PropertyField(dDataBase);
         inspectorTest.Update();
     }
 }
 

When I typed InspectorTest into "typeof", the compiler done nothing and without any tips. Then caused the error was CS0246. I tried to save my code in VS. The error was remaining here. So I turned to unity and figured out there was no error in console panel but same properties in inspector. First one is located in "Assets/Scripts/Attribute", second one is located in "Assets/Scripts/Attribute/Editor". My Unity version is 2020.3.24.f1c1. How could I fix it?

Comment
Add comment · Show 1
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 dark9spring · Jan 01 at 02:23 AM 0
Share

I have uploaded inspector panel's image. Wishing this could be helpful.alt text

snipaste-2022-01-01-10-19-09.png (64.1 kB)

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

179 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 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 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

EditorGUILayout.Popup with an array of GameObject? 0 Answers

EditorGUILayout.BeginVertical("Box") not filling the inspector 0 Answers

Custom Editor slider not working inside if statement 0 Answers

Use placeholder text in CustomEditor 0 Answers

Custom Editor showing twice? 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