Documentation for the Unity C# Library
Loading...
Searching...
No Matches
StepItemSO.cs
Go to the documentation of this file.
1using System;
2using System.Collections;
3using System.Collections.Generic;
4using System.IO;
5using System.Linq;
6using Sirenix.OdinInspector;
7using UnityEditor;
8using UnityEngine;
9
10namespace PixoVR.Event
11{
12 [CreateAssetMenu(menuName = "Scenarios Data Menu/Create Step", fileName = "Step", order = 2)]
14 {
15 [ReadOnly] public string stepID;
16 public List<StepFunction> functionsStep;
17 public bool waitForUserAction;
18
19 [ValueDropdown("GetStepNames")] public List<string> nextSteps;
20
21 [ValueDropdown("GetVoiceoverNames")] public string voiceOverIDWrongAction = "";
22
32
33 [NonSerialized]
34 private StepItem _item;
35#if UNITY_EDITOR
36 [ReadOnly] public StepsDataSO owner;
37
38 private IEnumerable GetStepNames()
39 {
40 var list = new ValueDropdownList<string>();
41
42 for (int i = 0; i < owner.listOfSteps.Count; i++)
43 {
44 list.Add(owner.listOfSteps[i].stepID);
45 }
46
47 return list;
48 }
49
50 private IEnumerable GetVoiceoverNames()
51 {
52 var list = new ValueDropdownList<string>();
53 list.Add("");
54
55 if (owner.owner.VoiceOverData != null)
56 {
57 for (int i = 0; i < owner.owner.VoiceOverData.voiceOverInfos.Count; i++)
58 {
59 list.Add(owner.owner.VoiceOverData.voiceOverInfos[i].id);
60 }
61 }
62
63 return list;
64 }
65
66 private void OnValidate()
67 {
68 Validate();
69 }
70
71 public void Validate()
72 {
73 var stepDataPath = Path.GetDirectoryName(Path.GetDirectoryName(AssetDatabase.GetAssetPath(this)));
74
75 // Find all Texture2Ds that have 'co' in their filename, that are labelled with 'architecture' and are placed in 'MyAwesomeProps' folder
76 string[] guids = AssetDatabase.FindAssets("t:StepsDataSO", new[] {stepDataPath});
77
78 foreach (string guid in guids)
79 {
80 owner = AssetDatabase.LoadAssetAtPath<StepsDataSO>(AssetDatabase.GUIDToAssetPath(guid));
81 }
82
83 for (int i = 0; i < functionsStep.Count; i++)
84 {
85 functionsStep[i].owner = this;
86 }
87 }
88
89 public bool ValidateID(string currentStepID)
90 {
91 var stepDataPath = Path.GetDirectoryName(Path.GetDirectoryName(AssetDatabase.GetAssetPath(this)));
92
93 // Find all Texture2Ds that have 'co' in their filename, that are labelled with 'architecture' and are placed in 'MyAwesomeProps' folder
94 string[] guids = AssetDatabase.FindAssets("t:StepsDataSO", new[] {stepDataPath});
95
96 foreach (string guid in guids)
97 {
98 return !AssetDatabase.LoadAssetAtPath<StepsDataSO>(AssetDatabase.GUIDToAssetPath(guid))
99 .listOfSteps.Any(s => stepID.Equals(currentStepID));
100 }
101
102 return false;
103 }
104#endif
105 }
106}
[Serializable]
Definition StepItem.cs:12
List< StepFunction > functionsStep
Definition StepItemSO.cs:16
List< string > nextSteps
Definition StepItemSO.cs:19
List< StepItemSO > listOfSteps