Example #1
0
        void OnEnable()
        {
            // Get properties
            _mmfeedbacks = serializedObject.FindProperty("Sequences");

            _mmfeedbacksInitializationMode = serializedObject.FindProperty("InitializationMode");
            _mmfeedbacksSafeMode           = serializedObject.FindProperty("SafeMode");
            _mmfeedbacksAutoPlayOnStart    = serializedObject.FindProperty("AutoPlayOnStart");

            // Repair routine to catch feedbacks that may have escaped due to Unity's serialization issues
            RepairRoutine();

            // Create editors
            _editors = new Dictionary <SequenceBase, Editor>();
            for (int i = 0; i < _mmfeedbacks.arraySize; i++)
            {
                AddEditor(_mmfeedbacks.GetArrayElementAtIndex(i).objectReferenceValue as SequenceBase);
            }

            // Retrieve available feedbacks
            List <System.Type> types = (from domainAssembly in System.AppDomain.CurrentDomain.GetAssemblies()
                                        from assemblyType in domainAssembly.GetTypes()
                                        where assemblyType.IsSubclassOf(typeof(SequenceBase))
                                        select assemblyType).ToList();

            // Create display list from types
            List <string> typeNames = new List <string>();

            for (int i = 0; i < types.Count; i++)
            {
                SequenceTypePair newType = new SequenceTypePair();
                newType.SequenceType = types[i];
                newType.SequenceName = SequencePathAttribute.GetFeedbackDefaultPath(types[i]);
                if (newType.SequenceName == "SequenceBase")
                {
                    continue;
                }
                _typesAndNames.Add(newType);
            }

            _typesAndNames = _typesAndNames.OrderBy(t => t.SequenceName).ToList();

            typeNames.Add("Add new Sequence...");
            for (int i = 0; i < _typesAndNames.Count; i++)
            {
                typeNames.Add(_typesAndNames[i].SequenceName);
            }

            _typeDisplays = typeNames.ToArray();
        }
Example #2
0
        protected virtual SequenceBase AddSequence(System.Type type)
        {
            GameObject gameObject = (target as SequencePlayer).gameObject;

            SequenceBase newFeedback = Undo.AddComponent(gameObject, type) as SequenceBase;

            newFeedback.hideFlags = _debugView ? HideFlags.None : HideFlags.HideInInspector;
            newFeedback.Label     = SequencePathAttribute.GetFeedbackDefaultName(type);

            AddEditor(newFeedback);

            _mmfeedbacks.arraySize++;
            _mmfeedbacks.GetArrayElementAtIndex(_mmfeedbacks.arraySize - 1).objectReferenceValue = newFeedback;

            return(newFeedback);
        }