コード例 #1
0
        private void OnEnable()
        {
            Cacher = ScriptableObjectExtension.ReadAsset <BGMListCacher>(CachePath);
            if (!Cacher)
            {
                ScriptableObjectExtension.WriteAsset(Cacher, CachePath);
            }


            so          = new SerializedObject(Cacher);
            BGMListView = new ReorderableList(so, so.FindProperty("BGM"));


            Instance = this;


            BGMListView.drawElementCallback =
                (Rect rect, int index, bool isActive, bool isFocused) =>
            {
                var element = BGMListView.serializedProperty.GetArrayElementAtIndex(index);
                rect.y += 2;

                EditorGUI.PropertyField(
                    new Rect(rect.x, rect.y, position.width / 2f, EditorGUIUtility.singleLineHeight),
                    element.FindPropertyRelative("Audio"), GUIContent.none);
                EditorGUI.PropertyField(
                    new Rect(rect.x + position.width / 2f, rect.y, position.width / 3f, EditorGUIUtility.singleLineHeight),
                    element.FindPropertyRelative("Tag"), GUIContent.none);
            };

            BGMListView.onChangedCallback = (list) =>
            {
            };
        }
コード例 #2
0
        void OnGUI()
        {
            if (Application.isPlaying)
            {
                GUILayout.Label("Please exit Play Mode then reopen this window.", GUILayout.Width(position.width));
                return;
            }


            if (gmp != null)
            {
                scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Width(position.width), GUILayout.Height(position.height - 2 * EditorGUIUtility.singleLineHeight));

                GUILayout.Label("Cached Prefabs:" + gmp.GetAllPrefab().Count, GUILayout.Width(EditorGUIUtility.labelWidth));

                foreach (PrefabCacher.PrefabCache pc in gmp.GetAllPrefab())
                {
                    EditorGUILayout.BeginHorizontal();
                    GUILayout.Label(pc.gameObject.name, GUILayout.Width(EditorGUIUtility.labelWidth));
                    GUILayout.Label(pc.path, GUILayout.Width(position.width * 0.97f - EditorGUIUtility.labelWidth));
                    EditorGUILayout.EndHorizontal();
                }

                EditorGUILayout.EndScrollView();
            }



            if (GUILayout.Button("UPDATE CACHE"))
            {
                gmp = new PrefabCacher();
                ScriptableObjectExtension.DeleteAsset(AssetSave);

                gmp.UpdateCache(LoadAllPrefab());
                ScriptableObjectExtension.WriteAsset(gmp, AssetSave);
            }
        }