/// <summary>
        /// On Enable, grabs properties and initializes the add feedback dropdown's contents
        /// </summary>
        void OnEnable()
        {
            // Get properties
            _mmfeedbacks = serializedObject.FindProperty("Feedbacks");
            _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 <MMFeedback, Editor>();
            for (int i = 0; i < _mmfeedbacks.arraySize; i++)
            {
                AddEditor(_mmfeedbacks.GetArrayElementAtIndex(i).objectReferenceValue as MMFeedback);
            }

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

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

            for (int i = 0; i < types.Count; i++)
            {
                FeedbackTypePair newType = new FeedbackTypePair();
                newType.FeedbackType = types[i];
                newType.FeedbackName = FeedbackPathAttribute.GetFeedbackDefaultPath(types[i]);
                if (newType.FeedbackName == "MMFeedbackBase")
                {
                    continue;
                }
                _typesAndNames.Add(newType);
            }

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

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

            _typeDisplays = typeNames.ToArray();
        }
        /// <summary>
        /// Lists all feedbacks, builds the dropdown list, and stores it in a static
        protected virtual void PrepareFeedbackTypeList()
        {
            if ((_typeDisplays != null) && (_typeDisplays.Length > 0))
            {
                return;
            }

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

            // Create display list from types
            _typeNames.Clear();
            for (int i = 0; i < types.Count; i++)
            {
                FeedbackTypePair _newType = new FeedbackTypePair();
                _newType.FeedbackType = types[i];
                _newType.FeedbackName = FeedbackPathAttribute.GetFeedbackDefaultPath(types[i]);
                if ((_newType.FeedbackName == "MMF_FeedbackBase") || (_newType.FeedbackName == null))
                {
                    continue;
                }
                _typesAndNames.Add(_newType);
            }

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

            _typeNames.Add("Add new feedback...");
            for (int i = 0; i < _typesAndNames.Count; i++)
            {
                _typeNames.Add(_typesAndNames[i].FeedbackName);
            }

            _typeDisplays = _typeNames.ToArray();
        }
Beispiel #3
0
        /// <summary>
        /// On Enable, grabs properties and initializes the add feedback dropdown's contents
        /// </summary>
        void OnEnable()
        {
            // Get properties
            _targetMMFeedbacks                     = target as MMFeedbacks;
            _mmfeedbacks                           = serializedObject.FindProperty("Feedbacks");
            _mmfeedbacksInitializationMode         = serializedObject.FindProperty("InitializationMode");
            _mmfeedbacksSafeMode                   = serializedObject.FindProperty("SafeMode");
            _mmfeedbacksAutoPlayOnStart            = serializedObject.FindProperty("AutoPlayOnStart");
            _mmfeedbacksAutoPlayOnEnable           = serializedObject.FindProperty("AutoPlayOnEnable");
            _mmfeedbacksDirection                  = serializedObject.FindProperty("Direction");
            _mmfeedbacksAutoChangeDirectionOnEnd   = serializedObject.FindProperty("AutoChangeDirectionOnEnd");
            _mmfeedbacksDurationMultiplier         = serializedObject.FindProperty("DurationMultiplier");
            _mmfeedbacksDisplayFullDurationDetails = serializedObject.FindProperty("DisplayFullDurationDetails");
            _mmfeedbacksCooldownDuration           = serializedObject.FindProperty("CooldownDuration");
            _mmfeedbacksInitialDelay               = serializedObject.FindProperty("InitialDelay");
            _mmfeedbacksFeedbacksIntensity         = serializedObject.FindProperty("FeedbacksIntensity");

            _mmfeedbacksEvents = serializedObject.FindProperty("Events");

            // store GUI bg color
            _originalBackgroundColor = GUI.backgroundColor;

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

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

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

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

            for (int i = 0; i < types.Count; i++)
            {
                FeedbackTypePair newType = new FeedbackTypePair();
                newType.FeedbackType = types[i];
                newType.FeedbackName = FeedbackPathAttribute.GetFeedbackDefaultPath(types[i]);
                if (newType.FeedbackName == "MMFeedbackBase")
                {
                    continue;
                }
                _typesAndNames.Add(newType);
            }

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

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

            _typeDisplays = typeNames.ToArray();

            _directionButtonStyle               = new GUIStyle();
            _directionButtonStyle.border.left   = 0;
            _directionButtonStyle.border.right  = 0;
            _directionButtonStyle.border.top    = 0;
            _directionButtonStyle.border.bottom = 0;
        }