예제 #1
0
        void InitFold()
        {
            fold = new Fold("Fold");

            // add funcion
            fold.Add(() => GUILayout.Label("Added function"));

            // add function with checkEnableFunc
            // Called only when checkEnableFunc returns true.
            fold.Add(
                () => isEnable,
                () => GUILayout.Label("With checkEnableFunc.")
                );

            // add title label action
            fold.SetTitleAction(() => GUILayout.Label("Title Action"));

            // set open first
            fold.Open();
        }
예제 #2
0
        protected override void Awake()
        {
            Ins = this;
            base.Awake();
            TypeOptions = typeof(Options);
            MemberInfos = TypeOptions.GetMembers(BindingFlags.Public | BindingFlags.Static);
            foreach (var item in MemberInfos)
            {
                CategoryAttribute     catyAttr = item.GetCustomAttribute(typeof(CategoryAttribute)) as CategoryAttribute;
                FoldoutGroupAttribute foldAttr = item.GetCustomAttribute(typeof(FoldoutGroupAttribute)) as FoldoutGroupAttribute;
                string typeName = "None";
                if (catyAttr != null)
                {
                    typeName = catyAttr.Category;
                }
                else if (foldAttr != null)
                {
                    typeName = foldAttr.GroupName;
                }
                if (!TypedMemberInfos.ContainsKey(typeName))
                {
                    TypedMemberInfos.Add(typeName, new List <MemberInfo>());
                    Folds.Add(typeName, new Fold(typeName));
                    ScrollVals.Add(typeName, new Vector2());
                }
                var list = TypedMemberInfos[typeName];
                list.Add(item);
            }

            foreach (var item in Folds)
            {
                item.Value.Add(() => {
                    ScrollVals[item.Key] = DoMember(TypedMemberInfos[item.Key], ScrollVals[item.Key]);
                });
            }

            FoldView.Add(() => {
                RGUI.BeginVertical();
                foreach (var item in AllIMUI)
                {
                    if (item.IsOptionView)
                    {
                        if (RGUI.Button(item.Title))
                        {
                            item.Toggle();
                        }
                    }
                }
                RGUI.EndVertical();
            });
        }