Exemple #1
0
        /// <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");

            // 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
            _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>();

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

            _typeDisplays = typeNames.ToArray();
        }
Exemple #2
0
        public static void OutputIFeedbacksList()
        {
            // 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();

            List <string> typeNames = new List <string>();


            string previousType = "";

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

                string newEntry = FeedbackPathAttribute.GetFeedbackDefaultPath(newType.FeedbackType);
                typeNames.Add(newEntry);
            }

            typeNames.Sort();
            StringBuilder builder = new StringBuilder();
            int           counter = 1;

            foreach (string typeName in typeNames)
            {
                string[] splitArray = typeName.Split(char.Parse("/"));

                if ((previousType != splitArray[0]) && (counter > 1))
                {
                    builder.Append("\n");
                }

                builder.Append("- [ ] ");
                builder.Append(counter.ToString("000"));
                builder.Append(" - ");
                builder.Append(typeName);
                builder.Append("\n");

                previousType = splitArray[0];
                counter++;
            }
            Debug.Log(builder.ToString());
        }
        /// <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();
        }
Exemple #5
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;
        }