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