예제 #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();
        }
예제 #2
0
        /// <summary>
        /// Adds a feedback of the specified type to the player
        /// </summary>
        /// <param name="feedbackType"></param>
        /// <returns></returns>
        public new MMF_Feedback AddFeedback(System.Type feedbackType)
        {
            InitializeList();
            MMF_Feedback newFeedback = (MMF_Feedback)Activator.CreateInstance(feedbackType);

            newFeedback.Label    = FeedbackPathAttribute.GetFeedbackDefaultName(feedbackType);
            newFeedback.Owner    = this;
            newFeedback.UniqueID = Guid.NewGuid().GetHashCode();
            FeedbacksList.Add(newFeedback);
            newFeedback.InitializeCustomAttributes();
            newFeedback.CacheRequiresSetup();
            return(newFeedback);
        }
예제 #3
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();
        }
예제 #5
0
        /// <summary>
        /// Add a feedback to the list
        /// </summary>
        protected virtual MMFeedback AddFeedback(System.Type type)
        {
            GameObject gameObject = (target as MMFeedbacks).gameObject;

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

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

            AddEditor(newFeedback);

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

            return(newFeedback);
        }
예제 #6
0
        /// <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();
        }
예제 #7
0
        public virtual MMFeedback AddFeedback(System.Type feedbackType)
        {
            MMFeedback newFeedback;

            #if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                newFeedback = Undo.AddComponent(this.gameObject, feedbackType) as MMFeedback;
            }
            else
            {
                newFeedback = this.gameObject.AddComponent(feedbackType) as MMFeedback;
            }
            #else
            newFeedback = this.gameObject.AddComponent(feedbackType) as MMFeedback;
            #endif

            newFeedback.hideFlags = HideFlags.HideInInspector;
            newFeedback.Label     = FeedbackPathAttribute.GetFeedbackDefaultName(feedbackType);

            AutoRepair();

            return(newFeedback);
        }
예제 #8
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;
        }
        static public string GetFeedbackDefaultPath(System.Type type)
        {
            FeedbackPathAttribute attribute = type.GetCustomAttributes(false).OfType <FeedbackPathAttribute>().FirstOrDefault();

            return(attribute != null ? attribute.Path : null);
        }