private void DrawDataEntry(EntityStatDictionary data, StatData stat, EntityStatValues selectedData) { if (selectedData != null) { //Draw data for Entity, if available using (new GUILayout.HorizontalScope("box")) { GUI.backgroundColor = Color.white; var obj = new SerializedObject(selectedData.value); obj.Update(); var serializedProp = obj.FindProperty("value"); EditorGUILayout.PropertyField( serializedProp, new GUIContent(string.Empty), GUILayout.MinWidth(TableEntryWidth), GUILayout.MaxWidth(TableEntryWidth)); obj.ApplyModifiedProperties(); } } else { //No data for Entity, draw "N/A" using (new GUILayout.HorizontalScope( "box", GUILayout.MinWidth(TableEntryWidth + 8), GUILayout.MaxWidth(TableEntryWidth + 8))) { GUI.backgroundColor = Color.white; GUILayout.Label("N/A"); GUILayout.FlexibleSpace(); if (GUILayout.Button("+", GUILayout.MaxHeight(15))) { _entityData = data.entityData; _statData = stat; switch (stat.statTypeEnum) { case StatTypeEnum.BOOL: CreateBoolEntry(data.entityData.entityName, stat.Name); break; case StatTypeEnum.FLOAT: CreateFloatEntry(data.entityData.entityName, stat.Name); break; case StatTypeEnum.INT: CreateIntEntry(data.entityData.entityName, stat.Name); break; } } } } }
private void CreateStatEntry(string entityDataName, string statValue, StatType statTypeValue) { Undo.RecordObject(_globalDictionary, "Add new dictionary stat"); var statValues = new EntityStatValues { statData = _statData, value = statTypeValue }; AssetDatabase.CreateAsset( statValues.value, $"Assets/_SALVO/Data/Stat Values/{entityDataName}_{statValue}.asset"); EntityStatDictionary stat; //Create container if (!DoesEntityDataAlreadyExist(_entityData)) { stat = new EntityStatDictionary { entityData = _entityData, statValues = new List <EntityStatValues> { statValues } }; _globalDictionary.data.Add(stat); } else { //Entity Data - Already exists, just add to previous dictionaries stat = _globalDictionary.data.First(o => o.entityData == _entityData); stat.statValues.Add(statValues); } EditorUtility.SetDirty(_globalDictionary); AssetDatabase.SaveAssets(); }