protected virtual void ApplyProperty(Database.SpreadSheetData.CellEventData data) { var stringAsset = AssetDatabase.LoadAssetAtPath <StringAsset>("Assets/HK/AutoAnt/DataSources/StringAsset/CellEvent.asset"); this.eventName = stringAsset.CreateFinderSafe(data.Name); this.category = (Constants.CellEventCategory)Enum.Parse(typeof(Constants.CellEventCategory), data.Category); this.condition = AssetDatabase.LoadAssetAtPath <CellEventGenerateCondition>($"Assets/HK/AutoAnt/DataSources/CellEvents/Conditions/{data.Condition}.asset"); this.size = data.Size; this.constructionSE = AssetDatabase.LoadAssetAtPath <AudioClip>($"Assets/HK/AutoAnt/DataSources/SE/{data.Constructionse}.mp3"); this.destructionSE = AssetDatabase.LoadAssetAtPath <AudioClip>($"Assets/HK/AutoAnt/DataSources/SE/{data.Destructionse}.mp3"); this.constructionEffect = AssetDatabase.LoadAssetAtPath <GameObject>($"Assets/HK/AutoAnt/Prefabs/Effects/{data.Constructioneffect}.prefab").GetComponent <PoolableEffect>(); this.destructionEffect = AssetDatabase.LoadAssetAtPath <GameObject>($"Assets/HK/AutoAnt/Prefabs/Effects/{data.Destructioneffect}.prefab").GetComponent <PoolableEffect>(); this.gimmickPrefab = AssetDatabase.LoadAssetAtPath <GameObject>($"Assets/HK/AutoAnt/Prefabs/CellEvent/{data.Gimmickprefab}.prefab"); this.visibleAnimation = AssetDatabase.LoadAssetAtPath <GameObject>($"Assets/HK/AutoAnt/Prefabs/Tween/{data.Visibleanimation}.prefab").GetComponent <TweenAnimationAttacher>(); }
protected static T InternalGetOrCreateAsset <T>(Database.SpreadSheetData.CellEventData data) where T : CellEvent { var path = $"Assets/HK/AutoAnt/DataSources/CellEvents/{data.Classname}/{data.Id}.asset"; var result = AssetDatabase.LoadAssetAtPath <T>(path); if (result == null) { result = CreateInstance <T>(); result.name = data.Id.ToString(); AssetDatabase.CreateAsset(result, path); } result.ApplyProperty(data); EditorUtility.SetDirty(result); return(result); }
public static CellEvent GetOrCreateAsset(Database.SpreadSheetData.CellEventData data) { switch (data.Classname) { case "Housing": return(CellEvent.InternalGetOrCreateAsset <Housing>(data)); case "Facility": return(CellEvent.InternalGetOrCreateAsset <Facility>(data)); case "Road": return(CellEvent.InternalGetOrCreateAsset <Road>(data)); default: Debug.LogError($"CellEventType = {data.Classname}は未対応の値です"); return(null); } }