コード例 #1
0
        public static List <ToolBagBaseData> GetToolBagDatas()
        {
            List <ToolBagBaseData> toolBagBaseDatas = new List <ToolBagBaseData>();

            var types = Assembly
                        .GetExecutingAssembly()
                        .GetTypes().Where(item => item.IsSubclassOf(typeof(ToolBagBaseData))).ToList();

            Debug.Log($"Tools Count : {types.Count}");

            types.ForEach(x =>
            {
                toolBagBaseDatas.Add(Activator.CreateInstance(x) as ToolBagBaseData);
            });

            toolBagBaseDatas.Sort((a, b) => a.SortIndex.CompareTo(b.SortIndex));

            LoadToolDataStatus().ForEach(x =>
            {
                ToolBagBaseData saveData = toolBagBaseDatas.Find(y => y.Name == x.name);
                if (saveData != null)
                {
                    saveData.IsShow = x.isShow;
                }
            });

            return(toolBagBaseDatas);
        }
コード例 #2
0
        private void OnGUI()
        {
            if (instance == null)
            {
                instance = this;
            }

            if (toolBagDataList == null)
            {
                LoadData();
            }

            GUILayout.BeginVertical();

            GUILayout.Space(2);

            if (selectData == null)
            {
                toolBagDataList.ForEach(x =>
                {
                    if (GUILayout.Button(x.Name))
                    {
                        selectData = x;
                    }

                    GUILayout.Space(2);
                });
            }
            else
            {
                if (GUILayout.Button("返回"))
                {
                    selectData = null;
                }

                GUILayout.Space(5);

                if (selectData != null)
                {
                    GUILayout.TextArea(selectData.Name, new GUIStyle("DefaultCenteredText")
                    {
                        fontStyle = FontStyle.Bold
                    });

                    GUILayout.Space(2);

                    selectData?.ShowWindow();
                }
            }

            GUILayout.EndVertical();
        }