1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
|
using UnityEditor;
using UnityEngine;
using System;
using System.Collections;
using UnityEngine.Networking;
namespace AmplifyShaderEditor
{
[InitializeOnLoad]
public class InvalidDataChecker
{
private static string[] m_invalidData = { "674ea7bed6b1cd94b8057074298096db", //"/Samples",
"2738539936eacef409be91f148b2a4a0", //"/Resources",
"c880e50f07f2be9499d414ac6f9f3a7a", //"/Templates",
"563f992b9989cf547ac59bf748442c17"};//"/Textures"};
//private static string m_ASEFolderPath;
private static string m_invalidDataCollected = string.Empty;
static InvalidDataChecker()
{
bool foundInvalidData = false;
//m_ASEFolderPath = AssetDatabase.GUIDToAssetPath( IOUtils.ASEFolderGUID );
int count = 0;
for ( int i = 0; i < m_invalidData.Length; i++ )
{
//m_invalidData[ i ] = m_ASEFolderPath + m_invalidData[ i ];
m_invalidData[ i ] = AssetDatabase.GUIDToAssetPath( m_invalidData[ i ] );
if ( AssetDatabase.IsValidFolder( m_invalidData[ i ] ) )
{
foundInvalidData = true;
m_invalidDataCollected += m_invalidData[ i ]+"\n";
count += 1;
}
}
if ( count < 5 )
{
for ( ; count < 5; count++ )
{
m_invalidDataCollected += "\n";
}
}
if ( foundInvalidData )
{
InvalidDataPopUp window = ( InvalidDataPopUp ) EditorWindow.GetWindow( typeof( InvalidDataPopUp ), true, "Found Invalid Data" );
window.minSize = new Vector2( 502, 265 );
window.maxSize = new Vector2( 502, 265 );
window.Show();
}
EditorApplication.update += Update;
}
static void Update()
{
EditorApplication.update -= Update;
if( !EditorApplication.isPlayingOrWillChangePlaymode )
{
Preferences.ShowOption show = Preferences.ShowOption.Never;
if( !EditorPrefs.HasKey( Preferences.PrefStartUp ) )
{
show = Preferences.ShowOption.Always;
EditorPrefs.SetInt( Preferences.PrefStartUp, 0 );
}
else
{
if( Time.realtimeSinceStartup < 10 )
{
show = (Preferences.ShowOption) EditorPrefs.GetInt( Preferences.PrefStartUp, 0 );
// check version here
if( show == Preferences.ShowOption.OnNewVersion )
{
ASEStartScreen.StartBackgroundTask( StartRequest( ASEStartScreen.ChangelogURL, () =>
{
var changeLog = ChangeLogInfo.CreateFromJSON( www.downloadHandler.text );
if( changeLog != null )
{
if( changeLog.Version > VersionInfo.FullNumber )
ASEStartScreen.Init();
}
} ) );
}
}
}
if( show == Preferences.ShowOption.Always )
ASEStartScreen.Init();
}
}
static UnityWebRequest www;
static IEnumerator StartRequest( string url, Action success = null )
{
using( www = UnityWebRequest.Get( url ) )
{
#if UNITY_2017_2_OR_NEWER
yield return www.SendWebRequest();
#else
yield return www.Send();
#endif
while( www.isDone == false )
yield return null;
if( success != null )
success();
}
}
public static void CleanInvalidData()
{
for ( int i = 0; i < m_invalidData.Length; i++ )
{
if ( FileUtil.DeleteFileOrDirectory( m_invalidData[ i ] ) )
{
Debug.Log( "Removed invalid " + m_invalidData[ i ] );
if ( FileUtil.DeleteFileOrDirectory( m_invalidData[ i ] + ".meta" ) )
{
Debug.Log( "Removed invalid " + m_invalidData[ i ] + ".meta" );
}
}
}
AssetDatabase.Refresh();
}
public static string InvalidDataCollected { get { return m_invalidDataCollected; } }
}
public class InvalidDataPopUp : EditorWindow
{
private readonly GUIContent m_buttonContent = new GUIContent( "Remove Invalid Data" );
private Vector2 m_scrollPosition = Vector2.zero;
public void OnGUI()
{
GUILayout.BeginVertical();
{
GUIStyle labelStyle = new GUIStyle( EditorStyles.label );
labelStyle.alignment = TextAnchor.MiddleCenter;
labelStyle.wordWrap = true;
GUILayout.Label( "\nAmplify Shader Editor " + VersionInfo.StaticToString(), labelStyle, GUILayout.ExpandWidth( true ) );
GUILayout.Space( 5 );
GUILayout.Label( "Invalid/Legacy Data was found on your previous ASE folder which needs to be removed in order for it to work correctly." , labelStyle, GUILayout.ExpandWidth( true ) );
GUILayout.Space( 5 );
GUILayout.Label( "Below are the detected files/folders which require to be removed.", labelStyle, GUILayout.ExpandWidth( true ) );
GUILayout.Space( 5 );
m_scrollPosition = GUILayout.BeginScrollView( m_scrollPosition ,GUILayout.Height(85));
GUILayout.TextArea( InvalidDataChecker.InvalidDataCollected );
GUILayout.EndScrollView();
GUILayout.Label( "VERY IMPORTANT: If you have assets of yours inside these folders you need to move them to another location before hitting the button below or they will be PERMANENTLY DELETED", labelStyle, GUILayout.ExpandWidth( true ) );
GUILayout.Space( 5 );
GUILayout.BeginHorizontal();
{
GUILayout.Space( 151 );
if ( GUILayout.Button( m_buttonContent, GUILayout.Width( 200 ) ) )
{
InvalidDataChecker.CleanInvalidData();
Close();
}
}
GUILayout.EndHorizontal();
}
GUILayout.EndVertical();
}
}
}
|