- Home /
[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 :)
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?
@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
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.
Your answer
Follow this Question
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