Commit 8c6ee0e0 authored by Tommé Nöll's avatar Tommé Nöll
Browse files

added notification when opening locked scenes

parent c24564e0
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEditor;
using UnityEditor.SceneManagement;
using System.IO;
[InitializeOnLoad]
public class NotifyForLockedFiles : UnityEditor.AssetModificationProcessor
{
static NotifyForLockedFiles()
{
EditorSceneManager.activeSceneChangedInEditMode += CheckActivatedScene;
if (EditorSceneManager.GetActiveScene() != null)
{
CheckActivatedScene(EditorSceneManager.GetActiveScene(), EditorSceneManager.GetActiveScene());
}
}
public static string[] OnWillSaveAssets(string[] paths)
{
public static string[] OnWillSaveAssets(string[] paths)
List<string> pathsToSave = new List<string>();
for (int i = 0; i < paths.Length; ++i)
{
List<string> pathsToSave = new List<string>();
for (int i = 0; i < paths.Length; ++i)
{
FileInfo info = new FileInfo(paths[i]);
if (info.IsReadOnly)
UnityEditor.EditorUtility.DisplayDialog("Can not save.",
"Sorry, but " + paths[i] + " is Read-Only! Please Save as another name.",
"Ok");
else
pathsToSave.Add(paths[i]);
}
return pathsToSave.ToArray();
FileInfo info = new FileInfo(paths[i]);
if (info.IsReadOnly)
UnityEditor.EditorUtility.DisplayDialog("Konnte nicht speichern",
"Die Scene " + paths[i] + " ist Read-Only. Sie konnte nicht gespeichert werden. Sie kann aber unter anderem Namen gespeichert werden.",
"Ok");
else
pathsToSave.Add(paths[i]);
}
return pathsToSave.ToArray();
}
public static void CheckActivatedScene(Scene oldScene, Scene newScene)
{
Debug.Log(newScene.path);
FileInfo info = new FileInfo(newScene.path);
if (info.IsReadOnly)
{
UnityEditor.EditorUtility.DisplayDialog("Read-Only", "Die Scene " + newScene.path + " ist Read-Only. Sie wird nicht gespeichert werden können.", "Ok");
}
}
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment