/// <summary> /// Confirms that there is an asset in the project folder to store this value in during gameplay. /// Note that this is not part of the save file! /// </summary> /// <returns>True if value asset is correctly referenced</returns> protected bool ConfirmValueExistence <T> (ValueAsset <T> valueAsset) { if (valueAsset == null) { Debug.LogError(name + " has no value asset referenced to store its value!", gameObject); enabled = false; return(false); } return(true); }
public static void RemoveEvent(ValueAsset <TValue> asset) { Undo.RecordObject(asset, $"Remove {typeof(TGameEvent).Name} at {asset.name}"); DestroyImmediate(asset.OnValueChanged, true); asset.OnValueChanged = null; AssetDatabase.SaveAssets(); EditorUtility.SetDirty(asset); }
public static void CreateEvent(ValueAsset <TValue> asset) { var newEvent = CreateInstance <TGameEvent>(); newEvent.name = $"On{asset.name}Change"; Undo.RecordObject(newEvent, $"Created new {typeof(TGameEvent).Name} to {asset.name}"); AssetDatabase.AddObjectToAsset(newEvent, asset); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(newEvent)); asset.OnValueChanged = newEvent; AssetDatabase.SaveAssets(); EditorUtility.SetDirty(asset); }
private void OnEnable() { asset = target as ValueAsset <TValue>; }