Пример #1
0
 public static void EnsureSequenceIsRemembered(string key, HapticSequence sequence)
 {
     key = HapticResources.CleanName(key);
     if (!LoadedSequences.ContainsKey(key) && sequence != null)
     {
         LoadedSequences.Add(key, new SequenceImportData(sequence, key));
     }
 }
Пример #2
0
 public static bool SequenceExists(string key)
 {
     if (LoadedSequences.ContainsKey(key) && LoadedSequences[key].Sequence != null)
     {
         return(true);
     }
     LoadedSequences.Remove(key);
     return(false);
 }
Пример #3
0
        /// <summary>
        /// Create a HapticSequence from a HapticDefinitionFile
        /// </summary>
        /// <param name="key">Name of the root effect</param>
        /// <param name="hdf">A HapticDefinitionFile containing the root effect</param>
        /// <returns></returns>
        public static HapticSequence CreateSequenceFromHDF(string key, HapticDefinitionFile hdf)
        {
            string cleanedKey = HapticResources.CleanName(key);

            if (LoadedSequences.ContainsKey(cleanedKey))
            {
                //Debug.Log("Sequence: " + cleanedKey + " already exists, returning it instead of needless reconstruction\n");
                return(LoadedSequences[cleanedKey].Sequence);
            }
            //Debug.Log("Sequence: " + cleanedKey + " DOES NOT exist, creating a new one\n");

            HapticSequence seq = ScriptableObject.CreateInstance <HapticSequence>();
            var            sequence_def_array = hdf.sequence_definitions[key];

            foreach (var effect in sequence_def_array)
            {
                seq.AddEffect(new HapticEffect(effect.ParseEffect(), effect.time, effect.duration, effect.strength));
            }
            EnsureSequenceIsRemembered(cleanedKey, seq);
            return(seq);
        }