C# Custom Object Editor Error

Hi, i have this object i created in C# called Skill.
this is the object :

public class Skill {
    string Name;
    float Effect;
    float CastTime;
    SkillType Type;
    float Cost;
    int Times;
    float Range;
    int Thumbnail;
    EffectProperties Ep;

    public Skill(string Name, float Effect, float CastTime, SkillType Type, float Cost, int Times, float Range, int Thumbnail, EffectProperties Ep){
	    this.Name = Name;
	    this.Effect = Effect;
	    this.CastTime = CastTime;
	    this.Type = Type;
	    this.Cost = Cost;
	    this.Times = Times;
	    this.Range = Range;
	    this.Thumbnail = Thumbnail;
	    this.Ep = Ep;

    public string namE {
	    get{ return Name; }
	    set{ Name = value; }

public float effect {
	get{ return Effect; }
	set{ Effect = value; }

public float castTime {
	get{ return CastTime; }
	set{ CastTime = value; }

public SkillType type {
	get{ return Type; }
	set{ Type = value; }

public float cost {
	get{ return Cost; }
	set{ Cost = value; }

public int times {
	get{ return Times; }
	set{ Times = value; }

public float range {
	get{ return Range; }
	set{ Range = value; }

public int thumbnail {
	get{ return Thumbnail; }
	set{ Thumbnail = value; }

public EffectProperties ep{
	get{ return Ep; }
	set{ Ep = value; }

public struct EffectProperties {
private bool atTarget;
private bool projectile;
private int particles;
private float lifeTime;

public EffectProperties(bool atTar, bool Proj, int Par, float lifeT){
	atTarget = atTar;
	projectile = Proj;
	particles = Par;
	lifeTime = lifeT;

public bool AtTarget{
	get{ return atTarget; }
	set{ atTarget = value; }

public bool Projectile{
	get{ return projectile; }
	set{ projectile = value; }

public int Particles{
	get{ return particles; }
	set{ particles = value; }

public float LifeTime{
	get{ return lifeTime; }
	set{ lifeTime = value; }

public enum SkillType{

and i have made an editor script for it so i can see the object in the inspector when ever i type public Skill myVar; int a script.
but the problem is that i keep getting an error from the SkillEditor.cs script that says
error CS0030: Cannot convert type UnityEngine.Object' to Skill’ and i dont know how to solve it. please help, here is my SkillEditor.cs script:

using UnityEngine;
using UnityEditor;
using System.Collections;

[CustomEditor (typeof(Stats))]
public class SkillEditor : Editor {
    public override void OnInspectorGUI(){
	    Skill pp = (Skill)target;
	    GUILayout.Label("Skill Object Editor");
	    pp.castTime = EditorGUILayout.FloatField("Cast Time",pp.castTime);

thanks for reading

I have never tried this, but you could try it out.

// Creates new serializedObject from the selected gameobject 
var so : SerializedObject = new SerializedObject(Selection.activeGameObject.GetComponent(Skill));

so.FindProperty("castTime").floatValue = EditorGUILayout.FloatField("Cast Time", so.FindProperty("castTime").floatValue);


The main issue is that your custom editor is for the class “Stats”, so the target variable will always be a Stats instance which of course can’t be casted to Skill.

Also keep in mind that structs aren’t serialized! Also since you use private variables (and properties to access them) you need to mark the private variables with SerializeField so they are serialized.

// ...
private string Name;
// ...

Otherwise your editor is pretty useless since all changes are gone when you save / load the scene or you enter / leave playmode.