//----------------------------------------------------------------------------------------------------------------------
        void ShowReloadSelectedSceneCacheFilesGUI()
        {
            float itemHeight = EditorGUIUtility.singleLineHeight;

            //Button
            EditorGUILayout.BeginHorizontal(GUILayout.Height(itemHeight));
            if (GUILayout.Button("Reload Selected Scene Cache Files", GUILayout.Width(250f), GUILayout.Height(itemHeight)))
            {
                foreach (SceneCachePlayer player in m_targets)
                {
                    string sceneCacheFilePath = player.GetSceneCacheFilePath();
                    SceneCachePlayerEditorUtility.ChangeSceneCacheFile(player, sceneCacheFilePath);
                }
            }
            EditorGUILayout.EndHorizontal();

            //[TODO-sin: 2020-9-28] use ScrollView
            foreach (SceneCachePlayer player in m_targets)
            {
                EditorGUILayout.BeginHorizontal(GUILayout.Height(itemHeight));
                GUILayout.Space(30);
                if (player.gameObject.IsPrefab())
                {
                    GameObject prefab     = PrefabUtility.GetCorrespondingObjectFromOriginalSource(player.gameObject);
                    string     prefabPath = AssetDatabase.GetAssetPath(prefab);
                    EditorGUILayout.LabelField(prefabPath);
                }
                else
                {
                    EditorGUILayout.LabelField(player.name);
                }
                EditorGUILayout.EndHorizontal();
            }
        }
//----------------------------------------------------------------------------------------------------------------------
        void OnSceneCacheFileReload()
        {
            string sceneCacheFilePath = m_sceneCachePlayer.GetSceneCacheFilePath();

            SceneCachePlayerEditorUtility.ChangeSceneCacheFile(m_sceneCachePlayer, sceneCacheFilePath);
            GUIUtility.ExitGUI();
        }
Ejemplo n.º 3
0
//----------------------------------------------------------------------------------------------------------------------

        public override void OnImportAsset(AssetImportContext ctx)
        {
            //Ignore assets outside Assets folder (for example: Packages, etc)
            if (!ctx.assetPath.StartsWith("Assets/"))
            {
                return;
            }

            GameObject       go     = new GameObject();
            SceneCachePlayer player = go.AddComponent <SceneCachePlayer>();

            SceneCachePlayerEditorUtility.ChangeSceneCacheFile(player, ctx.assetPath);

            string objectName = Path.GetFileNameWithoutExtension(ctx.assetPath);

            go.name = objectName;

            ctx.AddObjectToAsset(objectName, go);
            ctx.SetMainObject(go);
        }
//----------------------------------------------------------------------------------------------------------------------
        private static void ChangeSceneCacheFileInInspector(SceneCachePlayer cachePlayer, string sceneCacheFilePath)
        {
            SceneCachePlayerEditorUtility.ChangeSceneCacheFile(cachePlayer, sceneCacheFilePath);
        }