Beispiel #1
0
    public static System.Enum EnumPopup(Rect rect, string label, System.Enum enumerator, string[] minus)
    {
        System.Array  optionsEnums        = System.Enum.GetValues(enumerator.GetType());
        string[]      options             = System.Enum.GetNames(enumerator.GetType());
        string        selectedName        = System.Enum.GetName(enumerator.GetType(), enumerator);
        List <string> OriginalListOptions = ArrayUtility.ArrayToList(options);
        List <string> FilteredListOptions = ArrayUtility.ArrayToList(options);

        for (int i = 0; i < minus.Length; i++)
        {
            if (FilteredListOptions.Contains(minus[i]))
            {
                FilteredListOptions.Remove(minus[i]);
            }
        }
        int selectedIndex = FilteredListOptions.IndexOf(selectedName);

        selectedIndex = EditorGUI.Popup(rect, label, selectedIndex, FilteredListOptions.ToArray());
        if (selectedIndex < 0)
        {
            selectedIndex = 0;
        }
        selectedName = FilteredListOptions[selectedIndex];
        int nonfilteredSelectedIndex = OriginalListOptions.IndexOf(selectedName);

        return((System.Enum)(optionsEnums.GetValue(nonfilteredSelectedIndex)));
    }
Beispiel #2
0
 //1#2#3# to list of string includes 1,2,3
 public static List <string> StringToListofString(string input, string pattern)
 {
     try
     {
         string[] stringArray = Regex.Split(input, pattern);
         return(ArrayUtility.ArrayToList <string>(stringArray));
     }
     catch (Exception e)
     {
         ExceptionHandling.ExceptionHandler(e);
         return(null);
     }
 }
    public void CleanUpUnusedVariables()
    {
        for (int i = 0; i < xBoolList.Length; i++)
        {
            object   analyzedObj = xBoolList[i].script;
            string[] allfields   = xBoolList[i].variablePath.Split('.');

            for (int ib = 0; ib < allfields.Length; ib++)
            {
                var field = analyzedObj.GetType().GetField(allfields[ib]);
                if (field != null)
                {
                    if (ib == allfields.Length - 1)
                    {
                        //Significa que o campo ainda existe, portanto esta variavel prevalecerá
                        break;
                    }
                    var obj = field.GetValue(analyzedObj); //obtem objeto pra procurar o proximo campo.
                    if (obj != null)
                    {
                        analyzedObj = obj; //Encontrou o objeto para fazer a próxima analise
                    }
                    else
                    {
                        //O objeto especificado nao foi encontrado
                    }
                }
                else
                {
                    //Não encontrou este campo no objeto analizado, significa que este campo deve ser
                    // removido da lista de xBools/xInt/xFloat
                    var _xBoolList = ArrayUtility.ArrayToList(xBoolList);
                    _xBoolList.RemoveAt(i);
                    xBoolList = _xBoolList.ToArray();
                    i--;
                    break;
                }
            }
        }
    }