示例#1
0
 public virtual void InspectorGUIButton(string ButtonText, GenericButtonCallback ButtonFunction)
 {
     if (GUILayout.Button(ButtonText))
     {
         ButtonFunction();
     }
 }
示例#2
0
        public virtual void     InspectorGUIDropDown(string DropDownLabel, ref List <string> Values, ref string CurrentValue, bool bAppendAddNewEntryOption = false, string AddNewEntryOptionText = "", GenericButtonCallback OnAddNewEntry = null)
        {
            List <string> AllValues             = Values;
            bool          bHasAddNewEntryOption = false;

            if (bAppendAddNewEntryOption && AddNewEntryOptionText != "" && OnAddNewEntry != null)
            {
                AllValues = new List <string>();
                AllValues.AddRange(Values);
                AllValues.Add(AddNewEntryOptionText);

                bHasAddNewEntryOption = true;
            }

            int CurrentIndex = Values.IndexOf(CurrentValue);

            if (CurrentIndex == -1)
            {
                CurrentIndex = 0;
            }

            int OldIndex = CurrentIndex;

            CurrentIndex = EditorGUILayout.Popup(DropDownLabel, CurrentIndex, AllValues.ToArray());

            if (bHasAddNewEntryOption && CurrentIndex == (AllValues.Count - 1))
            {
                OnAddNewEntry();
            }
            else
            {
                CurrentValue = Values[CurrentIndex];
            }

            if (CurrentIndex != OldIndex)
            {
                bInspectorHasChangedProperty = true;
            }
        }