- Home /
Editing custom types in the inspector
Hello, I am trying to edit an object in the Inspector that I've defined (here called CConnector
). However, all that is shown in the Inspector is the string ScriptCode
. CConnector
is just a basic class, not a ScriptableObject, so I'm not sure if that affects how I can use it. Also: built a custom editor that allows me to edit the individual CConnector
s, but the each element of Connectors
turns into null
on Play, so I was wondering if it had to do something with this script here. Thanks! (MacOS, Unity 2020.2).
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu(menuName = "Cutscenes/Cutscene Script")]
[ExecuteInEditMode]
public class CutsceneScript : ScriptableObject
{
[SerializeField]
private string scriptCode;
public string ScriptCode
{
get { return scriptCode; }
set { scriptCode = value; }
}
[SerializeField]
private CConnector startConnector;
public CConnector StartConnector
{
get { return startConnector; }
set { startConnector = value; }
}
[SerializeField]
private List<CConnector> connectors = new List<CConnector>();
public List<CConnector> Connectors
{
get { return connectors; }
set { connectors = value; }
}
}
Answer by Namey5 · Mar 21, 2021 at 02:23 AM
For an object to be displayed and serialized in the editor you need to manually mark the class as Serializable. You haven't provided the class itself here, but as an example;
[System.Serializable]
public class CConnector
{
// ...
}
Your answer
![](https://koobas.hobune.stream/wayback/20220613031030im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Show multiple attached scripts variables in one script in the inspector 0 Answers
Problems With Variable Class Arrays... 1 Answer
Showing scriptable object and bool within that object in inspector. 0 Answers
Replicate "Apply" and "Revert" button functionality in ScriptableObject Editor Inspector 2 Answers
HeaderAttribute [Header()] on ScriptableObject not working? 2 Answers