コード例 #1
0
        protected Selection RenderEnumSelection(Rect rect, int selected)
        {
            var originalEnumNames = m_EnumInfoHelper.GetAllNames();

            selected = Mathf.Clamp(selected, 0, originalEnumNames.Count() - 1);
            originalEnumNames.Add("► Add enum...");
            originalEnumNames.Add("► Update or delete enum...");
            string[] enumNames           = originalEnumNames.ToArray();
            int      addIndex            = enumNames.Count() - 2;
            int      deleteOrUpdateIndex = enumNames.Count() - 1;
            int      newSelected         = EditorGUI.Popup(rect, selected, enumNames);

            if (newSelected == addIndex)
            {
                NewEnumWindow.ShowNewEnumWindow(m_ProtoFile, m_EnumInfoHelper);
                return(new Selection(selected, enumNames[selected]));
            }

            if (newSelected == deleteOrUpdateIndex)
            {
                DeleteEnumWindow.ShowWindow(m_ProtoFile, m_Descriptor.File, m_EnumInfoHelper);
                return(new Selection(selected, enumNames[selected]));
            }

            return(new Selection(newSelected, enumNames[newSelected]));
        }
コード例 #2
0
        public static void ShowNewEnumWindow(FileInfo protoFile, EnumInfoHelper enumInfoHelper)
        {
            var displayInfo = new EnumInfo()
            {
                name   = "NewEnum" + enumInfoHelper.GetAllNames().Count(),
                values = new List <string>()
                {
                    "VALUE_0", "VALUE_1", "VALUE_2"
                }
            };

            ShowWindow(protoFile, enumInfoHelper, displayInfo);
        }
コード例 #3
0
        public static void ShowWindow(FileInfo protoFile, EnumInfoHelper enumInfoHelper)
        {
            var window = ScriptableObject.CreateInstance <NewEnumWindow>();

            window.titleContent     = new GUIContent("New enum");
            window.position         = new Rect(Screen.width / 2f, Screen.height / 2f, 300, 500);
            window.m_ProtoFile      = protoFile;
            window.m_EnumInfoHelper = enumInfoHelper;
            window.m_Info           = new EnumInfo()
            {
                name   = "NewEnum" + enumInfoHelper.GetAllNames().Count(),
                values = new List <string>()
                {
                    "VALUE_0", "VALUE_1", "VALUE_2"
                }
            };
            window.ShowUtility();
        }
コード例 #4
0
        bool EnumExist(EnumInfo info)
        {
            var existingEnumNames = m_EnumInfoHelper.GetAllNames();

            return(existingEnumNames.Contains(info.name));
        }