using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
using System;
using UnityEditor.SceneManagement;
[System.Serializable]
[CustomEditor(typeof(Wave))]
public class WaveEditor : Editor {
int numberOfSegments = 1;
public override void OnInspectorGUI()
{
Wave myTarget = (Wave)target;
EditorGUI.BeginChangeCheck();
numberOfSegments = EditorGUILayout.IntField("Number of wave segments:", numberOfSegments);
if (EditorGUI.EndChangeCheck())
{
if (numberOfSegments < 1)
numberOfSegments = 1;
Array.Resize(ref myTarget.waveSegments, numberOfSegments);
Array.Resize(ref myTarget.waveSegmentsDelay, numberOfSegments - 1);
}
for (int i = 0; i < myTarget.waveSegments.Length; i++)
{
myTarget.waveSegments[i]=(WaveSegment)EditorGUILayout.ObjectField(myTarget.waveSegments[i], typeof(WaveSegment), true);
if (i != myTarget.waveSegments.Length - 1) myTarget.waveSegmentsDelay[i] = EditorGUILayout.FloatField("Delay", myTarget.waveSegmentsDelay[i]);
}
if (GUI.changed)
{
Undo.RecordObject(myTarget,"save");
EditorUtility.SetDirty(myTarget);
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
AssetDatabase.SaveAssets();
Repaint();
Debug.Log("SAVED");
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
[System.Serializable]
[CreateAssetMenu(fileName = "Wave", menuName = "Wave/Wave", order = 3)]
public class Wave : ScriptableObject
{
public WaveSegment[] waveSegments;
public float[] waveSegmentsDelay;
private void Awake()
{
waveSegments = new WaveSegment[1];
}
}
i tried everything but still not saving…