Hi everyone,
I read through several examples and questions in the forum but didn’t find a solution, because the examples does not working or facing a different solution-
I fill some references into a public static list<> EventSamplerRefList by an editor script. Several instances of the SamplerFixed.cs exist.These data of EventSamplerRefList should persist start/stop/build and restarting Unity.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class ManagerEventSamples{
[SerializeField]
public static List<EventSampleData> EventSamplerRefList = new List<EventSampleData>();
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
#endif
[System.Serializable]
[SerializeField]
public class EventSampleData {
public string evtName = "";
public ushort evtType = 0;
public double percent;
public Transform trackSideGO = null;
public short evtOP1 = 0;
public EventSampleData() {
}
}
using UnityEngine;
using System.Collections;
using UnityEditor;
using UnityEditor.SceneManagement;
[System.Serializable]
[CustomEditor(typeof(SamplerFixed))]
public class SamplerEditor : Editor
if (GUILayout.Button("Add(EventSample)")) {
SamplerFixed sampler = (SamplerFixed)target;
......
var eventSample = new EventSampleData();
ManagerEventSamples.EventSamplerRefList.Add(eventSample);
// Force serialization
EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene());
}
}
The list EventSamplerRefList exist as gobal access to several data by reference.
Does anyone have solution how to solve this?
Thanks a lot!