22 CustomRemoveElementFunction =
"Remove",
23 CustomRemoveIndexFunction =
"RemoveAt",
24 CustomAddFunction =
"Add",
25 OnBeginListElementGUI =
"OnBeginListElementGUI"
26 ), DisableContextMenu(DisableForCollectionElements =
true, DisableForMember =
false),
36 TextInputDialogue.ShowDialogue(
37 "Enter ID for new step",
40 if (!
string.IsNullOrEmpty(stepId))
45 $
"{Path.GetDirectoryName(AssetDatabase.GetAssetPath(this))}";
47 if (!stepData.listOfSteps.Any(d => d.stepID.Equals(stepId)))
50 $
"{scenarioPath}/{ScenarioEditorWindow.StepsDirectoryName}/{stepId}.asset";
52 var stepItem = ScriptableObject.CreateInstance<StepItemSO>();
53 stepItem.stepID = stepId;
54 AssetDatabase.CreateAsset(stepItem, stepPath);
58 EditorUtility.DisplayDialog(
67 EditorUtility.DisplayDialog(
74 AssetDatabase.Refresh();
79 public void RemoveAt(
int index)
81 AssetDatabase.DeleteAsset(AssetDatabase.GetAssetPath(
this.listOfSteps[index]));
82 AssetDatabase.Refresh();
91 public void OnBeginListElementGUI(
int index)
93 SirenixEditorGUI.BeginHorizontalToolbar();
95 if (SirenixEditorGUI.ToolbarButton(
"Duplicate"))
97 TextInputDialogue.ShowDialogue(
98 "Enter ID for new step",
101 if (!
string.IsNullOrEmpty(stepId))
106 $
"{Path.GetDirectoryName(AssetDatabase.GetAssetPath(this))}";
108 if (!stepData.listOfSteps.Any(d => d.stepID.Equals(stepId)))
111 $
"{scenarioPath}/{ScenarioEditorWindow.StepsDirectoryName}/{stepId}.asset";
114 ScriptableObject.Instantiate(listOfSteps[index]);
116 stepItem.stepID = stepId;
117 AssetDatabase.CreateAsset(stepItem, stepPath);
121 EditorUtility.DisplayDialog(
130 EditorUtility.DisplayDialog(
137 AssetDatabase.Refresh();
142 if (SirenixEditorGUI.ToolbarButton(
"Rename"))
144 TextInputDialogue.ShowDialogue(
150 if (
string.IsNullOrEmpty(stepId) || !step.ValidateID(stepId))
153 EditorUtility.DisplayDialog(
155 "Invalid step ID: " + stepId,
162 step.stepID = stepId;
163 EditorUtility.SetDirty(step);
164 AssetDatabase.SaveAssetIfDirty(step);
165 AssetDatabase.Refresh();
167 AssetDatabase.RenameAsset(
168 AssetDatabase.GetAssetPath(step),
172 AssetDatabase.Refresh();
178 SirenixEditorGUI.EndHorizontalToolbar();
181 public void Rebuild()
183 var scenarioPath = $
"{Path.GetDirectoryName(AssetDatabase.GetAssetPath(this))}";
185 var stepsPath = $
"{scenarioPath}/{ScenarioEditorWindow.StepsDirectoryName}";
190 string[] guids = AssetDatabase.FindAssets(
"t:StepItemSO",
new[] {stepsPath});
192 foreach (
string guid
in guids)
198 EditorUtility.SetDirty(
this);
204 if (stepID ==
string.Empty)
220 public void Validate()
223 Debug.Log($
"StepsData {name} validation begin");
230 if (Regex.IsMatch(v1,
@"\p{IsCyrillic}"))
232 Debug.LogError($
"StepsData {v1} Cyrillic symbol presented!!");
241 Debug.LogError($
"StepsData {v1} duplicates at position {i}:{j}");
246 Debug.Log($
"StepsData {name} validation finish");