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 Mrintoxx · Jul 02, 2020 at 11:22 AM · editor-scriptingscriptableobject

[SOLVED] Custom editor can't acces to variables of a scriptable object

Hi guys ! I encounter a problem while scripting a custom editor for my scriptables objects. I'm pretty new in that domain so please be gentle. when i declare : [CustomEditor(typeof(Fish))] => Fish is the name of my scriptable object i've got the error : missing assemble reference. but when i write :

 public override void OnInspectorGUI()
     {
         base.OnInspectorGUI();
      
         EditorGUILayout.HelpBox("Test", MessageType.Info);
 
     }

The base inspector and the helpox is shown so i trust it is recognized and i can add more ediots options. But if i try to access a avariable from scriptable object it can't found it.

 public override void OnInspectorGUI()
     {
         var fish = target as Fish;
         //base.OnInspectorGUI();
         var nameLabel = target.nameLabel;
         EditorGUILayout.HelpBox("Test", MessageType.Info);
     }

I can use the serializedObject.FindProperty(); but after i can't modify the values with the fields.

The script of the scriptable object is pretty simple :

 using UnityEngine;
 
 [CreateAssetMenu(fileName = "Fish", menuName = "Game/Fish", order = 0)]
 [System.Serializable]
 public class Fish : ScriptableObject
 {
     public string nameLabel = null;
     [Header("Inclusive")]
     public int minScoreValue = 0;
     [Header("Exclusive")]
     public int maxScoreValue = 0;
     public AudioClip audioClip;
     public int percentageOfSpawn = 0;
     [Range(0, 100)]
     public float speedMovement;
 
     public int ScoreToAdd()
     {
         int score = Random.Range(minScoreValue, maxScoreValue);
         return score;
     }
 }
 

If anyone have an idea, thanks for help :)

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 Bunny83 · Jul 02, 2020 at 11:51 AM 0
Share

Well where do you have placed your Fish class in your project and where's your custom editor located? Do you use any assembly definition files?

avatar image Mrintoxx Bunny83 · Jul 02, 2020 at 11:57 AM 0
Share

@Bunny83 thanks for reply ! :D Custom editor is located in Assets/Editor/FishEditor.cs Fish class is in Assets/Ressources/Scripts/ScriptableObjects/Fish.cs And i don't use any assembly file, or at leat i've never created one or modified I've checked and for both the assembly definition file is Assembly-CSharp.dll

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Mrintoxx · Jul 03, 2020 at 05:05 AM

After searching for a while and thanks to @bunny83 the problemn was with the assembly definition file.

The scriptable object was driven by : assembly-csharp.dll And the editor was driven by : assembly-csharp-editor.dll

In the assemble-csharp, it was no reference to csharp-editor, so it woul'dnt recognize the type.

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

143 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

Related Questions

Cannot include ScriptableObject in asset bundle in Unity 5 0 Answers

Animator Editor Window disappear when generate AnimatorController inside other asset 0 Answers

Scriptable Object save List 0 Answers

Create List of custom class types, for use in custom editor 0 Answers

Is it possible to write a function in the backend of an editor script for a scriptableObject? 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