Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Tommé Nöll
seedling
Commits
8c6ee0e0
Commit
8c6ee0e0
authored
Jul 05, 2019
by
Tommé Nöll
Browse files
added notification when opening locked scenes
parent
c24564e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Assets/Editor/NotifyForLockedFiles.cs
View file @
8c6ee0e0
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
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment