├── .gitignore ├── Assets ├── Editor.meta ├── Editor │ ├── AnimationClipCompressor.cs │ ├── AnimationClipCompressor.cs.meta │ ├── Common.meta │ ├── Common │ │ ├── Debug.cs │ │ ├── Debug.cs.meta │ │ ├── EditorUtils.cs │ │ ├── EditorUtils.cs.meta │ │ ├── FileUtils.cs │ │ ├── FileUtils.cs.meta │ │ ├── JSON.meta │ │ ├── JSON │ │ │ ├── JSONObject.cs │ │ │ ├── JSONObject.cs.meta │ │ │ ├── JSONTemplates.cs │ │ │ ├── JSONTemplates.cs.meta │ │ │ ├── SimpleJSON.cs │ │ │ ├── SimpleJSON.cs.meta │ │ │ ├── VectorTemplates.cs │ │ │ └── VectorTemplates.cs.meta │ │ ├── StringUtils.cs │ │ ├── StringUtils.cs.meta │ │ ├── UnityLogFile.cs │ │ ├── UnityLogFile.cs.meta │ │ ├── Utils.cs │ │ └── Utils.cs.meta │ ├── LightmapViewer.cs │ ├── LightmapViewer.cs.meta │ ├── MaterialCleaner.cs │ ├── MaterialCleaner.cs.meta │ ├── MatrixViewer.cs │ ├── MatrixViewer.cs.meta │ ├── MenuShortcutsWindow.cs │ ├── MonoScriptDumper.meta │ ├── MonoScriptDumper │ │ ├── MonoScriptDumper.cs │ │ ├── MonoScriptDumper.cs.meta │ │ ├── MonoScriptSerializeFieldView.cs │ │ └── MonoScriptSerializeFieldView.cs.meta │ ├── UVSheetViewer.cs │ └── UVSheetViewer.cs.meta ├── Resources.meta ├── Resources │ ├── Prefab.meta │ └── Prefab │ │ ├── role.meta │ │ └── role │ │ ├── player_1.meta │ │ └── player_1 │ │ ├── player_1_1_1.prefab │ │ └── player_1_1_1.prefab.meta ├── _Raw.meta ├── _Raw │ ├── role.meta │ └── role │ │ ├── animation.meta │ │ ├── animation │ │ ├── player.meta │ │ └── player │ │ │ ├── female.meta │ │ │ └── female │ │ │ ├── battlelost.anim │ │ │ ├── battlelost.anim.meta │ │ │ ├── jump_1.anim │ │ │ ├── jump_1.anim.meta │ │ │ ├── jump_2.anim │ │ │ ├── jump_2.anim.meta │ │ │ ├── jump_3.anim │ │ │ ├── jump_3.anim.meta │ │ │ ├── spawn.anim │ │ │ └── spawn.anim.meta │ │ ├── player_1.meta │ │ └── player_1 │ │ ├── MergedMeshes.meta │ │ ├── MergedMeshes │ │ ├── player_1_1_1_part1.asset │ │ └── player_1_1_1_part1.asset.meta │ │ ├── SimplifiedMeshes.meta │ │ ├── idle.anim │ │ ├── idle.anim.meta │ │ ├── player_1_1.FBX │ │ ├── player_1_1.FBX.meta │ │ ├── player_1_1.mat │ │ ├── player_1_1.mat.meta │ │ ├── player_1_1.png │ │ └── player_1_1.png.meta ├── __backup_animations__.meta ├── __backup_animations__ │ ├── _Raw.meta │ └── _Raw │ │ ├── role.meta │ │ └── role │ │ ├── player_1.meta │ │ └── player_1 │ │ ├── battlewin.anim │ │ └── battlewin.anim.meta ├── __export_record__.meta ├── __export_record__ │ ├── AnimationCompressRecord.json │ └── AnimationCompressRecord.json.meta ├── gmcs.rsp ├── gmcs.rsp.meta ├── test.meta ├── test.unity ├── test.unity.meta └── test │ ├── LightingData.asset │ ├── LightingData.asset.meta │ ├── Lightmap-0_comp_dir.png │ ├── Lightmap-0_comp_dir.png.meta │ ├── Lightmap-0_comp_light.exr │ └── Lightmap-0_comp_light.exr.meta ├── ProjectSettings ├── AudioManager.asset ├── ClusterInputManager.asset ├── DynamicsManager.asset ├── EditorBuildSettings.asset ├── EditorSettings.asset ├── GraphicsSettings.asset ├── InputManager.asset ├── NavMeshAreas.asset ├── NavMeshLayers.asset ├── NetworkManager.asset ├── Physics2DSettings.asset ├── ProjectSettings.asset ├── ProjectVersion.txt ├── QualitySettings.asset ├── TagManager.asset ├── TimeManager.asset └── UnityConnectSettings.asset ├── README.md ├── ScreenShot ├── animationclip-compressor.png ├── lightmap-viewer.png ├── matrix-viewer-memory.png ├── matrix-viewer.png ├── mono-script-viewer.png └── uvsheet_viewer.png ├── UnityToolDist.CSharp.Editor.csproj ├── UnityToolDist.CSharp.csproj ├── UnityVS.UnityToolDist.CSharp.Editor.csproj └── UnityVS.UnityToolDist.sln /.gitignore: -------------------------------------------------------------------------------- 1 | Library 2 | Temp 3 | *.sln 4 | UnityToolDist.v11.suo -------------------------------------------------------------------------------- /Assets/Editor.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 81d90dbebd70f2947b62995a37b1edef 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Editor/AnimationClipCompressor.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 02403ccd75f27d64386ad08e31b73cbc 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/Common.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d4f8818202d09b3468e2367f1e60b4d0 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Editor/Common/Debug.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.IO; 3 | using System.Diagnostics; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading; 8 | 9 | namespace Common { 10 | 11 | public static class UDebug { 12 | 13 | delegate void LogDelegate( String msg ); 14 | delegate void LogExceptionDelegate( Exception e ); 15 | static LogDelegate _Log = NoAction; 16 | static LogDelegate _LogError = NoAction; 17 | static LogDelegate _LogWarning = NoAction; 18 | static LogExceptionDelegate _LogException = NoActionException; 19 | static int _LogCount = 0; 20 | static int _ErrorCount = 0; 21 | static int _WarningCount = 0; 22 | static int _ExceptionCount = 0; 23 | static int _AssertFailCount = 0; 24 | static bool _enabled = true; 25 | 26 | public static bool showCallStackEnabled = true; 27 | public static bool enabled { 28 | get { 29 | return _enabled; 30 | } 31 | set { 32 | if ( _enabled != value ) { 33 | _enabled = value; 34 | if ( _enabled ) { 35 | _Log = UnityEngine.Debug.Log; 36 | _LogError = UnityEngine.Debug.LogError; 37 | _LogException = UnityEngine.Debug.LogException; 38 | _LogWarning = UnityEngine.Debug.LogWarning; 39 | } else { 40 | _Log = NoAction; 41 | _LogError = NoAction; 42 | _LogWarning = NoAction; 43 | _LogException = NoActionException; 44 | } 45 | } 46 | } 47 | } 48 | 49 | public static int errorCount { 50 | get { 51 | return _ErrorCount; 52 | } 53 | } 54 | 55 | public static int warningCount { 56 | get { 57 | return _WarningCount; 58 | } 59 | } 60 | 61 | public static int assertFailCount { 62 | get { 63 | return _AssertFailCount; 64 | } 65 | } 66 | 67 | public static int exceptionCount { 68 | get { 69 | return _ExceptionCount; 70 | } 71 | } 72 | 73 | public static bool hasWarning { 74 | get { 75 | return ( _ExceptionCount + _ErrorCount + _AssertFailCount + _WarningCount ) > 0; 76 | } 77 | } 78 | 79 | public static bool hasError { 80 | get { 81 | return ( _ExceptionCount + _ErrorCount + _AssertFailCount ) > 0; 82 | } 83 | } 84 | 85 | public static void ClearLogCounter() { 86 | Interlocked.Exchange( ref _LogCount, 0 ); 87 | Interlocked.Exchange( ref _ErrorCount, 0 ); 88 | Interlocked.Exchange( ref _WarningCount, 0 ); 89 | Interlocked.Exchange( ref _ExceptionCount, 0 ); 90 | Interlocked.Exchange( ref _AssertFailCount, 0 ); 91 | } 92 | 93 | public delegate bool AssertTest(); 94 | 95 | public static void MessageBox( String s ) { 96 | #if UNITY_EDITOR && UNITY_EDITOR_WIN 97 | if ( showCallStackEnabled ) { 98 | using ( var prcShell = new System.Diagnostics.Process() ) { 99 | prcShell.StartInfo.FileName = UnityEngine.Application.dataPath + "/../../Tool/Bin/MsgBoxer.exe"; 100 | Common.UDebug.Log( prcShell.StartInfo.FileName ); 101 | prcShell.StartInfo.Arguments = "\"" + s + "\""; 102 | prcShell.Start(); 103 | } 104 | } 105 | #endif 106 | } 107 | 108 | public static void ShowCallStack() { 109 | MessageBox( GetCallStack( 2 ) ); 110 | } 111 | 112 | public static String GetCallStack( int skipFrame = 1 ) { 113 | StackTrace stackTrace = new StackTrace( skipFrame, true ); // get call stack 114 | StackFrame[] stackFrames = stackTrace.GetFrames(); // get method calls (frames) 115 | // write call stack method names 116 | var sb = new StringBuilder( 200 ); 117 | for ( int i = 0; i < stackFrames.Length; ++i ) { 118 | var frame = stackFrames[i]; 119 | sb.Append( frame.GetMethod() ); 120 | sb.Append( "(at " ); 121 | sb.Append( frame.GetFileName() ); 122 | sb.Append( ": " ); 123 | sb.Append( frame.GetFileLineNumber() ); 124 | sb.Append( ")\n" ); 125 | } 126 | return sb.ToString(); 127 | } 128 | 129 | public static int GetCallStackSize() { 130 | StackTrace stackTrace = new StackTrace( 1, false ); // get call stack 131 | return stackTrace.FrameCount; 132 | } 133 | 134 | public static String SafeFormat( String format, T arg ) { 135 | if ( format != null ) { 136 | try { 137 | return String.Format( format, arg ); 138 | } catch ( Exception e ) { 139 | Common.UDebug.LogException( e ); 140 | } 141 | } 142 | return String.Empty; 143 | } 144 | 145 | public static String SafeFormat( String format, T1 arg1, T2 arg2 ) { 146 | if ( format != null ) { 147 | try { 148 | return String.Format( format, arg1, arg2 ); 149 | } catch ( Exception e ) { 150 | Common.UDebug.LogException( e ); 151 | } 152 | } 153 | return String.Empty; 154 | } 155 | 156 | public static String SafeFormat( String format, T1 arg1, T2 arg2, T3 arg3 ) { 157 | if ( format != null ) { 158 | try { 159 | return String.Format( format, arg1, arg2, arg3 ); 160 | } catch ( Exception e ) { 161 | Common.UDebug.LogException( e ); 162 | } 163 | } 164 | return String.Empty; 165 | } 166 | 167 | public static String SafeFormat( String format, T1 arg1, T2 arg2, T3 arg3, T4 arg4 ) { 168 | if ( format != null ) { 169 | try { 170 | return String.Format( format, arg1, arg2, arg3, arg4 ); 171 | } catch ( Exception e ) { 172 | Common.UDebug.LogException( e ); 173 | } 174 | } 175 | return String.Empty; 176 | } 177 | 178 | public static String SafeFormat( String format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5 ) { 179 | if ( format != null ) { 180 | try { 181 | return String.Format( format, arg1, arg2, arg3, arg4, arg5 ); 182 | } catch ( Exception e ) { 183 | Common.UDebug.LogException( e ); 184 | } 185 | } 186 | return String.Empty; 187 | } 188 | 189 | public static String SafeFormat( String format, params object[] args ) { 190 | if ( format != null && args != null ) { 191 | try { 192 | return String.Format( format, args ); 193 | } catch ( Exception e ) { 194 | Common.UDebug.LogException( e ); 195 | } 196 | } 197 | return String.Empty; 198 | } 199 | 200 | #if UNITY_EDITOR 201 | static int _IgnoreCount = 0; 202 | #endif 203 | 204 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 205 | static public void Assert( bool condition, string assertString = null ) { 206 | if ( !condition ) { 207 | Interlocked.Increment( ref _AssertFailCount ); 208 | #if UNITY_EDITOR 209 | try { 210 | StackTrace myTrace = new StackTrace( true ); 211 | StackFrame myFrame = myTrace.GetFrame( 1 ); 212 | assertString = assertString ?? String.Empty; 213 | string assertInformation = "Filename: " + myFrame.GetFileName() + "\nMethod: " + myFrame.GetMethod() + "\nLine: " + myFrame.GetFileLineNumber(); 214 | ULogFile.sharedInstance.LogError( assertInformation ); 215 | var s = assertString + "\n" + assertInformation; 216 | LogError( s ); 217 | if ( _IgnoreCount < 5 ) { 218 | UnityEngine.Debug.Break(); 219 | if ( UnityEditor.EditorUtility.DisplayDialog( "Assert!", s, "Debug", "Ignore" ) ) { 220 | UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal( myFrame.GetFileName(), myFrame.GetFileLineNumber() ); 221 | } else { 222 | ++_IgnoreCount; 223 | } 224 | } 225 | } catch ( Exception e ) { 226 | UnityEngine.Debug.LogError( e.ToString() ); 227 | } 228 | #else 229 | System.Diagnostics.Debug.Assert( condition, assertString ); 230 | #endif 231 | } 232 | } 233 | 234 | #region base logger 235 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 236 | public static void Log( String arg ) { 237 | Interlocked.Increment( ref _LogCount ); 238 | _Log( arg ); 239 | } 240 | 241 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 242 | public static void Log( T arg ) { 243 | Interlocked.Increment( ref _LogCount ); 244 | _Log( arg.ToString() ); 245 | } 246 | 247 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 248 | public static void LogError( String arg ) { 249 | Interlocked.Increment( ref _ErrorCount ); 250 | _LogError( arg ); 251 | } 252 | 253 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 254 | public static void LogError( T arg ) { 255 | Interlocked.Increment( ref _ErrorCount ); 256 | _LogError( arg.ToString() ); 257 | } 258 | 259 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 260 | public static void LogWarning( String arg ) { 261 | Interlocked.Increment( ref _WarningCount ); 262 | _LogWarning( arg ); 263 | } 264 | 265 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 266 | public static void LogWarning( T arg ) { 267 | Interlocked.Increment( ref _WarningCount ); 268 | _LogWarning( arg.ToString() ); 269 | } 270 | 271 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 272 | public static void LogException( Exception e ) { 273 | Interlocked.Increment( ref _ExceptionCount ); 274 | _LogException( e ); 275 | } 276 | #endregion 277 | 278 | #region LogEx 279 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 280 | public static void Log( String format, T arg ) { 281 | Log( SafeFormat( format, arg ) ); 282 | } 283 | 284 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 285 | public static void Log( String format, T1 arg1, T2 arg2 ) { 286 | Log( SafeFormat( format, arg1, arg2 ) ); 287 | } 288 | 289 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 290 | public static void Log( String format, T1 arg1, T2 arg2, T3 arg3 ) { 291 | Log( SafeFormat( format, arg1, arg2, arg3 ) ); 292 | } 293 | 294 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 295 | public static void Log( String format, T1 arg1, T2 arg2, T3 arg3, T4 arg4 ) { 296 | Log( SafeFormat( format, arg1, arg2, arg3, arg4 ) ); 297 | } 298 | 299 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 300 | public static void Log( String format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5 ) { 301 | Log( SafeFormat( format, arg1, arg2, arg3, arg4, arg5 ) ); 302 | } 303 | 304 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 305 | public static void Log( String format, params object[] args ) { 306 | Log( SafeFormat( format, args ) ); 307 | } 308 | #endregion 309 | 310 | #region LogErrorEx 311 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 312 | public static void LogError( String format, T arg ) { 313 | LogError( SafeFormat( format, arg ) ); 314 | } 315 | 316 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 317 | public static void LogError( String format, T1 arg1, T2 arg2 ) { 318 | LogError( SafeFormat( format, arg1, arg2 ) ); 319 | } 320 | 321 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 322 | public static void LogError( String format, T1 arg1, T2 arg2, T3 arg3 ) { 323 | LogError( SafeFormat( format, arg1, arg2, arg3 ) ); 324 | } 325 | 326 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 327 | public static void LogError( String format, T1 arg1, T2 arg2, T3 arg3, T4 arg4 ) { 328 | LogError( SafeFormat( format, arg1, arg2, arg3, arg4 ) ); 329 | } 330 | 331 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 332 | public static void LogError( String format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5 ) { 333 | LogError( SafeFormat( format, arg1, arg2, arg3, arg4, arg5 ) ); 334 | } 335 | 336 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 337 | public static void LogError( String format, params object[] args ) { 338 | LogError( SafeFormat( format, args ) ); 339 | } 340 | #endregion 341 | 342 | #region LogWarningEx 343 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 344 | public static void LogWarning( String format, T args ) { 345 | LogWarning( SafeFormat( format, args ) ); 346 | } 347 | 348 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 349 | public static void LogWarning( String format, T1 arg1, T2 arg2 ) { 350 | LogWarning( SafeFormat( format, arg1, arg2 ) ); 351 | } 352 | 353 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 354 | public static void LogWarning( String format, T1 arg1, T2 arg2, T3 arg3 ) { 355 | LogWarning( SafeFormat( format, arg1, arg2, arg3 ) ); 356 | } 357 | 358 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 359 | public static void LogWarning( String format, T1 arg1, T2 arg2, T3 arg3, T4 arg4 ) { 360 | LogWarning( SafeFormat( format, arg1, arg2, arg3, arg4 ) ); 361 | } 362 | 363 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 364 | public static void LogWarning( String format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5 ) { 365 | LogWarning( SafeFormat( format, arg1, arg2, arg3, arg4, arg5 ) ); 366 | } 367 | 368 | 369 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 370 | public static void LogWarning( String format, params object[] args ) { 371 | LogWarning( SafeFormat( format, args ) ); 372 | } 373 | #endregion 374 | 375 | [Conditional( "DEBUG" ), Conditional( "UNITY_EDITOR" ), Conditional( "ENABLE_ASSERTION" )] 376 | public static void BreakPoint() { 377 | #if UNITY_EDITOR 378 | UnityEngine.Debug.DebugBreak(); 379 | #else 380 | System.Diagnostics.Debugger.Break(); 381 | #endif 382 | } 383 | 384 | private static void NoAction( String msg ) { 385 | #if !UNITY_EDITOR 386 | Console.WriteLine( msg ); 387 | #endif 388 | } 389 | 390 | private static void NoActionException( Exception e ) { 391 | #if !UNITY_EDITOR 392 | Console.WriteLine( e.ToString() ); 393 | #endif 394 | } 395 | 396 | public static void Print( String arg ) { 397 | #if UNITY_4 || UNITY_5 || UNITY_EDITOR || DEBUG 398 | UnityEngine.Debug.Log( arg ); 399 | #else 400 | Console.WriteLine( arg ); 401 | #endif 402 | } 403 | 404 | public static void Print( T arg ) { 405 | #if UNITY_4 || UNITY_5 || UNITY_EDITOR || DEBUG 406 | UnityEngine.Debug.Log( arg.ToString() ); 407 | #else 408 | Console.WriteLine( arg.ToString() ); 409 | #endif 410 | } 411 | 412 | public static void Print( String format, T arg ) { 413 | #if UNITY_4 || UNITY_5 || UNITY_EDITOR || DEBUG 414 | UnityEngine.Debug.Log( SafeFormat( format, arg ) ); 415 | #else 416 | Console.WriteLine( SafeFormat( format, arg ) ); 417 | #endif 418 | } 419 | 420 | public static void Print( String format, T1 arg1, T2 arg2 ) { 421 | #if UNITY_4 || UNITY_5 || UNITY_EDITOR || DEBUG 422 | UnityEngine.Debug.Log( SafeFormat( format, arg1, arg2 ) ); 423 | #else 424 | Console.WriteLine( SafeFormat( format, arg1, arg2 ) ); 425 | #endif 426 | } 427 | 428 | public static void Print( String format, T1 arg1, T2 arg2, T3 arg3 ) { 429 | #if UNITY_4 || UNITY_5 || UNITY_EDITOR || DEBUG 430 | UnityEngine.Debug.Log( SafeFormat( format, arg1, arg2, arg3 ) ); 431 | #else 432 | Console.WriteLine( SafeFormat( format, arg1, arg2, arg3 ) ); 433 | #endif 434 | } 435 | 436 | public static void Print( String format, T1 arg1, T2 arg2, T3 arg3, T4 arg4 ) { 437 | #if UNITY_4 || UNITY_5 || UNITY_EDITOR || DEBUG 438 | UnityEngine.Debug.Log( SafeFormat( format, arg1, arg2, arg3, arg4 ) ); 439 | #else 440 | Console.WriteLine( SafeFormat( format, arg1, arg2, arg3, arg4 ) ); 441 | #endif 442 | } 443 | 444 | public static void Print( String format, T1 arg1, T2 arg2, T3 arg3, T4 arg4, T5 arg5 ) { 445 | #if UNITY_4 || UNITY_5 || UNITY_EDITOR || DEBUG 446 | UnityEngine.Debug.Log( SafeFormat( format, arg1, arg2, arg3, arg4, arg5 ) ); 447 | #else 448 | Console.WriteLine( SafeFormat( format, arg1, arg2, arg3, arg4, arg5 ) ); 449 | #endif 450 | } 451 | 452 | public static void Print( String format, params object[] args ) { 453 | #if UNITY_4 || UNITY_5 || UNITY_EDITOR || DEBUG 454 | UnityEngine.Debug.Log( SafeFormat( format, args ) ); 455 | #else 456 | Console.WriteLine( format, args ); 457 | #endif 458 | } 459 | 460 | static UDebug() { 461 | bool editor = false; 462 | #if UNITY_EDITOR 463 | editor = true; 464 | if ( UnityEditor.EditorApplication.isPlaying == false ) { 465 | enabled = true; 466 | } 467 | #endif 468 | if ( UnityEngine.Debug.isDebugBuild || editor ) { 469 | if ( enabled ) { 470 | _Log = UnityEngine.Debug.Log; 471 | _LogError = UnityEngine.Debug.LogError; 472 | _LogException = UnityEngine.Debug.LogException; 473 | _LogWarning = UnityEngine.Debug.LogWarning; 474 | } 475 | } 476 | } 477 | } 478 | } 479 | -------------------------------------------------------------------------------- /Assets/Editor/Common/Debug.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 04b9e82a440954749bfd4651794fa70a 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/Common/EditorUtils.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using System; 3 | using System.Text; 4 | using System.Collections; 5 | using System.Collections.Generic; 6 | using System.Security.Cryptography; 7 | using UnityEngine; 8 | using UnityEditor; 9 | using System.IO; 10 | using System.Linq; 11 | using System.Reflection; 12 | using Common; 13 | 14 | namespace AresEditor.ArtistKit { 15 | 16 | public static class EditorUtils { 17 | 18 | public static readonly String ProjectDirectory = String.Empty; 19 | 20 | static EditorUtils() { 21 | ProjectDirectory = EditorUtils.GetProjectUnityRootPath(); 22 | } 23 | 24 | public static String GetProjectRootPath() { 25 | string rootPath = Application.dataPath + "/../.."; 26 | if ( Directory.Exists( rootPath ) ) { 27 | rootPath = Path.GetFullPath( rootPath ); 28 | return rootPath.Replace( '\\', '/' ); 29 | } else { 30 | return rootPath; 31 | } 32 | } 33 | 34 | public static String GetProjectUnityRootPath() { 35 | string rootPath = Application.dataPath + "/.."; 36 | if ( Directory.Exists( rootPath ) ) { 37 | rootPath = Path.GetFullPath( rootPath ); 38 | return rootPath.Replace( '\\', '/' ); 39 | } else { 40 | return rootPath; 41 | } 42 | } 43 | 44 | public static String GetProjectUnityRootName() { 45 | var path = GetProjectUnityRootPath().TrimEnd( '/' ); 46 | return path.Substring( path.LastIndexOf( '/' ) + 1 ); 47 | } 48 | 49 | public static void BrowseFolderWin( String path, bool selectFile = false ) { 50 | if ( Application.platform == RuntimePlatform.WindowsEditor ) { 51 | System.Diagnostics.Process prcShell = new System.Diagnostics.Process(); 52 | prcShell.StartInfo.FileName = "explorer.exe"; 53 | path = path.Replace( '/', '\\' ); 54 | if ( selectFile && File.Exists( path ) ) { 55 | prcShell.StartInfo.Arguments = "/select, " + path; 56 | } else { 57 | prcShell.StartInfo.Arguments = path; 58 | } 59 | prcShell.Start(); 60 | } else { 61 | UnityEngine.Debug.Log( "Log dir: " + path ); 62 | } 63 | } 64 | 65 | public static void BrowseFolder( String path ) { 66 | if ( Application.isEditor ) { 67 | System.Diagnostics.Process prcShell = new System.Diagnostics.Process(); 68 | if ( Application.platform == RuntimePlatform.OSXEditor ) { 69 | prcShell.StartInfo.FileName = "open"; 70 | path = path.Replace( '\\', '/' ); 71 | } else if ( Application.platform == RuntimePlatform.WindowsEditor ) { 72 | prcShell.StartInfo.FileName = "explorer.exe"; 73 | path = path.Replace( '/', '\\' ); 74 | } else { 75 | return; 76 | } 77 | prcShell.StartInfo.Arguments = path; 78 | prcShell.Start(); 79 | } else { 80 | UnityEngine.Debug.Log( "Log dir: " + path ); 81 | } 82 | } 83 | 84 | public static void ClearLog() { 85 | var assembly = Assembly.GetAssembly( typeof( SceneView ) ); 86 | var type = assembly.GetType( "UnityEditorInternal.LogEntries" ); 87 | var method = type.GetMethod( "Clear" ); 88 | method.Invoke( null, null ); 89 | } 90 | 91 | public static void CheckCompileError() { 92 | Assembly assembly = Assembly.GetAssembly( typeof( SceneView ) ); 93 | Type logEntries = assembly.GetType( "UnityEditorInternal.LogEntries" ); 94 | logEntries.GetMethod( "Clear" ).Invoke( null, null ); 95 | int count = ( int )logEntries.GetMethod( "GetCount" ).Invoke( null, null ); 96 | if ( count > 0 ) { 97 | Common.UDebug.LogError( "Cannot build because you have compile errors!" ); 98 | } 99 | } 100 | 101 | public static Func FileExtFilter( String ext ) { 102 | if ( !ext.StartsWith( "." ) ) { 103 | ext = "." + ext; 104 | } 105 | return fileName => fileName.EndsWith( ext, StringComparison.CurrentCultureIgnoreCase ); 106 | } 107 | 108 | public static bool FileFilter_prefab( String fileName ) { 109 | return fileName.EndsWith( ".prefab", StringComparison.CurrentCultureIgnoreCase ); 110 | } 111 | 112 | public static String RelateToAssetsPath( String path ) { 113 | if ( path.StartsWith( Application.dataPath ) ) { 114 | return "Assets" + path.Substring( Application.dataPath.Length ); 115 | } 116 | return path; 117 | } 118 | 119 | public static String GetSelectedPath() { 120 | var path = String.Empty; 121 | var sel = Selection.GetFiltered( typeof( UnityEngine.Object ), SelectionMode.Assets ); 122 | foreach ( var obj in sel ) { 123 | path = AssetDatabase.GetAssetPath( obj ); 124 | if ( !string.IsNullOrEmpty( path ) && Directory.Exists( path ) ) { 125 | break; 126 | } 127 | } 128 | return path; 129 | } 130 | 131 | public static List GetAllSelectedPath() { 132 | var paths = new List(); 133 | var sel = Selection.GetFiltered( typeof( UnityEngine.Object ), SelectionMode.Assets ); 134 | foreach ( var obj in sel ) { 135 | var path = AssetDatabase.GetAssetPath( obj ); 136 | if ( !string.IsNullOrEmpty( path ) && Directory.Exists( path ) ) { 137 | paths.Add( path ); 138 | } 139 | } 140 | return paths; 141 | } 142 | 143 | public static String GetFullPath( String path ) { 144 | path = Path.GetFullPath( ( new Uri( path ) ).LocalPath ); 145 | path = path.Replace( '\\', '/' ); 146 | if ( FileUtils.CreateDirectory( path ) ) { 147 | return path; 148 | } else { 149 | return String.Empty; 150 | } 151 | } 152 | 153 | public static FileStream FileOpenRead( String filePath ) { 154 | if ( !System.IO.Path.IsPathRooted( filePath ) ) { 155 | filePath = ProjectDirectory + "/" + filePath; 156 | filePath = filePath.Replace( System.IO.Path.AltDirectorySeparatorChar, System.IO.Path.DirectorySeparatorChar ); 157 | } 158 | return File.OpenRead( filePath ); 159 | } 160 | 161 | static String _Md5Asset( String filePath, 162 | MD5CryptoServiceProvider md5Service, 163 | byte[] buffer, StringBuilder sb ) { 164 | try { 165 | int bytesRead = 0; 166 | using ( var file = FileOpenRead( filePath ) ) { 167 | while ( ( bytesRead = file.Read( buffer, 0, buffer.Length ) ) > 0 ) { 168 | md5Service.TransformBlock( buffer, 0, bytesRead, buffer, 0 ); 169 | } 170 | } 171 | var meta = filePath + ".meta"; 172 | if ( File.Exists( meta ) ) { 173 | bytesRead = 0; 174 | using ( var file = FileOpenRead( meta ) ) { 175 | while ( ( bytesRead = file.Read( buffer, 0, buffer.Length ) ) > 0 ) { 176 | md5Service.TransformBlock( buffer, 0, bytesRead, buffer, 0 ); 177 | } 178 | } 179 | } 180 | md5Service.TransformFinalBlock( buffer, 0, bytesRead ); 181 | var hashBytes = md5Service.Hash; 182 | for ( int i = 0; i < hashBytes.Length; i++ ) { 183 | sb.Append( hashBytes[ i ].ToString( "x2" ) ); 184 | } 185 | return sb.ToString(); 186 | } catch ( Exception e ) { 187 | ULogFile.sharedInstance.LogError( "_Md5Asset: {0}\ncd: {1}", filePath, ProjectDirectory ); 188 | ULogFile.sharedInstance.LogException( e ); 189 | } 190 | return String.Empty; 191 | } 192 | 193 | public static String Md5Asset( String filePath ) { 194 | if ( !File.Exists( filePath ) ) { 195 | return String.Empty; 196 | } 197 | const int chunkSize = 10240; 198 | var _MD5Service = new MD5CryptoServiceProvider(); 199 | var buffer = new byte[ chunkSize ]; 200 | return _Md5Asset( filePath, _MD5Service, buffer, new StringBuilder() ); 201 | } 202 | 203 | public static String Md5File( String filePath ) { 204 | try { 205 | using ( var stream = new BufferedStream( FileOpenRead( filePath ), 4096 ) ) { 206 | var _MD5Service = new MD5CryptoServiceProvider(); 207 | var hashBytes = _MD5Service.ComputeHash( stream ); 208 | var sb = new StringBuilder(); 209 | for ( int i = 0; i < hashBytes.Length; i++ ) { 210 | sb.Append( hashBytes[ i ].ToString( "x2" ) ); 211 | } 212 | return sb.ToString(); 213 | } 214 | } catch ( Exception e ) { 215 | ULogFile.sharedInstance.LogException( e ); 216 | } 217 | return String.Empty; 218 | } 219 | 220 | public static String Md5String( String str ) { 221 | var bytes = UTF8Encoding.Default.GetBytes( str ); 222 | var md5 = new MD5CryptoServiceProvider(); 223 | var hashBytes = md5.ComputeHash( bytes ); 224 | var sb = new StringBuilder(); 225 | for ( int i = 0; i < hashBytes.Length; i++ ) { 226 | sb.Append( hashBytes[ i ].ToString( "x2" ) ); 227 | } 228 | return sb.ToString(); 229 | } 230 | } 231 | } 232 | #endif 233 | //EOF 234 | -------------------------------------------------------------------------------- /Assets/Editor/Common/EditorUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8b36715da8ce0b243bde55b2b01854d3 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/Common/FileUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | using System.IO; 5 | 6 | namespace Common { 7 | 8 | public static class FileUtils { 9 | 10 | public static FileStream OpenFile( String fullPath ) { 11 | FileStream fs = null; 12 | try { 13 | fs = File.Open( fullPath, FileMode.Open, FileAccess.Read, FileShare.Read ); 14 | } catch ( Exception e ) { 15 | Common.ULogFile.sharedInstance.LogException( e ); 16 | } 17 | return fs; 18 | } 19 | 20 | // create a directory 21 | // each sub directories will be created if any of them don't exist. 22 | public static bool CreateDirectory( String dirName ) { 23 | try { 24 | // first remove file name and extension; 25 | var ext = Path.GetExtension( dirName ); 26 | String fileNameAndExt = Path.GetFileName( dirName ); 27 | if ( !String.IsNullOrEmpty( fileNameAndExt ) && !string.IsNullOrEmpty( ext ) ) { 28 | dirName = dirName.Substring( 0, dirName.Length - fileNameAndExt.Length ); 29 | } 30 | var sb = new StringBuilder(); 31 | var dirs = dirName.Split( '/', '\\' ); 32 | if ( dirs.Length > 0 ) { 33 | if ( dirName[ 0 ] == '/' ) { 34 | // abs path tag on Linux OS 35 | dirs[ 0 ] = "/" + dirs[ 0 ]; 36 | } 37 | } 38 | for ( int i = 0; i < dirs.Length; ++i ) { 39 | if ( dirs[ i ].Length == 0 ) { 40 | continue; 41 | } 42 | if ( sb.Length != 0 ) { 43 | sb.Append( '/' ); 44 | } 45 | sb.Append( dirs[ i ] ); 46 | var cur = sb.ToString(); 47 | if ( String.IsNullOrEmpty( cur ) ) { 48 | continue; 49 | } 50 | if ( !Directory.Exists( cur ) ) { 51 | var info = Directory.CreateDirectory( cur ); 52 | if ( null == info ) { 53 | return false; 54 | } 55 | } 56 | } 57 | return true; 58 | } catch ( Exception e ) { 59 | ULogFile.sharedInstance.LogException( e ); 60 | } 61 | return false; 62 | } 63 | 64 | public static bool CopyDirectory( String sourceDirName, String destDirName, bool copySubDirs ) { 65 | // Get the subdirectories for the specified directory. 66 | DirectoryInfo dir = new DirectoryInfo( sourceDirName ); 67 | if ( !dir.Exists ) { 68 | return false; 69 | } 70 | DirectoryInfo[] dirs = dir.GetDirectories(); 71 | // If the destination directory doesn't exist, create it. 72 | if ( !Directory.Exists( destDirName ) ) { 73 | Directory.CreateDirectory( destDirName ); 74 | } 75 | // Get the files in the directory and copy them to the new location. 76 | FileInfo[] files = dir.GetFiles(); 77 | foreach ( FileInfo file in files ) { 78 | string temppath = Path.Combine( destDirName, file.Name ); 79 | file.CopyTo( temppath, false ); 80 | } 81 | var ret = true; 82 | // If copying subdirectories, copy them and their contents to new location. 83 | if ( copySubDirs ) { 84 | foreach ( DirectoryInfo subdir in dirs ) { 85 | string temppath = Path.Combine( destDirName, subdir.Name ); 86 | ret &= CopyDirectory( subdir.FullName, temppath, copySubDirs ); 87 | } 88 | } 89 | return ret; 90 | } 91 | 92 | public enum TreeWalkerCmd { 93 | Continue, 94 | Skip, 95 | Exit, 96 | } 97 | 98 | public interface ITreeWalker { 99 | bool IsRecursive(); 100 | // will be called for each file while WalkTree is running 101 | TreeWalkerCmd DoFile( String name ); 102 | // will be called for each directory while WalkTree is running 103 | TreeWalkerCmd DoDirectory( String name ); 104 | // wildmatch pattern 105 | String FileSearchPattern(); 106 | String DirectorySearchPattern(); 107 | } 108 | 109 | public class BaseTreeWalker : ITreeWalker { 110 | public virtual bool IsRecursive() { return true; } 111 | public virtual TreeWalkerCmd DoFile( String name ) { return TreeWalkerCmd.Continue; } 112 | public virtual TreeWalkerCmd DoDirectory( String name ) { return TreeWalkerCmd.Continue; } 113 | public virtual String FileSearchPattern() { return "*"; } 114 | public virtual String DirectorySearchPattern() { return "*"; } 115 | } 116 | 117 | class TreeDeleter : BaseTreeWalker, IDisposable { 118 | public List fileList = new List(); 119 | public List dirList = new List(); 120 | public override bool IsRecursive() { return true; } 121 | public override TreeWalkerCmd DoFile( String name ) { 122 | fileList.Add( name ); 123 | return TreeWalkerCmd.Continue; 124 | } 125 | public override TreeWalkerCmd DoDirectory( String name ) { 126 | dirList.Add( name ); 127 | return TreeWalkerCmd.Continue; 128 | } 129 | public void Dispose() { 130 | try { 131 | for ( int i = 0; i < fileList.Count; ++i ) { 132 | File.Delete( fileList[i] ); 133 | } 134 | for ( int i = dirList.Count - 1; i >= 0; --i ) { 135 | Directory.Delete( dirList[i] ); 136 | } 137 | } catch ( Exception e ) { 138 | UDebug.LogException( e ); 139 | } 140 | } 141 | } 142 | 143 | public static bool RemoveTree( String dirName, bool delSelf = false ) { 144 | int count = 0; 145 | using ( var td = new TreeDeleter() ) { 146 | WalkTree( dirName, td ); 147 | count = td.dirList.Count + td.fileList.Count; 148 | } 149 | if ( delSelf ) { 150 | try { 151 | if ( Directory.Exists( dirName ) ) { 152 | Directory.Delete( dirName ); 153 | } 154 | } catch ( Exception e ) { 155 | UDebug.LogException( e ); 156 | } 157 | } 158 | return count != 0; 159 | } 160 | 161 | public static void WalkTree( String dirName, ITreeWalker walker ) { 162 | var dirCount = 0; 163 | dirName = Common.StringUtils.StandardisePath( dirName ); 164 | Stack dirStack = new Stack(); 165 | dirStack.Push( dirName ); 166 | while ( dirStack.Count > 0 ) { 167 | String lastPath = dirStack.Pop(); 168 | DirectoryInfo di = new DirectoryInfo( lastPath ); 169 | if ( !di.Exists || ( ( di.Attributes & FileAttributes.Hidden ) != 0 && dirCount > 0 ) ) { 170 | continue; 171 | } 172 | ++dirCount; 173 | foreach ( FileInfo fileInfo in di.GetFiles( walker.FileSearchPattern() ) ) { 174 | // compose full file name from dirName 175 | String f = lastPath; 176 | if ( f[f.Length - 1] == '/' ) { 177 | f += fileInfo.Name; 178 | } else { 179 | f = f + "/" + fileInfo.Name; 180 | } 181 | var cmd = walker.DoFile( f ); 182 | switch ( cmd ) { 183 | case TreeWalkerCmd.Skip: 184 | continue; 185 | case TreeWalkerCmd.Exit: 186 | goto EXIT; 187 | } 188 | } 189 | if ( walker.IsRecursive() ) { 190 | foreach ( DirectoryInfo dirInfo in di.GetDirectories( walker.DirectorySearchPattern() ) ) { 191 | // compose full path name from dirName 192 | String p = lastPath; 193 | if ( p[p.Length - 1] == '/' ) { 194 | p += dirInfo.Name; 195 | } else { 196 | p = p + "/" + dirInfo.Name; 197 | } 198 | FileAttributes fa = File.GetAttributes( p ); 199 | if ( ( fa & FileAttributes.Hidden ) == 0 ) { 200 | var cmd = walker.DoDirectory( p ); 201 | switch ( cmd ) { 202 | case TreeWalkerCmd.Skip: 203 | continue; 204 | case TreeWalkerCmd.Exit: 205 | goto EXIT; 206 | } 207 | dirStack.Push( p ); 208 | } 209 | } 210 | } 211 | } 212 | EXIT: 213 | ; 214 | } 215 | 216 | class DirectoryScanner : BaseTreeWalker { 217 | List m_allDirs; 218 | Func m_filter; 219 | bool m_recursive; 220 | public DirectoryScanner( List fs, Func filter, bool recursive ) { 221 | m_allDirs = fs; 222 | m_filter = filter; 223 | m_recursive = recursive; 224 | } 225 | public override bool IsRecursive() { 226 | return m_recursive; 227 | } 228 | public override TreeWalkerCmd DoDirectory( String name ) { 229 | if ( m_filter == null || !m_filter( name ) ) { 230 | m_allDirs.Add( name ); 231 | } 232 | return TreeWalkerCmd.Continue; 233 | } 234 | } 235 | 236 | class FileScanner : BaseTreeWalker { 237 | List m_allFiles; 238 | Func m_filter; 239 | bool m_recursive; 240 | public FileScanner( List fs, Func filter, bool recursive ) { 241 | m_allFiles = fs; 242 | m_filter = filter; 243 | m_recursive = recursive; 244 | } 245 | public override bool IsRecursive() { 246 | return m_recursive; 247 | } 248 | public override TreeWalkerCmd DoFile( String name ) { 249 | if ( m_filter == null || m_filter( name ) ) { 250 | m_allFiles.Add( name ); 251 | } 252 | return TreeWalkerCmd.Continue; 253 | } 254 | } 255 | 256 | public static List GetFileList( String path, Func filter, bool recursive = true ) { 257 | var ret = new List(); 258 | if ( !String.IsNullOrEmpty( path ) ) { 259 | var fs = new FileScanner( ret, filter, recursive ); 260 | WalkTree( path, fs ); 261 | } 262 | return ret; 263 | } 264 | 265 | public static List GetDirectoryList( String path, Func filter, bool recursive = true ) { 266 | var ret = new List(); 267 | if ( !String.IsNullOrEmpty( path ) ) { 268 | var fs = new DirectoryScanner( ret, filter, recursive ); 269 | WalkTree( path, fs ); 270 | } 271 | return ret; 272 | } 273 | } 274 | } 275 | -------------------------------------------------------------------------------- /Assets/Editor/Common/FileUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: fcb8ecb4d2d7f5c4a92b17a910b5594f 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/Common/JSON.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d31b71188f802eb47b373ff1966e9a4e 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Editor/Common/JSON/JSONObject.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c56cca2bfdc6da948bf23995bb3ae069 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/Common/JSON/JSONTemplates.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | /* 6 | * http://www.opensource.org/licenses/lgpl-2.1.php 7 | * JSONTemplates class 8 | * for use with Unity 9 | * Copyright Matt Schoen 2010 10 | */ 11 | 12 | public static partial class JSONTemplates { 13 | static readonly HashSet touched = new HashSet(); 14 | 15 | public static JSONObject TOJSON(object obj) { //For a generic guess 16 | if(touched.Add(obj)) { 17 | JSONObject result = JSONObject.obj; 18 | //Fields 19 | FieldInfo[] fieldinfo = obj.GetType().GetFields(); 20 | foreach(FieldInfo fi in fieldinfo) { 21 | JSONObject val = JSONObject.nullJO; 22 | if(!fi.GetValue(obj).Equals(null)) { 23 | MethodInfo info = typeof(JSONTemplates).GetMethod("From" + fi.FieldType.Name); 24 | if(info != null) { 25 | object[] parms = new object[1]; 26 | parms[0] = fi.GetValue(obj); 27 | val = (JSONObject)info.Invoke(null, parms); 28 | } else if(fi.FieldType == typeof(string)) 29 | val = JSONObject.CreateStringObject(fi.GetValue(obj).ToString()); 30 | else 31 | val = JSONObject.Create(fi.GetValue(obj).ToString()); 32 | } 33 | if(val) { 34 | if(val.type != JSONObject.Type.NULL) 35 | result.AddField(fi.Name, val); 36 | else Debug.LogWarning("Null for this non-null object, property " + fi.Name + " of class " + obj.GetType().Name + ". Object type is " + fi.FieldType.Name); 37 | } 38 | } 39 | //Properties 40 | PropertyInfo[] propertyInfo = obj.GetType().GetProperties(); 41 | foreach(PropertyInfo pi in propertyInfo) { 42 | //This section should mirror part of AssetFactory.AddScripts() 43 | JSONObject val = JSONObject.nullJO; 44 | if(!pi.GetValue(obj, null).Equals(null)) { 45 | MethodInfo info = typeof(JSONTemplates).GetMethod("From" + pi.PropertyType.Name); 46 | if(info != null) { 47 | object[] parms = new object[1]; 48 | parms[0] = pi.GetValue(obj, null); 49 | val = (JSONObject)info.Invoke(null, parms); 50 | } else if(pi.PropertyType == typeof(string)) 51 | val = JSONObject.CreateStringObject(pi.GetValue(obj, null).ToString()); 52 | else 53 | val = JSONObject.Create(pi.GetValue(obj, null).ToString()); 54 | } 55 | if(val) { 56 | if(val.type != JSONObject.Type.NULL) 57 | result.AddField(pi.Name, val); 58 | else Debug.LogWarning("Null for this non-null object, property " + pi.Name + " of class " + obj.GetType().Name + ". Object type is " + pi.PropertyType.Name); 59 | } 60 | } 61 | return result; 62 | } 63 | Debug.LogWarning("trying to save the same data twice"); 64 | return JSONObject.nullJO; 65 | } 66 | } 67 | 68 | /* 69 | * Some helpful code templates for the JSON class 70 | * 71 | * LOOP THROUGH OBJECT 72 | for(int i = 0; i < obj.Count; i++){ 73 | if(obj.keys[i] != null){ 74 | switch((string)obj.keys[i]){ 75 | case "key1": 76 | do stuff with (JSONObject)obj.list[i]; 77 | break; 78 | case "key2": 79 | do stuff with (JSONObject)obj.list[i]; 80 | break; 81 | } 82 | } 83 | } 84 | * 85 | * LOOP THROUGH ARRAY 86 | foreach(JSONObject ob in obj.list) 87 | do stuff with ob; 88 | */ 89 | -------------------------------------------------------------------------------- /Assets/Editor/Common/JSON/JSONTemplates.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0a17052a3def56b4ebea997f85304acf 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/Common/JSON/SimpleJSON.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6b1508e4877d15b42b9a7dc0e17bc067 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/Common/JSON/VectorTemplates.cs: -------------------------------------------------------------------------------- 1 | using UnityEngine; 2 | 3 | public static partial class JSONTemplates { 4 | 5 | /* 6 | * Vector2 7 | */ 8 | public static Vector2 ToVector2(JSONObject obj) { 9 | float x = obj["x"] ? obj["x"].f : 0; 10 | float y = obj["y"] ? obj["y"].f : 0; 11 | return new Vector2(x, y); 12 | } 13 | public static JSONObject FromVector2(Vector2 v) { 14 | JSONObject vdata = JSONObject.obj; 15 | if(v.x != 0) vdata.AddField("x", v.x); 16 | if(v.y != 0) vdata.AddField("y", v.y); 17 | return vdata; 18 | } 19 | /* 20 | * Vector3 21 | */ 22 | public static JSONObject FromVector3(Vector3 v) { 23 | JSONObject vdata = JSONObject.obj; 24 | if(v.x != 0) vdata.AddField("x", v.x); 25 | if(v.y != 0) vdata.AddField("y", v.y); 26 | if(v.z != 0) vdata.AddField("z", v.z); 27 | return vdata; 28 | } 29 | public static Vector3 ToVector3(JSONObject obj) { 30 | float x = obj["x"] ? obj["x"].f : 0; 31 | float y = obj["y"] ? obj["y"].f : 0; 32 | float z = obj["z"] ? obj["z"].f : 0; 33 | return new Vector3(x, y, z); 34 | } 35 | /* 36 | * Vector4 37 | */ 38 | public static JSONObject FromVector4(Vector4 v) { 39 | JSONObject vdata = JSONObject.obj; 40 | if(v.x != 0) vdata.AddField("x", v.x); 41 | if(v.y != 0) vdata.AddField("y", v.y); 42 | if(v.z != 0) vdata.AddField("z", v.z); 43 | if(v.w != 0) vdata.AddField("w", v.w); 44 | return vdata; 45 | } 46 | public static Vector4 ToVector4(JSONObject obj) { 47 | float x = obj["x"] ? obj["x"].f : 0; 48 | float y = obj["y"] ? obj["y"].f : 0; 49 | float z = obj["z"] ? obj["z"].f : 0; 50 | float w = obj["w"] ? obj["w"].f : 0; 51 | return new Vector4(x, y, z, w); 52 | } 53 | /* 54 | * Matrix4x4 55 | */ 56 | public static JSONObject FromMatrix4x4(Matrix4x4 m) { 57 | JSONObject mdata = JSONObject.obj; 58 | if(m.m00 != 0) mdata.AddField("m00", m.m00); 59 | if(m.m01 != 0) mdata.AddField("m01", m.m01); 60 | if(m.m02 != 0) mdata.AddField("m02", m.m02); 61 | if(m.m03 != 0) mdata.AddField("m03", m.m03); 62 | if(m.m10 != 0) mdata.AddField("m10", m.m10); 63 | if(m.m11 != 0) mdata.AddField("m11", m.m11); 64 | if(m.m12 != 0) mdata.AddField("m12", m.m12); 65 | if(m.m13 != 0) mdata.AddField("m13", m.m13); 66 | if(m.m20 != 0) mdata.AddField("m20", m.m20); 67 | if(m.m21 != 0) mdata.AddField("m21", m.m21); 68 | if(m.m22 != 0) mdata.AddField("m22", m.m22); 69 | if(m.m23 != 0) mdata.AddField("m23", m.m23); 70 | if(m.m30 != 0) mdata.AddField("m30", m.m30); 71 | if(m.m31 != 0) mdata.AddField("m31", m.m31); 72 | if(m.m32 != 0) mdata.AddField("m32", m.m32); 73 | if(m.m33 != 0) mdata.AddField("m33", m.m33); 74 | return mdata; 75 | } 76 | public static Matrix4x4 ToMatrix4x4(JSONObject obj) { 77 | Matrix4x4 result = new Matrix4x4(); 78 | if(obj["m00"]) result.m00 = obj["m00"].f; 79 | if(obj["m01"]) result.m01 = obj["m01"].f; 80 | if(obj["m02"]) result.m02 = obj["m02"].f; 81 | if(obj["m03"]) result.m03 = obj["m03"].f; 82 | if(obj["m10"]) result.m10 = obj["m10"].f; 83 | if(obj["m11"]) result.m11 = obj["m11"].f; 84 | if(obj["m12"]) result.m12 = obj["m12"].f; 85 | if(obj["m13"]) result.m13 = obj["m13"].f; 86 | if(obj["m20"]) result.m20 = obj["m20"].f; 87 | if(obj["m21"]) result.m21 = obj["m21"].f; 88 | if(obj["m22"]) result.m22 = obj["m22"].f; 89 | if(obj["m23"]) result.m23 = obj["m23"].f; 90 | if(obj["m30"]) result.m30 = obj["m30"].f; 91 | if(obj["m31"]) result.m31 = obj["m31"].f; 92 | if(obj["m32"]) result.m32 = obj["m32"].f; 93 | if(obj["m33"]) result.m33 = obj["m33"].f; 94 | return result; 95 | } 96 | /* 97 | * Quaternion 98 | */ 99 | public static JSONObject FromQuaternion(Quaternion q) { 100 | JSONObject qdata = JSONObject.obj; 101 | if(q.w != 0) qdata.AddField("w", q.w); 102 | if(q.x != 0) qdata.AddField("x", q.x); 103 | if(q.y != 0) qdata.AddField("y", q.y); 104 | if(q.z != 0) qdata.AddField("z", q.z); 105 | return qdata; 106 | } 107 | public static Quaternion ToQuaternion(JSONObject obj) { 108 | float x = obj["x"] ? obj["x"].f : 0; 109 | float y = obj["y"] ? obj["y"].f : 0; 110 | float z = obj["z"] ? obj["z"].f : 0; 111 | float w = obj["w"] ? obj["w"].f : 0; 112 | return new Quaternion(x, y, z, w); 113 | } 114 | /* 115 | * Color 116 | */ 117 | public static JSONObject FromColor(Color c) { 118 | JSONObject cdata = JSONObject.obj; 119 | if(c.r != 0) cdata.AddField("r", c.r); 120 | if(c.g != 0) cdata.AddField("g", c.g); 121 | if(c.b != 0) cdata.AddField("b", c.b); 122 | if(c.a != 0) cdata.AddField("a", c.a); 123 | return cdata; 124 | } 125 | public static Color ToColor(JSONObject obj) { 126 | Color c = new Color(); 127 | for(int i = 0; i < obj.Count; i++) { 128 | switch(obj.keys[i]) { 129 | case "r": c.r = obj[i].f; break; 130 | case "g": c.g = obj[i].f; break; 131 | case "b": c.b = obj[i].f; break; 132 | case "a": c.a = obj[i].f; break; 133 | } 134 | } 135 | return c; 136 | } 137 | /* 138 | * Layer Mask 139 | */ 140 | public static JSONObject FromLayerMask(LayerMask l) { 141 | JSONObject result = JSONObject.obj; 142 | result.AddField("value", l.value); 143 | return result; 144 | } 145 | public static LayerMask ToLayerMask(JSONObject obj) { 146 | LayerMask l = new LayerMask {value = (int)obj["value"].n}; 147 | return l; 148 | } 149 | public static JSONObject FromRect(Rect r) { 150 | JSONObject result = JSONObject.obj; 151 | if(r.x != 0) result.AddField("x", r.x); 152 | if(r.y != 0) result.AddField("y", r.y); 153 | if(r.height != 0) result.AddField("height", r.height); 154 | if(r.width != 0) result.AddField("width", r.width); 155 | return result; 156 | } 157 | public static Rect ToRect(JSONObject obj) { 158 | Rect r = new Rect(); 159 | for(int i = 0; i < obj.Count; i++) { 160 | switch(obj.keys[i]) { 161 | case "x": r.x = obj[i].f; break; 162 | case "y": r.y = obj[i].f; break; 163 | case "height": r.height = obj[i].f; break; 164 | case "width": r.width = obj[i].f; break; 165 | } 166 | } 167 | return r; 168 | } 169 | public static JSONObject FromRectOffset(RectOffset r) { 170 | JSONObject result = JSONObject.obj; 171 | if(r.bottom != 0) result.AddField("bottom", r.bottom); 172 | if(r.left != 0) result.AddField("left", r.left); 173 | if(r.right != 0) result.AddField("right", r.right); 174 | if(r.top != 0) result.AddField("top", r.top); 175 | return result; 176 | } 177 | public static RectOffset ToRectOffset(JSONObject obj) { 178 | RectOffset r = new RectOffset(); 179 | for(int i = 0; i < obj.Count; i++) { 180 | switch(obj.keys[i]) { 181 | case "bottom": r.bottom = (int)obj[i].n; break; 182 | case "left": r.left = (int)obj[i].n; break; 183 | case "right": r.right = (int)obj[i].n; break; 184 | case "top": r.top = (int)obj[i].n; break; 185 | } 186 | } 187 | return r; 188 | } 189 | 190 | public static AnimationCurve ToAnimationCurve(JSONObject obj){ 191 | AnimationCurve a = new AnimationCurve(); 192 | if(obj.HasField("keys")){ 193 | JSONObject keys = obj.GetField("keys"); 194 | for(int i =0; i < keys.list.Count;i++){ 195 | a.AddKey(ToKeyframe(keys[i])); 196 | } 197 | } 198 | if(obj.HasField("preWrapMode")) 199 | a.preWrapMode = (WrapMode)((int)obj.GetField("preWrapMode").n); 200 | if(obj.HasField("postWrapMode")) 201 | a.postWrapMode = (WrapMode)((int)obj.GetField("postWrapMode").n); 202 | return a; 203 | } 204 | 205 | public static JSONObject FromAnimationCurve(AnimationCurve a){ 206 | JSONObject result = JSONObject.obj; 207 | result.AddField("preWrapMode", a.preWrapMode.ToString()); 208 | result.AddField("postWrapMode", a.postWrapMode.ToString()); 209 | if(a.keys.Length > 0){ 210 | JSONObject keysJSON = JSONObject.Create(); 211 | for(int i =0; i < a.keys.Length;i++){ 212 | keysJSON.Add(FromKeyframe(a.keys[i])); 213 | } 214 | result.AddField("keys", keysJSON); 215 | } 216 | return result; 217 | } 218 | 219 | public static Keyframe ToKeyframe(JSONObject obj){ 220 | Keyframe k = new Keyframe(obj.HasField("time")? obj.GetField("time").n : 0, obj.HasField("value")? obj.GetField("value").n : 0); 221 | if(obj.HasField("inTangent")) k.inTangent = obj.GetField("inTangent").n; 222 | if(obj.HasField("outTangent")) k.outTangent = obj.GetField("outTangent").n; 223 | if(obj.HasField("tangentMode")) k.tangentMode = (int)obj.GetField("tangentMode").n; 224 | 225 | return k; 226 | } 227 | public static JSONObject FromKeyframe(Keyframe k){ 228 | JSONObject result = JSONObject.obj; 229 | if(k.inTangent != 0) result.AddField("inTangent", k.inTangent); 230 | if(k.outTangent != 0) result.AddField("outTangent", k.outTangent); 231 | if(k.tangentMode != 0) result.AddField("tangentMode", k.tangentMode); 232 | if(k.time != 0) result.AddField("time", k.time); 233 | if(k.value != 0) result.AddField("value", k.value); 234 | return result; 235 | } 236 | 237 | } 238 | -------------------------------------------------------------------------------- /Assets/Editor/Common/JSON/VectorTemplates.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d4d4e3ac673696248a8bd64cca9e305b 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/Common/StringUtils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Security.Cryptography; 6 | using UnityEngine; 7 | 8 | namespace Common { 9 | 10 | public static class StringUtils { 11 | 12 | const int GlobalStringBuilderPoolSize = 10; 13 | const int MaxGlobalStringBuilderPoolSize = GlobalStringBuilderPoolSize * 4; 14 | const int StringBuilderInitSize = 128; 15 | const int StringBuilderMaxSize = 256; 16 | 17 | static Queue[] _StringBuilderPoolBuf = null; // allocating & allocated pools 18 | static int _StringBuilderPoolIndex = 0; // allocator pool index in buf 19 | 20 | static StringUtils() { 21 | _StringBuilderPoolBuf = new Queue[ 2 ] { 22 | new Queue(), 23 | new Queue() 24 | }; 25 | for ( int i = 0; i < GlobalStringBuilderPoolSize; ++i ) { 26 | _StringBuilderPoolBuf[ _StringBuilderPoolIndex ].Enqueue( new StringBuilder( StringBuilderInitSize ) ); 27 | } 28 | } 29 | 30 | public static StringBuilder newStringBuilder { 31 | get { 32 | var curPool = _StringBuilderPoolBuf[ _StringBuilderPoolIndex ]; 33 | if ( curPool.Count == 0 ) { 34 | // swap allocator pool 35 | _StringBuilderPoolIndex = ( _StringBuilderPoolIndex + 1 ) & 1; 36 | curPool = _StringBuilderPoolBuf[ _StringBuilderPoolIndex ]; 37 | } 38 | var dstIndex = ( _StringBuilderPoolIndex + 1 ) & 1; 39 | var dstPool = _StringBuilderPoolBuf[ dstIndex ]; 40 | if ( curPool.Count > 0 ) { 41 | var sb = curPool.Dequeue(); 42 | dstPool.Enqueue( sb ); 43 | sb.Length = 0; 44 | return sb; 45 | } else { 46 | var sb = new StringBuilder( StringBuilderInitSize ); 47 | dstPool.Enqueue( sb ); 48 | return sb; 49 | } 50 | } 51 | } 52 | 53 | public static StringBuilder AllocateStringBuilder() { 54 | var curPool = _StringBuilderPoolBuf[ _StringBuilderPoolIndex ]; 55 | if ( curPool.Count == 0 ) { 56 | // swap allocator pool 57 | _StringBuilderPoolIndex = ( _StringBuilderPoolIndex + 1 ) & 1; 58 | curPool = _StringBuilderPoolBuf[ _StringBuilderPoolIndex ]; 59 | } 60 | if ( curPool.Count > 0 ) { 61 | var sb = curPool.Dequeue(); 62 | sb.Length = 0; 63 | return sb; 64 | } else { 65 | return new StringBuilder( StringBuilderInitSize ); 66 | } 67 | } 68 | 69 | public static void FreeStringBuilder( StringBuilder sb ) { 70 | var curPool = _StringBuilderPoolBuf[ _StringBuilderPoolIndex ]; 71 | if ( sb != null && curPool.Count < MaxGlobalStringBuilderPoolSize ) { 72 | sb.Length = 0; 73 | if ( sb.Capacity > StringBuilderMaxSize ) { 74 | sb.Capacity = StringBuilderInitSize; 75 | } 76 | curPool.Enqueue( sb ); 77 | } 78 | } 79 | 80 | public static void SplitFilename( String qualifiedName, out String outBasename, out String outPath ) { 81 | String path = qualifiedName.Replace( '\\', '/' ); 82 | int i = path.LastIndexOf( '/' ); 83 | if ( i == -1 ) { 84 | outPath = String.Empty; 85 | outBasename = qualifiedName; 86 | } else { 87 | outBasename = path.Substring( i + 1, path.Length - i - 1 ); 88 | outPath = path.Substring( 0, i + 1 ); 89 | } 90 | } 91 | 92 | public static String StandardisePath( String init ) { 93 | String path = init.Replace( '\\', '/' ); 94 | if ( path.Length > 0 && path[ path.Length - 1 ] != '/' ) { 95 | path += '/'; 96 | } 97 | return path; 98 | } 99 | 100 | public static String StandardisePathWithoutSlash( String init ) { 101 | String path = init.Replace( '\\', '/' ); 102 | while ( path.Length > 0 && path[ path.Length - 1 ] == '/' ) { 103 | path = path.Remove( path.Length - 1 ); 104 | } 105 | return path; 106 | } 107 | 108 | public static String RemoveExtension( String fullName ) { 109 | int dot = fullName.LastIndexOf( '.' ); 110 | if ( dot != -1 ) { 111 | return fullName.Substring( 0, dot ); 112 | } else { 113 | return fullName; 114 | } 115 | } 116 | 117 | public static void SplitBaseFilename( String fullName, out String outBasename, out String outExtention ) { 118 | int i = fullName.LastIndexOf( '.' ); 119 | if ( i == -1 ) { 120 | outExtention = String.Empty; 121 | outBasename = fullName; 122 | } else { 123 | outExtention = fullName.Substring( i + 1 ); 124 | outBasename = fullName.Substring( 0, i ); 125 | } 126 | } 127 | 128 | public static String SafeFormat( String format, T arg ) { 129 | if ( format != null ) { 130 | try { 131 | return String.Format( format, arg ); 132 | } catch ( Exception e ) { 133 | UDebug.LogException( e ); 134 | } 135 | } 136 | return String.Empty; 137 | } 138 | 139 | public static String SafeFormat( String format, T1 arg1, T2 arg2 ) { 140 | if ( format != null ) { 141 | try { 142 | return String.Format( format, arg1, arg2 ); 143 | } catch ( Exception e ) { 144 | UDebug.LogException( e ); 145 | } 146 | } 147 | return String.Empty; 148 | } 149 | 150 | public static String SafeFormat( String format, T1 arg1, T2 arg2, T3 arg3 ) { 151 | if ( format != null ) { 152 | try { 153 | return String.Format( format, arg1, arg2, arg3 ); 154 | } catch ( Exception e ) { 155 | UDebug.LogException( e ); 156 | } 157 | } 158 | return String.Empty; 159 | } 160 | 161 | public static String SafeFormat( String format, params object[] args ) { 162 | if ( format != null && args != null ) { 163 | try { 164 | return String.Format( format, args ); 165 | } catch ( Exception e ) { 166 | Common.UDebug.LogException( e ); 167 | } 168 | } 169 | return String.Empty; 170 | } 171 | 172 | public static void SplitFullFilename( String qualifiedName, out String outBasename, out String outExtention, out String outPath ) { 173 | String fullName = String.Empty; 174 | SplitFilename( qualifiedName, out fullName, out outPath ); 175 | SplitBaseFilename( fullName, out outBasename, out outExtention ); 176 | } 177 | 178 | public static String MakeRelativePath( String workingDirectory, String fullPath ) { 179 | String result = String.Empty; 180 | int offset; 181 | // this is the easy case. The file is inside of the working directory. 182 | if ( fullPath.StartsWith( workingDirectory ) ) { 183 | return fullPath.Substring( workingDirectory.Length + 1 ); 184 | } 185 | // the hard case has to back out of the working directory 186 | String[] baseDirs = workingDirectory.Split( ':', '\\', '/' ); 187 | String[] fileDirs = fullPath.Split( ':', '\\', '/' ); 188 | 189 | // if we failed to split (empty strings?) or the drive letter does not match 190 | if ( baseDirs.Length <= 0 || fileDirs.Length <= 0 || baseDirs[ 0 ] != fileDirs[ 0 ] ) { 191 | // can't create a relative path between separate harddrives/partitions. 192 | return fullPath; 193 | } 194 | // skip all leading directories that match 195 | for ( offset = 1; offset < baseDirs.Length; offset++ ) { 196 | if ( baseDirs[ offset ] != fileDirs[ offset ] ) 197 | break; 198 | } 199 | // back out of the working directory 200 | for ( int i = 0; i < ( baseDirs.Length - offset ); i++ ) { 201 | result += "..\\"; 202 | } 203 | // step into the file path 204 | for ( int i = offset; i < fileDirs.Length - 1; i++ ) { 205 | result += fileDirs[ i ] + "\\"; 206 | } 207 | // append the file 208 | result += fileDirs[ fileDirs.Length - 1 ]; 209 | return result; 210 | } 211 | 212 | public static String FormatMemorySize( int size ) { 213 | if ( size < 1024 ) { 214 | return String.Format( "{0} B", size ); 215 | } else if ( size < 1024 * 1024 ) { 216 | return String.Format( "{0:f2} KB", size >> 10 ); 217 | } else if ( size < 1024 * 1024 * 1024 ) { 218 | return String.Format( "{0:f2} MB", size >> 20 ); 219 | } else { 220 | return String.Format( "{0:f2} GB", size >> 30 ); 221 | } 222 | } 223 | 224 | public static String FormatMemorySize( long size ) { 225 | if ( size < 1024 ) { 226 | return String.Format( "{0} B", size ); 227 | } else if ( size < 1024 * 1024 ) { 228 | return String.Format( "{0:f2} KB", size >> 10 ); 229 | } else if ( size < 1024 * 1024 * 1024 ) { 230 | return String.Format( "{0:f2} MB", size >> 20 ); 231 | } else if ( size < 1024L * 1024 * 1024 * 1024 ) { 232 | return String.Format( "{0:f2} GB", size >> 30 ); 233 | } else { 234 | return String.Format( "{0:f2} TB", size >> 40 ); 235 | } 236 | } 237 | } 238 | } 239 | -------------------------------------------------------------------------------- /Assets/Editor/Common/StringUtils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 750a97cb4e0927f4481fc517fbfb80d1 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/Common/UnityLogFile.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c3d697ef15e4528438d534393a7ca9a7 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/Common/Utils.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading; 6 | using System.IO; 7 | using System.Reflection; 8 | using System.Diagnostics; 9 | using System.Runtime.InteropServices; 10 | 11 | namespace Common { 12 | 13 | public static class Utils { 14 | 15 | static DateTime _epoch = new DateTime( 1970, 1, 1, 0, 0, 0, DateTimeKind.Utc ); 16 | static long _epochTicks = _epoch.Ticks; 17 | static Stopwatch _globalTimer = new Stopwatch(); 18 | static long _startupTicksMS = NowUnixTimeMS(); 19 | 20 | static Utils() { 21 | _startupTicksMS = NowUnixTimeMS(); 22 | _globalTimer.Start(); 23 | ULogFile.sharedInstance.Log( "System Global Timer Started: {0}/ticks <=> {1}, IsHighResolution = {2}, Frequency = {3}", 24 | _startupTicksMS, 25 | UnixTimeMSToDateTime( _startupTicksMS ), 26 | Stopwatch.IsHighResolution, 27 | Stopwatch.Frequency 28 | ); 29 | } 30 | 31 | public static int GetSystemTicksMS() { 32 | // TickCount cycles between Int32.MinValue, which is a negative 33 | // number, and Int32.MaxValue once every 49.8 days. This sample 34 | // removes the sign bit to yield a nonnegative number that cycles 35 | // between zero and Int32.MaxValue once every 24.9 days. 36 | return ( int )_globalTimer.ElapsedMilliseconds; 37 | } 38 | 39 | public static long GetSystemTicksMS64() { 40 | return _globalTimer.ElapsedMilliseconds; 41 | } 42 | 43 | public static int GetSystemTicksSec() { 44 | return ( int )( _globalTimer.ElapsedMilliseconds / 1000 ); 45 | } 46 | 47 | public static long GetSystemTicksSec64() { 48 | return _globalTimer.ElapsedMilliseconds / 1000; 49 | } 50 | 51 | public static String GetFormatedLocalTime() { 52 | return System.DateTime.Now.ToString( "yyyy-MM-dd HH:mm:ss" ); 53 | } 54 | 55 | public static long UnixTimeMSToTicks( long ms ) { 56 | return ms * TimeSpan.TicksPerMillisecond; 57 | } 58 | 59 | public static DateTime UnixTimeTicksToDateTime( long ticks ) { 60 | return ( _epoch + new TimeSpan( ticks ) ).ToLocalTime(); 61 | } 62 | 63 | public static DateTime UnixTimeMSToDateTime( long ms ) { 64 | return UnixTimeTicksToDateTime( UnixTimeMSToTicks( ms ) ); 65 | } 66 | 67 | public static long NowUnixTimeMS() { 68 | return ( DateTime.UtcNow.Ticks - _epochTicks ) / TimeSpan.TicksPerMillisecond; 69 | } 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Assets/Editor/Common/Utils.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 52a8fe179d967604ea96f5997bd4e378 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/LightmapViewer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Text; 5 | using System.Text.RegularExpressions; 6 | using System.Linq; 7 | using UnityEditor; 8 | using UnityEngine; 9 | using System.Threading; 10 | using System.Diagnostics; 11 | 12 | namespace AresEditor.ArtistKit { 13 | 14 | public class LightmapViewer : EditorWindow { 15 | 16 | static LightmapViewer m_window = null; 17 | static Dictionary _MeshUVsCache = null; 18 | static Dictionary _LightmapUVBoundsCache = null; 19 | 20 | List> _litmapUVs = null; 21 | 22 | [MenuItem( "Tools/LightmapViewer" )] 23 | static void Init() { 24 | if ( m_window == null ) { 25 | m_window = ( LightmapViewer )EditorWindow.GetWindow( typeof( LightmapViewer ), false, "Lightmap Viewer" ); 26 | } 27 | m_window.minSize = new Vector2( 400, 300 ); 28 | m_window.position = new Rect( 0, 0, m_window.minSize.x, m_window.minSize.y ); 29 | m_window.Show(); 30 | } 31 | 32 | void OnEnable() { 33 | Selection.selectionChanged += OnSelectionChanged; 34 | UpdateCache(); 35 | } 36 | 37 | void OnDisable() { 38 | _litmapUVs = null; 39 | Selection.selectionChanged -= OnSelectionChanged; 40 | if ( _MeshUVsCache != null ) { 41 | _MeshUVsCache.Clear(); 42 | } 43 | if ( _LightmapUVBoundsCache != null ) { 44 | _LightmapUVBoundsCache.Clear(); 45 | } 46 | } 47 | 48 | void OnDestroy() { 49 | m_window = null; 50 | } 51 | 52 | void UpdateCache() { 53 | _MeshUVsCache = _MeshUVsCache ?? new Dictionary(); 54 | _LightmapUVBoundsCache = _LightmapUVBoundsCache ?? new Dictionary(); 55 | var objs = Selection.gameObjects; 56 | List> litmapUVs = null; 57 | for ( int i = 0; i < objs.Length; ++i ) { 58 | var rs = objs[ i ].GetComponentsInChildren(); 59 | for ( int j = 0; j < rs.Length; ++j ) { 60 | var r = rs[ j ]; 61 | if ( r != null && r.lightmapIndex >= 0 ) { 62 | Mesh m = null; 63 | if ( r is MeshRenderer ) { 64 | var mf = r.GetComponent(); 65 | if ( mf != null ) { 66 | m = mf.sharedMesh; 67 | } 68 | } else if ( r is SkinnedMeshRenderer ) { 69 | var _r = r as SkinnedMeshRenderer; 70 | m = _r.sharedMesh; 71 | } 72 | 73 | if ( m != null ) { 74 | Vector4 uvBounds; 75 | if ( !_LightmapUVBoundsCache.TryGetValue( r, out uvBounds ) ) { 76 | var uv = GetMeshUV2( m ); 77 | if ( uv != null ) { 78 | var __uv = new Vector2[ uv.Length ]; 79 | Array.Copy( uv, __uv, uv.Length ); 80 | uv = __uv; 81 | litmapUVs = litmapUVs ?? new List>(); 82 | var minx = float.MaxValue; 83 | var miny = float.MaxValue; 84 | var maxx = float.MinValue; 85 | var maxy = float.MinValue; 86 | for ( var _j = 0; _j < uv.Length; ++_j ) { 87 | uv[ _j ].x *= r.lightmapScaleOffset.x; 88 | uv[ _j ].y *= r.lightmapScaleOffset.y; 89 | uv[ _j ].x += r.lightmapScaleOffset.z; 90 | uv[ _j ].y += r.lightmapScaleOffset.w; 91 | uv[ _j ].y = 1 - uv[ _j ].y; 92 | var _uv = uv[ _j ]; 93 | if ( _uv.x < minx ) { 94 | minx = _uv.x; 95 | } 96 | if ( _uv.y < miny ) { 97 | miny = _uv.y; 98 | } 99 | if ( _uv.x > maxx ) { 100 | maxx = _uv.x; 101 | } 102 | if ( _uv.y > maxy ) { 103 | maxy = _uv.y; 104 | } 105 | } 106 | var bounds = new Vector4( minx, miny, maxx, maxy ); 107 | litmapUVs.Add( new KeyValuePair( r.lightmapIndex, bounds ) ); 108 | _LightmapUVBoundsCache.Add( r, bounds ); 109 | } 110 | } else { 111 | litmapUVs = litmapUVs ?? new List>(); 112 | litmapUVs.Add( new KeyValuePair( r.lightmapIndex, uvBounds ) ); 113 | } 114 | } 115 | } 116 | } 117 | } 118 | _litmapUVs = litmapUVs; 119 | } 120 | 121 | void OnSelectionChanged() { 122 | if ( m_window != null ) { 123 | m_window.Repaint(); 124 | UpdateCache(); 125 | } 126 | } 127 | 128 | static Vector2[] GetMeshUV2( Mesh mesh ) { 129 | Vector2[] ret = null; 130 | var assetPath = AssetDatabase.GetAssetPath( mesh ); 131 | var ti = AssetImporter.GetAtPath( assetPath ) as ModelImporter; 132 | var id = String.Format( "{0}, {1}", assetPath, mesh.GetInstanceID() ); 133 | if ( !String.IsNullOrEmpty( assetPath ) ) { 134 | if ( _MeshUVsCache.TryGetValue( id, out ret ) && ret != null ) { 135 | return ret; 136 | } 137 | if ( mesh.isReadable == false ) { 138 | if ( ti != null ) { 139 | if ( ti.isReadable ) { 140 | ret = mesh.uv2; 141 | if ( ret.Length == 0 ) { 142 | ret = mesh.uv; 143 | } 144 | } else { 145 | try { 146 | ti.isReadable = true; 147 | AssetDatabase.ImportAsset( assetPath ); 148 | ret = mesh.uv2; 149 | if ( ret.Length == 0 ) { 150 | ret = mesh.uv; 151 | } 152 | } finally { 153 | ti.isReadable = false; 154 | AssetDatabase.ImportAsset( assetPath ); 155 | } 156 | } 157 | } 158 | } else { 159 | ret = mesh.uv2; 160 | if ( ret.Length == 0 ) { 161 | ret = mesh.uv; 162 | } 163 | } 164 | _MeshUVsCache[ id ] = ret; 165 | } 166 | return ret; 167 | } 168 | 169 | Rect OnGUI_Lightmap() { 170 | Rect selectRect = new Rect(); 171 | var lightmaps = LightmapSettings.lightmaps; 172 | if ( lightmaps != null && lightmaps.Length > 0 ) { 173 | EditorGUILayout.BeginVertical(); 174 | EditorGUILayout.LabelField( "" ); 175 | var width = 0.0f; 176 | var height = 0.0f; 177 | if ( Event.current.type == EventType.Repaint ) { 178 | var rt = GUILayoutUtility.GetLastRect(); 179 | var x = rt.x; 180 | var y = rt.y; 181 | var gap = 4; 182 | var border = x; 183 | width = border * 2; 184 | height = y + border; 185 | var maxTexHeight = 0; 186 | for ( int i = 0; i < lightmaps.Length; ++i ) { 187 | if ( i > 0 ) { 188 | width += gap; 189 | x += gap; 190 | } 191 | var m = lightmaps[ i ]; 192 | var t = m.lightmapLight; 193 | var t_width = t.width; 194 | var t_height = t.height; 195 | if ( t_width > 512 ) { 196 | t_width >>= 1; 197 | } 198 | if ( t_height > 512 ) { 199 | t_height >>= 1; 200 | } 201 | if ( t_height > maxTexHeight ) { 202 | maxTexHeight = t_height; 203 | } 204 | if ( t != null ) { 205 | EditorGUI.DrawPreviewTexture( new Rect( x, y, t_width, t_height ), t ); 206 | if ( _litmapUVs != null ) { 207 | for ( int j = 0; j < _litmapUVs.Count; ++j ) { 208 | var uv = _litmapUVs[ j ]; 209 | if ( uv.Key == i ) { 210 | var bounds = uv.Value; 211 | var a = Mathf.FloorToInt( x + bounds.x * t_width ); 212 | var b = Mathf.FloorToInt( y + bounds.y * t_height ); 213 | var c = Mathf.CeilToInt( ( bounds.z - bounds.x ) * t_width ); 214 | var d = Mathf.CeilToInt( ( bounds.w - bounds.y ) * t_height ); 215 | var color = Color.red; 216 | var _color = GUI.color; 217 | var rect = new Rect( a, b, c, d ); 218 | var mouseOvered = rect.Contains( Event.current.mousePosition ); 219 | color = mouseOvered ? Color.green : Color.red; 220 | color.a = mouseOvered ? 0.0f : 0.5f; 221 | GUI.color = color; 222 | EditorGUI.DrawTextureAlpha( new Rect( a, b, c, d ), Texture2D.whiteTexture, ScaleMode.StretchToFill ); 223 | color = mouseOvered ? Color.green : Color.red; 224 | color.a = mouseOvered ? 0.5f : 0.0f; 225 | if ( mouseOvered ) { 226 | selectRect = new Rect( a, b, c, d ); 227 | } 228 | GUI.color = color; 229 | EditorGUI.DrawRect( new Rect( a - 1, b - 1, c + 2, 1 ), color ); 230 | EditorGUI.DrawRect( new Rect( a - 1, b, 1, d ), color ); 231 | EditorGUI.DrawRect( new Rect( a - 1, b + d, c + 2, 1 ), color ); 232 | EditorGUI.DrawRect( new Rect( a + c, b, 1, d ), color ); 233 | GUI.color = _color; 234 | } 235 | } 236 | } 237 | width += t_width; 238 | x += t_width; 239 | } 240 | } 241 | height += maxTexHeight; 242 | if ( m_window != null ) { 243 | var size = m_window.minSize; 244 | if ( width > size.x ) { 245 | size.x = width; 246 | } 247 | if ( height > size.y ) { 248 | size.y = height; 249 | } 250 | m_window.minSize = size; 251 | } 252 | } 253 | EditorGUILayout.LabelField( 254 | String.Format( "PixelRect: ( {0}, {1}, {2}, {3} )", 255 | selectRect.x, selectRect.y, selectRect.width, selectRect.height ) 256 | ); 257 | EditorGUILayout.EndVertical(); 258 | } 259 | return selectRect; 260 | } 261 | 262 | void OnGUI() { 263 | EditorGUILayout.BeginVertical(); 264 | EditorGUILayout.Space(); 265 | EditorGUILayout.BeginHorizontal(); 266 | EditorGUILayout.ObjectField( "Current Selected:", Selection.activeGameObject, typeof( GameObject ), true ); 267 | EditorGUILayout.EndHorizontal(); 268 | EditorGUILayout.Space(); 269 | OnGUI_Lightmap(); 270 | EditorGUILayout.Space(); 271 | EditorGUILayout.EndVertical(); 272 | } 273 | } 274 | } 275 | -------------------------------------------------------------------------------- /Assets/Editor/LightmapViewer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0ca11ebb00bad8c4b89285cca5c0f3a5 3 | timeCreated: 1510191918 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Editor/MaterialCleaner.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using System.Text; 4 | using System.IO; 5 | using System; 6 | using UnityEngine; 7 | using UnityEditor; 8 | 9 | static class MaterialCleaner { 10 | 11 | public static bool ClearMaterialAsset( Material m ) { 12 | if ( m == null ) { 13 | return false; 14 | } 15 | var path = AssetDatabase.GetAssetPath( m ); 16 | if ( String.IsNullOrEmpty( path ) ) { 17 | return false; 18 | } 19 | var deps = AssetDatabase.GetDependencies( new String[] { path } ); 20 | var deps_textures = deps.Where( s => IsTextureAsset( s ) ).ToList(); 21 | var used_textures = new HashSet(); 22 | var shader = m.shader; 23 | var newMat = new Material( shader ); 24 | var c = ShaderUtil.GetPropertyCount( shader ); 25 | for ( int i = 0; i < c; ++i ) { 26 | var type = ShaderUtil.GetPropertyType( shader, i ); 27 | var name = ShaderUtil.GetPropertyName( shader, i ); 28 | var value = m.GetProperty( i ); 29 | switch ( type ) { 30 | case ShaderUtil.ShaderPropertyType.Color: { 31 | newMat.SetColor( name, m.GetColor( name ) ); 32 | } 33 | break; 34 | case ShaderUtil.ShaderPropertyType.Float: { 35 | newMat.SetFloat( name, m.GetFloat( name ) ); 36 | } 37 | break; 38 | case ShaderUtil.ShaderPropertyType.Range: { 39 | newMat.SetFloat( name, ( float )value ); 40 | } 41 | break; 42 | case ShaderUtil.ShaderPropertyType.TexEnv: { 43 | newMat.SetTexture( name, ( Texture )value ); 44 | newMat.SetTextureOffset( name, m.GetTextureOffset( name ) ); 45 | newMat.SetTextureScale( name, m.GetTextureScale( name ) ); 46 | var tpath = AssetDatabase.GetAssetPath( ( Texture )value ); 47 | if ( !String.IsNullOrEmpty( tpath ) ) { 48 | used_textures.Add( tpath ); 49 | } 50 | } 51 | break; 52 | case ShaderUtil.ShaderPropertyType.Vector: { 53 | newMat.SetVector( name, ( Vector4 )value ); 54 | } 55 | break; 56 | } 57 | } 58 | bool rebuild = false; 59 | if ( used_textures.Count != deps_textures.Count ) { 60 | for ( int i = 0; i < deps_textures.Count; ++i ) { 61 | var _fn = deps_textures[ i ]; 62 | if ( !used_textures.Contains( _fn ) ) { 63 | rebuild = true; 64 | UnityEngine.Debug.LogWarning( String.Format( "unused texture: {0}", _fn ) ); 65 | } 66 | } 67 | } 68 | if ( !rebuild ) { 69 | if ( newMat != null ) { 70 | UnityEngine.Object.DestroyImmediate( newMat ); 71 | } 72 | return false; 73 | } 74 | String basePath; 75 | String fn; 76 | String ext; 77 | SplitFullFilename( path, out fn, out ext, out basePath ); 78 | var tempAssetPath = String.Format( "{0}{1}_temp.{2}", basePath, fn, ext ); 79 | var _test = AssetDatabase.LoadAllAssetsAtPath( tempAssetPath ); 80 | if ( _test != null ) { 81 | AssetDatabase.DeleteAsset( tempAssetPath ); 82 | } 83 | // create a new material to replace it latter 84 | AssetDatabase.CreateAsset( newMat, tempAssetPath ); 85 | Resources.UnloadAsset( newMat ); 86 | var tempAssetDataPath = String.Format( "{0}{1}_datatemp.bytes", basePath, fn, ext ); 87 | if ( File.Exists( tempAssetPath ) ) { 88 | // rename it to .bytes 89 | File.Copy( tempAssetPath, tempAssetDataPath, true ); 90 | // delete temp material 91 | AssetDatabase.DeleteAsset( tempAssetPath ); 92 | if ( File.Exists( tempAssetDataPath ) ) { 93 | // delete original material 94 | File.Delete( path ); 95 | // replace original material with .bytes file 96 | File.Copy( tempAssetDataPath, path, true ); 97 | // remove bytes file 98 | File.Delete( tempAssetDataPath ); 99 | AssetDatabase.Refresh(); 100 | // make sure the temp file has been removed correctly 101 | if ( File.Exists( tempAssetDataPath ) ) { 102 | UnityEngine.Debug.Log( String.Format( "AssetDatabase.DeleteAsset failed: {0}", tempAssetDataPath ) ); 103 | File.Delete( tempAssetDataPath ); 104 | AssetDatabase.Refresh(); 105 | return true; 106 | } 107 | } 108 | } 109 | return false; 110 | } 111 | 112 | static void SplitFilename( String qualifiedName, out String outBasename, out String outPath ) { 113 | String path = qualifiedName.Replace( '\\', '/' ); 114 | int i = path.LastIndexOf( '/' ); 115 | if ( i == -1 ) { 116 | outPath = String.Empty; 117 | outBasename = qualifiedName; 118 | } else { 119 | outBasename = path.Substring( i + 1, path.Length - i - 1 ); 120 | outPath = path.Substring( 0, i + 1 ); 121 | } 122 | } 123 | 124 | static void SplitBaseFilename( String fullName, out String outBasename, out String outExtention ) { 125 | int i = fullName.LastIndexOf( '.' ); 126 | if ( i == -1 ) { 127 | outExtention = String.Empty; 128 | outBasename = fullName; 129 | } else { 130 | outExtention = fullName.Substring( i + 1 ); 131 | outBasename = fullName.Substring( 0, i ); 132 | } 133 | } 134 | 135 | static void SplitFullFilename( String qualifiedName, out String outBasename, out String outExtention, out String outPath ) { 136 | String fullName = String.Empty; 137 | SplitFilename( qualifiedName, out fullName, out outPath ); 138 | SplitBaseFilename( fullName, out outBasename, out outExtention ); 139 | } 140 | 141 | static object GetProperty( this Material material, int index ) { 142 | var name = ShaderUtil.GetPropertyName( material.shader, index ); 143 | var type = ShaderUtil.GetPropertyType( material.shader, index ); 144 | switch ( type ) { 145 | case ShaderUtil.ShaderPropertyType.Color: 146 | return material.GetColor( name ); 147 | case ShaderUtil.ShaderPropertyType.Vector: 148 | return material.GetVector( name ); 149 | case ShaderUtil.ShaderPropertyType.Range: 150 | case ShaderUtil.ShaderPropertyType.Float: 151 | return material.GetFloat( name ); 152 | case ShaderUtil.ShaderPropertyType.TexEnv: 153 | return material.GetTexture( name ); 154 | } 155 | return null; 156 | } 157 | 158 | static bool IsTextureAsset( String assetPath ) { 159 | var ext = Path.GetExtension( assetPath ).ToLower(); 160 | return ext == ".png" || 161 | ext == ".tga" || 162 | ext == ".jpg" || 163 | ext == ".bmp" || 164 | ext == ".psd" || 165 | ext == ".dds" || 166 | ext == ".exr"; 167 | } 168 | } 169 | 170 | //EOF 171 | -------------------------------------------------------------------------------- /Assets/Editor/MaterialCleaner.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4852397f54093ce4394afc7620a5be07 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/MatrixViewer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | using UnityEditor; 7 | 8 | namespace AresEditor.ArcReactor { 9 | 10 | static class MatrixViewer { 11 | 12 | enum MatrixFormula { 13 | Overall, 14 | Identity, 15 | Scale, 16 | Translate, 17 | RotateX, 18 | RotateY, 19 | RotateZ, 20 | ScaleX, 21 | ScaleY, 22 | ScaleZ, 23 | TranslateX, 24 | TranslateY, 25 | TranslateZ, 26 | } 27 | 28 | static bool _visible = true; 29 | static bool _raw_memory_layout = false; 30 | static bool _usage_tips = false; 31 | static bool _useWorldSpace = false; 32 | static MatrixFormula _formula = MatrixFormula.Overall; 33 | 34 | struct Prop { 35 | public bool editable; 36 | public Color color; 37 | public String usage; 38 | public float value; 39 | } 40 | 41 | static Prop[] _props = new Prop[ 16 ] { 42 | new Prop(){ editable = false, color = Color.red + Color.yellow, usage = "xs,cy,cz", value = 1 }, 43 | new Prop(){ editable = false, color = Color.red * 2, usage = "sz", value = 0 }, 44 | new Prop(){ editable = false, color = Color.red * 2, usage = "-sy", value = 1 }, 45 | new Prop(){ editable = false, color = Color.white, usage = "0", value = 0 }, 46 | 47 | new Prop(){ editable = false, color = Color.red * 2, usage = "-sz", value = 0 }, 48 | new Prop(){ editable = false, color = Color.red + Color.yellow, usage = "ys,cx,cz", value = 1 }, 49 | new Prop(){ editable = false, color = Color.red * 2, usage = "sx", value = 0 }, 50 | new Prop(){ editable = false, color = Color.white, usage = "0", value = 0 }, 51 | 52 | new Prop(){ editable = false, color = Color.red * 2, usage = "sy", value = 0 }, 53 | new Prop(){ editable = false, color = Color.red * 2, usage = "-sx", value = 0 }, 54 | new Prop(){ editable = false, color = Color.red + Color.yellow, usage = "zs,cx,cy", value = 1 }, 55 | new Prop(){ editable = false, color = Color.white, usage = "0", value = 0 }, 56 | 57 | new Prop(){ editable = true, color = Color.green, usage = "tx", value = 0 }, 58 | new Prop(){ editable = true, color = Color.green, usage = "ty", value = 0 }, 59 | new Prop(){ editable = true, color = Color.green, usage = "tz", value = 0 }, 60 | new Prop(){ editable = false, color = Color.white, usage = "1", value = 1 }, 61 | }; 62 | 63 | public static Action OnInspectorGUI = null; 64 | 65 | static MatrixViewer() { 66 | OnInspectorGUI = _OnInspectorGUI; 67 | } 68 | 69 | static Quaternion ExtractRotation2( ref Matrix4x4 m ) { 70 | Vector3 s = ExtractScale( ref m ); 71 | float m00 = m[ 0, 0 ] / s.x; 72 | float m01 = m[ 0, 1 ] / s.y; 73 | float m02 = m[ 0, 2 ] / s.z; 74 | float m10 = m[ 1, 0 ] / s.x; 75 | float m11 = m[ 1, 1 ] / s.y; 76 | float m12 = m[ 1, 2 ] / s.z; 77 | float m20 = m[ 2, 0 ] / s.x; 78 | float m21 = m[ 2, 1 ] / s.y; 79 | float m22 = m[ 2, 2 ] / s.z; 80 | Quaternion q = new Quaternion(); 81 | q.w = Mathf.Sqrt( Mathf.Max( 0, 1 + m00 + m11 + m22 ) ) / 2; 82 | q.x = Mathf.Sqrt( Mathf.Max( 0, 1 + m00 - m11 - m22 ) ) / 2; 83 | q.y = Mathf.Sqrt( Mathf.Max( 0, 1 - m00 + m11 - m22 ) ) / 2; 84 | q.z = Mathf.Sqrt( Mathf.Max( 0, 1 - m00 - m11 + m22 ) ) / 2; 85 | q.x *= Mathf.Sign( q.x * ( m21 - m12 ) ); 86 | q.y *= Mathf.Sign( q.y * ( m02 - m20 ) ); 87 | q.z *= Mathf.Sign( q.z * ( m10 - m01 ) ); 88 | float qMagnitude = Mathf.Sqrt( q.w * q.w + q.x * q.x + q.y * q.y + q.z * q.z ); 89 | q.w /= qMagnitude; 90 | q.x /= qMagnitude; 91 | q.y /= qMagnitude; 92 | q.z /= qMagnitude; 93 | return q; 94 | } 95 | 96 | static Vector3 QuaternionToEuler( Quaternion q ) { 97 | Vector3 result; 98 | float test = q.x * q.y + q.z * q.w; 99 | // singularity at north pole 100 | if ( test > 0.499f ) { 101 | result.x = 0; 102 | result.y = 2 * Mathf.Atan2( q.x, q.w ); 103 | result.z = Mathf.PI / 2; 104 | } else if ( test < -0.499f ) { 105 | // singularity at south pole 106 | result.x = 0; 107 | result.y = -2 * Mathf.Atan2( q.x, q.w ); 108 | result.z = -Mathf.PI / 2; 109 | } else { 110 | result.x = Mathf.Rad2Deg * Mathf.Atan2( 2 * q.x * q.w - 2 * q.y * q.z, 1 - 2 * q.x * q.x - 2 * q.z * q.z ); 111 | result.y = Mathf.Rad2Deg * Mathf.Atan2( 2 * q.y * q.w - 2 * q.x * q.z, 1 - 2 * q.y * q.y - 2 * q.z * q.z ); 112 | result.z = Mathf.Rad2Deg * Mathf.Asin( 2 * q.x * q.y + 2 * q.z * q.w ); 113 | if ( result.x < 0 ) { 114 | result.x += 360; 115 | } 116 | if ( result.y < 0 ) { 117 | result.y += 360; 118 | } 119 | if ( result.z < 0 ) { 120 | result.z += 360; 121 | } 122 | } 123 | return result; 124 | } 125 | 126 | static Quaternion ExtractRotation( ref Matrix4x4 matrix ) { 127 | Vector3 forward; 128 | forward.x = matrix.m02; 129 | forward.y = matrix.m12; 130 | forward.z = matrix.m22; 131 | Vector3 upwards; 132 | upwards.x = matrix.m01; 133 | upwards.y = matrix.m11; 134 | upwards.z = matrix.m21; 135 | return Quaternion.LookRotation( forward, upwards ); 136 | } 137 | 138 | static Vector3 ExtractPosition( ref Matrix4x4 matrix ) { 139 | Vector3 position; 140 | position.x = matrix.m03; 141 | position.y = matrix.m13; 142 | position.z = matrix.m23; 143 | return position; 144 | } 145 | 146 | static Vector3 ExtractScale( ref Matrix4x4 matrix ) { 147 | Vector3 scale; 148 | scale.x = new Vector4( matrix.m00, matrix.m10, matrix.m20, matrix.m30 ).magnitude; 149 | scale.y = new Vector4( matrix.m01, matrix.m11, matrix.m21, matrix.m31 ).magnitude; 150 | scale.z = new Vector4( matrix.m02, matrix.m12, matrix.m22, matrix.m32 ).magnitude; 151 | return scale; 152 | } 153 | 154 | static void _DrawMatrixColumnMajor( ref Matrix4x4 mat, Func> func ) { 155 | EditorGUILayout.BeginHorizontal(); 156 | var index = 0; 157 | for ( int c = 0; c < 4; ++c ) { 158 | if ( c > 0 ) { 159 | GUILayout.Box( "", GUILayout.Height( 4 * ( EditorGUIUtility.singleLineHeight ) + EditorGUIUtility.standardVerticalSpacing ), GUILayout.Width( 1 ) ); 160 | } 161 | EditorGUILayout.BeginVertical(); 162 | for ( int r = 0; r < 4; ++r ) { 163 | EditorGUILayout.BeginHorizontal(); 164 | var _enabled = GUI.enabled; 165 | GUI.enabled = false; 166 | EditorGUILayout.LabelField( String.Format( "m{0}{1}", r, c ), GUILayout.Width( 28 ) ); 167 | GUI.enabled = _props[ index ].editable; 168 | var _color = GUI.color; 169 | GUI.color = _props[ index ].color; 170 | var ret = func( index, mat[ r, c ] ); 171 | if ( ret.Key ) { 172 | mat[ r, c ] = ret.Value; 173 | } 174 | GUI.color = _color; 175 | GUI.enabled = _enabled; 176 | EditorGUILayout.EndHorizontal(); 177 | ++index; 178 | } 179 | EditorGUILayout.EndVertical(); 180 | } 181 | EditorGUILayout.EndHorizontal(); 182 | } 183 | 184 | static unsafe void _DrawMatrixRowMajor( Matrix4x4* mat, Action func ) { 185 | var index = 0; 186 | float* p = ( float* )mat; 187 | for ( int r = 0; r < 4; ++r ) { 188 | if ( r > 0 ) { 189 | GUILayout.Box( "", GUILayout.ExpandWidth( true ), GUILayout.Height( 1 ) ); 190 | } 191 | EditorGUILayout.BeginHorizontal(); 192 | for ( int c = 0; c < 4; ++c ) { 193 | var _enabled = GUI.enabled; 194 | GUI.enabled = false; 195 | EditorGUILayout.LabelField( String.Format( "{0:00}", r * 4 + c ), GUILayout.Width( 28 ) ); 196 | GUI.enabled = _props[ index ].editable; 197 | var _color = GUI.color; 198 | GUI.color = _props[ index ].color; 199 | func( index, ( IntPtr )p ); 200 | GUI.color = _color; 201 | GUI.enabled = _enabled; 202 | ++p; 203 | ++index; 204 | } 205 | EditorGUILayout.EndHorizontal(); 206 | } 207 | } 208 | 209 | static void DrawFomula( int _index ) { 210 | var usage = _props[ _index ].usage; 211 | var f = _formula.ToString(); 212 | Func charToAxisMask = c => { 213 | c = Char.ToUpper( c ); 214 | int _axisMask = 0xff; 215 | if ( c == 'X' ) { 216 | _axisMask = 1 << 0; 217 | } else if ( c == 'Y' ) { 218 | _axisMask = 1 << 1; 219 | } else if ( c == 'Z' ) { 220 | _axisMask = 1 << 2; 221 | } 222 | return _axisMask; 223 | }; 224 | var axisMask = charToAxisMask( f[ f.Length - 1 ] ); 225 | switch ( _formula ) { 226 | case MatrixFormula.Overall: 227 | EditorGUILayout.TextField( usage ); 228 | break; 229 | case MatrixFormula.Identity: 230 | EditorGUILayout.FloatField( _props[ _index ].value ); 231 | break; 232 | case MatrixFormula.RotateX: 233 | case MatrixFormula.RotateY: 234 | case MatrixFormula.RotateZ: { 235 | var _usages = usage.Split( ',' ); 236 | var found = false; 237 | for ( int i = 0; i < _usages.Length; ++i ) { 238 | var _usage = _usages[ i ]; 239 | // sin & cos tag 240 | var sign = _usage.StartsWith( "-" ) ? "-" : ""; 241 | _usage = _usage.TrimStart( '-' ); 242 | var sin = _usage.StartsWith( "s" ); 243 | var cos = _usage.StartsWith( "c" ); 244 | var axis = charToAxisMask( _usage[ _usage.Length - 1 ] ); 245 | if ( ( sin || cos ) && ( axis & axisMask ) != 0 ) { 246 | var usage_ = String.Format( "{0}{1}( {2} )", sign, sin ? "sin" : "cos", _usage[ _usage.Length - 1 ] ); 247 | EditorGUILayout.TextField( usage_ ); 248 | found = true; 249 | break; 250 | } 251 | } 252 | if ( !found ) { 253 | EditorGUILayout.FloatField( _props[ _index ].value ); 254 | } 255 | } 256 | break; 257 | case MatrixFormula.Scale: 258 | case MatrixFormula.ScaleX: 259 | case MatrixFormula.ScaleY: 260 | case MatrixFormula.ScaleZ: { 261 | var _usages = usage.Split( ',' ); 262 | var found = false; 263 | for ( int i = 0; i < _usages.Length; ++i ) { 264 | var _usage = _usages[ i ]; 265 | if ( _usage.EndsWith( "s" ) ) { 266 | var tag = Char.ToUpper( _usage[ 0 ] ); 267 | var mask = charToAxisMask( tag ); 268 | if ( ( axisMask & mask ) != 0 ) { 269 | var usage_ = String.Format( "scale{0}", tag ); 270 | EditorGUILayout.TextField( usage_ ); 271 | found = true; 272 | break; 273 | } 274 | } 275 | } 276 | if ( !found ) { 277 | EditorGUILayout.FloatField( _props[ _index ].value ); 278 | } 279 | } 280 | break; 281 | case MatrixFormula.Translate: 282 | case MatrixFormula.TranslateX: 283 | case MatrixFormula.TranslateY: 284 | case MatrixFormula.TranslateZ: { 285 | var _usage = String.Empty; 286 | if ( usage.StartsWith( "t" ) ) { 287 | var tag = Char.ToUpper( usage[ usage.Length - 1 ] ); 288 | var mask = charToAxisMask( tag ); 289 | if ( ( axisMask & mask ) != 0 ) { 290 | _usage = String.Format( "trans{0}", tag ); 291 | } 292 | } 293 | if ( !String.IsNullOrEmpty( _usage ) ) { 294 | EditorGUILayout.TextField( _usage ); 295 | } else { 296 | EditorGUILayout.FloatField( _props[ _index ].value ); 297 | } 298 | } 299 | break; 300 | } 301 | } 302 | 303 | static unsafe Matrix4x4 DrawMatrix( Matrix4x4 mat ) { 304 | EditorGUILayout.BeginVertical(); 305 | EditorGUILayout.Separator(); 306 | _useWorldSpace = EditorGUILayout.ToggleLeft( "World Space", _useWorldSpace ); 307 | _raw_memory_layout = EditorGUILayout.ToggleLeft( "Memory Layout Mode", _raw_memory_layout ); 308 | EditorGUILayout.Separator(); 309 | 310 | var labelWidth = EditorGUIUtility.labelWidth; 311 | try { 312 | EditorGUIUtility.labelWidth = 24; 313 | if ( !_raw_memory_layout ) { 314 | _DrawMatrixColumnMajor( 315 | ref mat, 316 | ( _index, v ) => new KeyValuePair( true, EditorGUILayout.FloatField( v ) ) 317 | ); 318 | EditorGUILayout.Separator(); 319 | _usage_tips = EditorGUILayout.ToggleLeft( "Usage Tips", _usage_tips ); 320 | if ( _usage_tips ) { 321 | EditorGUILayout.Separator(); 322 | _formula = ( MatrixFormula )EditorGUILayout.EnumPopup( _formula ); 323 | EditorGUILayout.Separator(); 324 | _DrawMatrixColumnMajor( 325 | ref mat, 326 | ( _index, v ) => { 327 | DrawFomula( _index ); 328 | return new KeyValuePair( false, 0.0f ); 329 | } 330 | ); 331 | } 332 | } else { 333 | float* p = ( float* )&mat; 334 | _DrawMatrixRowMajor( 335 | &mat, 336 | ( _index, ptr ) => { 337 | float* _p = ( float* )ptr; 338 | *_p = EditorGUILayout.FloatField( *_p ); 339 | } 340 | ); 341 | EditorGUILayout.Separator(); 342 | _usage_tips = EditorGUILayout.ToggleLeft( "Usage Tips", _usage_tips ); 343 | if ( _usage_tips ) { 344 | EditorGUILayout.Separator(); 345 | _formula = ( MatrixFormula )EditorGUILayout.EnumPopup( _formula ); 346 | EditorGUILayout.Separator(); 347 | _DrawMatrixRowMajor( &mat, ( _index, ptr ) => DrawFomula( _index ) ); 348 | } 349 | } 350 | } finally { 351 | EditorGUIUtility.labelWidth = labelWidth; 352 | GUI.enabled = true; 353 | } 354 | EditorGUILayout.Separator(); 355 | EditorGUILayout.EndVertical(); 356 | return mat; 357 | } 358 | 359 | static void _OnInspectorGUI( Transform target ) { 360 | Transform transform = target; 361 | if ( transform != null ) { 362 | if ( _useWorldSpace ) { 363 | var mat = transform.localToWorldMatrix; 364 | var newMat = DrawMatrix( mat ); 365 | if ( newMat != mat ) { 366 | Undo.RecordObject( transform, "Assign From Matrix Viewer" ); 367 | transform.rotation = ExtractRotation( ref newMat ); 368 | transform.position = ExtractPosition( ref newMat ); 369 | } 370 | } else { 371 | var mat = Matrix4x4.TRS( transform.localPosition, transform.localRotation, transform.localScale ); 372 | var newMat = DrawMatrix( mat ); 373 | if ( newMat != mat ) { 374 | Undo.RecordObject( transform, "Assign From Matrix Viewer" ); 375 | transform.localScale = ExtractScale( ref newMat ); 376 | transform.localRotation = ExtractRotation( ref newMat ); 377 | transform.localPosition = ExtractPosition( ref newMat ); 378 | } 379 | } 380 | } 381 | } 382 | } 383 | 384 | class MatrixViewerWindow : EditorWindow { 385 | 386 | static MatrixViewerWindow m_window = null; 387 | 388 | [MenuItem( "Tools/MatrixViewer" )] 389 | static void Init() { 390 | if ( m_window == null ) { 391 | m_window = EditorWindow.GetWindow( "Matrix Viewer", true, typeof( EditorWindow ) ); 392 | } 393 | m_window.minSize = new Vector2( 400, 320 ); 394 | m_window.Show(); 395 | } 396 | 397 | void OnEnable() { 398 | EditorApplication.update += _Repaint; 399 | } 400 | 401 | void OnDisable() { 402 | EditorApplication.update -= _Repaint; 403 | } 404 | 405 | void _Repaint() { 406 | Repaint(); 407 | } 408 | 409 | void OnGUI() { 410 | var go = Selection.activeGameObject; 411 | if ( go != null ) { 412 | MatrixViewer.OnInspectorGUI( go.transform ); 413 | } 414 | } 415 | 416 | void OnDestroy() { 417 | m_window = null; 418 | } 419 | } 420 | } 421 | -------------------------------------------------------------------------------- /Assets/Editor/MatrixViewer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 270237e7936efa34190f740c78929f5f 3 | timeCreated: 1510053305 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Editor/MenuShortcutsWindow.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.IO; 6 | using UnityEngine; 7 | using UnityEditor; 8 | using System.Diagnostics; 9 | using System.Text.RegularExpressions; 10 | using System.Runtime.CompilerServices; 11 | using System.Reflection; 12 | 13 | public class MenuShortcutsWindow : EditorWindow { 14 | 15 | enum Page { 16 | Shortcuts, 17 | All 18 | } 19 | 20 | class MenuItemData { 21 | static Char[] separator = new Char[] { '/', ' ' }; 22 | public String menuItemPath = String.Empty; 23 | public String name = String.Empty; 24 | public String[] keywords = null; 25 | public String assemblyName = String.Empty; 26 | public void Init() { 27 | name = Path.GetFileNameWithoutExtension( menuItemPath ); 28 | keywords = menuItemPath.Split( separator, StringSplitOptions.RemoveEmptyEntries ); 29 | } 30 | } 31 | 32 | static MenuShortcutsWindow s_window = null; 33 | static SceneView.OnSceneFunc s_OnSceneGUI = null; 34 | static EditorApplication.CallbackFunction s_OnEditorWindowUpdate = null; 35 | 36 | static SortedDictionary s_allMenuItems = new SortedDictionary(); 37 | static SortedDictionary s_shortcuts = new SortedDictionary(); 38 | static Vector2 s_scrollViewPos = Vector2.zero; 39 | static Vector2 s_shortcutsViewPos = Vector2.zero; 40 | static String s_search = String.Empty; 41 | static List s_assemblies = new List(); 42 | static Page s_page = Page.Shortcuts; 43 | 44 | [MenuItem( "Window/ShortcutWindow", false, 100 )] 45 | static void Init() { 46 | if ( s_window == null ) { 47 | s_window = ScriptableObject.CreateInstance(); 48 | s_window.titleContent = new GUIContent( "Shortcuts" ); 49 | CheckInitAllMenuItems(); 50 | } 51 | if ( s_shortcuts.Count == 0 ) { 52 | s_page = Page.All; 53 | } else { 54 | s_page = Page.Shortcuts; 55 | } 56 | s_window.Show(); 57 | s_OnSceneGUI = OnSceneGUI; 58 | s_OnEditorWindowUpdate = OnEditorWindowUpdate; 59 | EditorApplication.update += s_OnEditorWindowUpdate; 60 | SceneView.onSceneGUIDelegate += s_OnSceneGUI; 61 | } 62 | 63 | static void CheckInitAllMenuItems() { 64 | if ( s_allMenuItems == null || s_allMenuItems.Count == 0 ) { 65 | var items = SearchAllMenuItems(); 66 | s_allMenuItems = s_allMenuItems ?? new SortedDictionary(); 67 | s_allMenuItems.Clear(); 68 | var assemblies = new HashSet(); 69 | for ( int i = 0; i < items.Count; ++i ) { 70 | var item = new MenuItemData(); 71 | var assemblyName = items[ i ].Value; 72 | assemblies.Add( assemblyName ); 73 | s_allMenuItems.Add( items[ i ].Key, item ); 74 | item.menuItemPath = items[ i ].Key; 75 | item.Init(); 76 | } 77 | s_assemblies = assemblies.ToList(); 78 | s_assemblies.Sort(); 79 | Load(); 80 | } 81 | } 82 | 83 | static void Load() { 84 | s_search = EditorPrefs.GetString( "MenuShortcutsWindow-search", String.Empty ); 85 | s_shortcuts.Clear(); 86 | var shortcuts = EditorPrefs.GetString( "MenuShortcutsWindow-shortcuts", String.Empty ).Split( ';' ); 87 | if ( shortcuts.Length > 0 ) { 88 | for ( int i = 0; i < shortcuts.Length; ++i ) { 89 | MenuItemData item; 90 | if ( s_allMenuItems.TryGetValue( shortcuts[ i ], out item ) && item != null ) { 91 | s_shortcuts.Add( shortcuts[ i ], item ); 92 | } 93 | } 94 | } 95 | if ( s_shortcuts.Count == 0 ) { 96 | s_page = Page.All; 97 | } else { 98 | s_page = Page.Shortcuts; 99 | } 100 | } 101 | 102 | static void Save() { 103 | if ( s_shortcuts != null && s_shortcuts.Count > 0 ) { 104 | var values = s_shortcuts.Keys.ToArray(); 105 | Array.Sort( values ); 106 | EditorPrefs.SetString( "MenuShortcutsWindow-shortcuts", String.Join( ";", values ) ); 107 | } else { 108 | EditorPrefs.DeleteKey( "MenuShortcutsWindow-shortcuts" ); 109 | } 110 | if ( !String.IsNullOrEmpty( s_search ) ) { 111 | EditorPrefs.SetString( "MenuShortcutsWindow-search", s_search ); 112 | } else { 113 | EditorPrefs.DeleteKey( "MenuShortcutsWindow-search" ); 114 | } 115 | } 116 | 117 | static List> SearchAllMenuItems() { 118 | var ret = new List>(); 119 | var set = new HashSet(); 120 | var assemblies = AppDomain.CurrentDomain.GetAssemblies(); 121 | for ( int i = 0; i < assemblies.Length; ++i ) { 122 | var types = assemblies[ i ].GetTypes(); 123 | var assemblyName = assemblies[ i ].GetName().Name; 124 | for ( int j = 0; j < types.Length; ++j ) { 125 | var methods = types[ j ].GetMethods( BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic ); 126 | for ( int n = 0; n < methods.Length; ++n ) { 127 | var attrs = methods[ n ].GetCustomAttributes( typeof( MenuItem ), false ); 128 | if ( attrs.Length > 0 ) { 129 | for ( int m = 0; m < attrs.Length; ++m ) { 130 | var attr = attrs[ m ] as MenuItem; 131 | if ( !String.IsNullOrEmpty( attr.menuItem ) ) { 132 | if ( set.Add( attr.menuItem ) ) { 133 | ret.Add( new KeyValuePair( attr.menuItem, assemblyName ) ); 134 | } 135 | } 136 | } 137 | } 138 | } 139 | } 140 | } 141 | return ret; 142 | } 143 | 144 | void OnDestroy() { 145 | Save(); 146 | s_window = null; 147 | SceneView.onSceneGUIDelegate -= s_OnSceneGUI; 148 | EditorApplication.update -= s_OnEditorWindowUpdate; 149 | s_OnSceneGUI = null; 150 | s_OnEditorWindowUpdate = null; 151 | } 152 | 153 | void OnSelectionChange() { 154 | Repaint(); 155 | } 156 | 157 | static void OnEditorWindowUpdate() { 158 | } 159 | 160 | static void OnSceneGUI( SceneView sceneview ) { 161 | } 162 | 163 | static void Clear() { 164 | s_search = String.Empty; 165 | s_shortcuts.Clear(); 166 | Save(); 167 | } 168 | 169 | static void OnGUI_Shortcuts() { 170 | s_shortcutsViewPos = EditorGUILayout.BeginScrollView( s_shortcutsViewPos ); 171 | List removeKeys = null; 172 | foreach ( var kv in s_shortcuts ) { 173 | EditorGUILayout.BeginHorizontal(); 174 | EditorGUILayout.TextField( kv.Value.name ); 175 | GUI.color = Color.red; 176 | if ( GUILayout.Button( "-", GUILayout.Width( 20 ) ) ) { 177 | removeKeys = removeKeys ?? new List(); 178 | removeKeys.Add( kv.Key ); 179 | } 180 | GUI.color = Color.green; 181 | if ( GUILayout.Button( "Excute", GUILayout.Width( 60 ) ) ) { 182 | EditorApplication.ExecuteMenuItem( kv.Key ); 183 | } 184 | GUI.color = Color.white; 185 | EditorGUILayout.EndHorizontal(); 186 | } 187 | if ( removeKeys != null ) { 188 | for ( int i = 0; i < removeKeys.Count; ++i ) { 189 | s_shortcuts.Remove( removeKeys[ i ] ); 190 | } 191 | Save(); 192 | } 193 | EditorGUILayout.EndScrollView(); 194 | if ( GUILayout.Button( "Clear" ) ) { 195 | Clear(); 196 | } 197 | } 198 | 199 | static void OnGUI_ShowAll() { 200 | s_scrollViewPos = EditorGUILayout.BeginScrollView( s_scrollViewPos ); 201 | var changed = false; 202 | foreach ( var kv in s_allMenuItems ) { 203 | if ( !String.IsNullOrEmpty( s_search ) && !kv.Key.StartsWith( s_search ) ) { 204 | continue; 205 | } 206 | EditorGUILayout.BeginHorizontal(); 207 | EditorGUILayout.TextField( kv.Key ); 208 | if ( s_shortcuts.ContainsKey( kv.Key ) ) { 209 | GUI.color = Color.red; 210 | if ( GUILayout.Button( "-", GUILayout.Width( 20 ) ) ) { 211 | s_shortcuts.Remove( kv.Key ); 212 | changed = true; 213 | } 214 | } else { 215 | GUI.color = Color.green; 216 | if ( GUILayout.Button( "+", GUILayout.Width( 20 ) ) ) { 217 | s_shortcuts.Add( kv.Key, kv.Value ); 218 | changed = true; 219 | } 220 | } 221 | GUI.color = Color.white; 222 | if ( GUILayout.Button( "Excute", GUILayout.Width( 60 ) ) ) { 223 | EditorApplication.ExecuteMenuItem( kv.Key ); 224 | } 225 | EditorGUILayout.EndHorizontal(); 226 | } 227 | EditorGUILayout.EndScrollView(); 228 | if ( changed ) { 229 | Save(); 230 | } 231 | } 232 | 233 | void OnGUI() { 234 | CheckInitAllMenuItems(); 235 | EditorGUILayout.BeginVertical(); 236 | EditorGUIUtility.labelWidth = 32; 237 | s_search = EditorGUILayout.TextField( "Find", s_search ); 238 | if ( s_search.StartsWith( " " ) ) { 239 | var search = s_search.TrimStart( ' ' ); 240 | if ( String.IsNullOrEmpty( search ) ) { 241 | s_search = String.Empty; 242 | } 243 | } 244 | 245 | s_page = ( Page )GUILayout.Toolbar( ( int )s_page, Enum.GetNames( typeof( Page ) ) ); 246 | switch ( s_page ) { 247 | case Page.Shortcuts: 248 | OnGUI_Shortcuts(); 249 | break; 250 | case Page.All: 251 | OnGUI_ShowAll(); 252 | break; 253 | } 254 | EditorGUILayout.EndVertical(); 255 | } 256 | } 257 | -------------------------------------------------------------------------------- /Assets/Editor/MonoScriptDumper.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d5617b59b01a75428b477b88955fa89 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Editor/MonoScriptDumper/MonoScriptDumper.cs: -------------------------------------------------------------------------------- 1 | #if UNITY_EDITOR 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Reflection; 6 | using System.Text; 7 | using UnityEditor; 8 | using UnityEngine; 9 | using CSharpExtensions; 10 | 11 | namespace CSharpExtensions { 12 | public static class TypeExtensions { 13 | public static string ToGenericTypeString( this Type t ) { 14 | if ( !t.IsGenericType ) 15 | return t.Name; 16 | string genericTypeName = t.GetGenericTypeDefinition().Name; 17 | genericTypeName = genericTypeName.Substring( 0, 18 | genericTypeName.IndexOf( '`' ) ); 19 | string genericArgs = string.Join( ",", 20 | t.GetGenericArguments() 21 | .Select( ta => ToGenericTypeString( ta ) ).ToArray() ); 22 | return genericTypeName + "<" + genericArgs + ">"; 23 | } 24 | } 25 | } 26 | 27 | public static class MonoScriptDumper { 28 | 29 | static Type[] BaseTypes = { 30 | typeof( bool ), 31 | typeof( byte ), 32 | typeof( sbyte ), 33 | typeof( short ), 34 | typeof( ushort ), 35 | typeof( int ), 36 | typeof( uint ), 37 | typeof( long ), 38 | typeof( ulong ), 39 | typeof( float ), 40 | typeof( double ), 41 | typeof( decimal ), 42 | typeof( string ), 43 | }; 44 | 45 | static Dictionary typeAlias = new Dictionary(); 46 | static HashSet BaseTypeSet = new HashSet(); 47 | static Dictionary dumpCache = new Dictionary(); 48 | static object locker = new object(); 49 | 50 | static MonoScriptDumper() { 51 | for ( var i = 0; i < BaseTypes.Length; ++i ) { 52 | BaseTypeSet.Add( BaseTypes[ i ] ); 53 | } 54 | 55 | typeAlias[ typeof( bool ) ] = "bool"; 56 | typeAlias[ typeof( byte ) ] = "byte"; 57 | typeAlias[ typeof( sbyte ) ] = "sbyte"; 58 | typeAlias[ typeof( byte ) ] = "byte"; 59 | typeAlias[ typeof( short ) ] = "short"; 60 | typeAlias[ typeof( ushort ) ] = "ushort"; 61 | typeAlias[ typeof( int ) ] = "int"; 62 | typeAlias[ typeof( uint ) ] = "uint"; 63 | typeAlias[ typeof( long ) ] = "long"; 64 | typeAlias[ typeof( ulong ) ] = "ulong"; 65 | typeAlias[ typeof( float ) ] = "float"; 66 | typeAlias[ typeof( double ) ] = "double"; 67 | typeAlias[ typeof( decimal ) ] = "decimal"; 68 | typeAlias[ typeof( string ) ] = "string"; 69 | } 70 | 71 | static String GetAlias( Type t ) { 72 | String o; 73 | if ( typeAlias.TryGetValue( t, out o ) ) { 74 | return o; 75 | } 76 | if ( t.Namespace == "UnityEngine" ) { 77 | return t.Name; 78 | } 79 | return t.FullName; 80 | } 81 | 82 | static bool DumpType( Type ftype, String name, out String prettyTypeName, int indent = 0, HashSet customTypes = null, bool isRoot = false ) { 83 | customTypes = customTypes ?? new HashSet(); 84 | prettyTypeName = String.Empty; 85 | if ( typeof( Delegate ).IsAssignableFrom( ftype ) ) { 86 | return false; 87 | } 88 | if ( BaseTypeSet.Contains( ftype ) || 89 | ftype.IsEnum ) { 90 | prettyTypeName = String.Format( "{0}{1} {2}\n", 91 | new String( '\t', indent ), 92 | GetAlias( ftype ), name ); 93 | return true; 94 | } else if ( ftype.IsArray ) { 95 | var et = ftype.GetElementType(); 96 | if ( et != null ) { 97 | var pname = String.Empty; 98 | if ( DumpType( et, "", out pname, indent + 1, customTypes ) ) { 99 | prettyTypeName = String.Format( "{0}{1}[] {2}\n", 100 | new String( '\t', indent ), 101 | GetAlias( et ), name ); 102 | if ( !BaseTypeSet.Contains( et ) && et.IsEnum == false ) { 103 | prettyTypeName = prettyTypeName + pname; 104 | } 105 | return true; 106 | } 107 | } 108 | } else if ( ftype.IsGenericType ) { 109 | var listType = typeof( List<> ); 110 | var gargs = ftype.GetGenericArguments(); 111 | if ( gargs.Length == 1 ) { 112 | if ( ftype == listType.MakeGenericType( gargs ) ) { 113 | var pname = String.Empty; 114 | if ( DumpType( gargs[ 0 ], "T", out pname, indent + 1, customTypes ) ) { 115 | prettyTypeName = String.Format( "{0}List<{1}> {2}\n", 116 | new String( '\t', indent ), 117 | GetAlias( gargs[ 0 ] ), name ); 118 | if ( !BaseTypeSet.Contains( gargs[ 0 ] ) && gargs[ 0 ].IsEnum == false ) { 119 | prettyTypeName = prettyTypeName + pname; 120 | } 121 | return true; 122 | } 123 | } 124 | } 125 | } else if ( !isRoot && typeof( UnityEngine.Object ).IsAssignableFrom( ftype ) ) { 126 | // unity's object will be serialized as a pointer/GUID 127 | prettyTypeName = String.Format( "{0}{1} {2}\n", 128 | new String( '\t', indent ), 129 | GetAlias( ftype ), name ); 130 | return true; 131 | } else if ( ftype.IsClass || ( ftype.IsValueType && !ftype.IsEnum ) ) { 132 | if ( !ftype.IsEnum ) { 133 | var attrs = System.Attribute.GetCustomAttributes( ftype ); 134 | var nserTag = Array.FindIndex( attrs, a => a is SerializableAttribute ); 135 | if ( ftype.IsClass && nserTag == -1 && !typeof( UnityEngine.Object ).IsAssignableFrom( ftype ) ) { 136 | return false; 137 | } 138 | } 139 | prettyTypeName = String.Format( "{0}{1} {2}\n", 140 | new String( '\t', indent ), 141 | GetAlias( ftype ), name ); 142 | FieldInfo[] fields = null; 143 | if ( !customTypes.Contains( ftype ) ) { 144 | fields = ftype.GetFields( 145 | BindingFlags.Instance | 146 | BindingFlags.NonPublic | 147 | BindingFlags.Public | 148 | BindingFlags.FlattenHierarchy ); 149 | customTypes.Add( ftype ); 150 | } 151 | if ( fields != null && fields.Length > 0 ) { 152 | var sb = new StringBuilder(); 153 | for ( int i = 0; i < fields.Length; ++i ) { 154 | var fi = fields[ i ]; 155 | var _ftype = fi.FieldType; 156 | var attrs = Attribute.GetCustomAttributes( fi ); 157 | var nserTag = Array.FindIndex( attrs, a => a is NonSerializedAttribute ); 158 | if ( nserTag != -1 ) { 159 | continue; 160 | } 161 | var serTag = Array.FindIndex( attrs, a => a is SerializeField ); 162 | if ( !( serTag != -1 || fi.IsPublic ) ) { 163 | continue; 164 | } 165 | var pname = String.Empty; 166 | if ( DumpType( _ftype, fi.Name, out pname, indent + 1, customTypes ) ) { 167 | sb.Append( pname ); 168 | } 169 | } 170 | prettyTypeName = prettyTypeName + sb.ToString(); 171 | } 172 | return true; 173 | } 174 | return false; 175 | } 176 | 177 | public static void Clear() { 178 | lock ( locker ) { 179 | dumpCache.Clear(); 180 | } 181 | } 182 | 183 | public static String Dump( Type type ) { 184 | var content = String.Empty; 185 | lock ( locker ) { 186 | if ( !dumpCache.TryGetValue( type, out content ) ) { 187 | DumpType( type, "", out content, 0, null, true ); 188 | if ( !String.IsNullOrEmpty( content ) ) { 189 | dumpCache.Add( type, content ); 190 | } 191 | } 192 | } 193 | return content; 194 | } 195 | } 196 | #endif 197 | //EOF 198 | -------------------------------------------------------------------------------- /Assets/Editor/MonoScriptDumper/MonoScriptDumper.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 52dbfbc5d8af59e40ae9f69ac139c70c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/MonoScriptDumper/MonoScriptSerializeFieldView.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using UnityEngine; 6 | using UnityEditor; 7 | 8 | public class MonoScriptSerializeFieldView : EditorWindow { 9 | 10 | static UnityEngine.Object _monoScript = null; 11 | static String _dumpedResult = String.Empty; 12 | static Vector2 _viewPos = Vector2.zero; 13 | 14 | [MenuItem( "Tools/SerializeFieldView" )] 15 | static void Init() { 16 | var window = ( MonoScriptSerializeFieldView )EditorWindow.GetWindow( typeof( MonoScriptSerializeFieldView ), true, "MonoScript SerializeField View" ); 17 | window.Show(); 18 | } 19 | 20 | void OnDestroy() { 21 | _monoScript = null; 22 | } 23 | 24 | static Type FindType( String name ) { 25 | var a = AppDomain.CurrentDomain.GetAssemblies(); 26 | for ( int i = 0; i < a.Length; ++i ) { 27 | var types = a[ i ].GetTypes(); 28 | for ( int j = 0; j < types.Length; ++j ) { 29 | var t = types[ j ]; 30 | if ( t.Name == name ) { 31 | if ( typeof( UnityEngine.MonoBehaviour ).IsAssignableFrom( t ) ) { 32 | return t; 33 | } 34 | } 35 | } 36 | } 37 | return null; 38 | } 39 | 40 | void OnGUI() { 41 | EditorGUILayout.BeginVertical(); 42 | EditorGUILayout.Space(); 43 | if ( _monoScript == null ) { 44 | EditorGUILayout.HelpBox( "Drag a MonoBehaviour script to view all of its serialize fields.", MessageType.Info ); 45 | } 46 | EditorGUILayout.BeginHorizontal(); 47 | var oldValue = _monoScript; 48 | EditorGUIUtility.labelWidth = 100; 49 | _monoScript = EditorGUILayout.ObjectField( "MonoBehaviour:", _monoScript, typeof( UnityEngine.Object ), true ) as UnityEngine.Object; 50 | if ( _monoScript != oldValue ) { 51 | _dumpedResult = String.Empty; 52 | _viewPos = Vector2.zero; 53 | if ( _monoScript != null ) { 54 | _dumpedResult = String.Empty; 55 | Type type = null; 56 | type = FindType( _monoScript.name ); 57 | if ( type != null ) { 58 | var info = MonoScriptDumper.Dump( type ); 59 | _dumpedResult = info as String; 60 | _viewPos = Vector2.zero; 61 | } else { 62 | Debug.LogError( String.Format( "Type: {0} not found.", _monoScript.name ) ); 63 | } 64 | } 65 | } 66 | EditorGUILayout.EndHorizontal(); 67 | if ( !String.IsNullOrEmpty( _dumpedResult ) ) { 68 | EditorGUILayout.Space(); 69 | _viewPos = EditorGUILayout.BeginScrollView( _viewPos ); 70 | EditorGUILayout.TextArea( _dumpedResult ); 71 | EditorGUILayout.EndScrollView(); 72 | } 73 | EditorGUILayout.Space(); 74 | EditorGUILayout.EndVertical(); 75 | } 76 | } 77 | 78 | -------------------------------------------------------------------------------- /Assets/Editor/MonoScriptDumper/MonoScriptSerializeFieldView.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: be892f7296ff909428f96e0155516a6c 3 | MonoImporter: 4 | serializedVersion: 2 5 | defaultReferences: [] 6 | executionOrder: 0 7 | icon: {instanceID: 0} 8 | userData: 9 | -------------------------------------------------------------------------------- /Assets/Editor/UVSheetViewer.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Text; 5 | using System.Text.RegularExpressions; 6 | using System.Linq; 7 | using UnityEditor; 8 | using UnityEngine; 9 | using System.Threading; 10 | using System.Diagnostics; 11 | using Common; 12 | 13 | namespace AresEditor.ArtistKit { 14 | 15 | public class UVSheetViewer : EditorWindow { 16 | 17 | enum UVChannel { 18 | UV0, 19 | UV1, 20 | UV2, 21 | UV3, 22 | } 23 | 24 | class UVData { 25 | public String name = String.Empty; 26 | public List subMeshes = null; 27 | public List uvs = new List(); 28 | public UVData() { 29 | for ( int i = 0; i < 4; ++i ) { 30 | uvs.Add( new Vector2[] { } ); 31 | } 32 | } 33 | } 34 | 35 | static UVChannel m_selectUVChannel = UVChannel.UV0; 36 | static UVSheetViewer m_window = null; 37 | 38 | static int m_pageOffset = 0; 39 | static Dictionary m_MeshUVCache = new Dictionary(); 40 | static List> m_selectedUVData = null; 41 | static Texture2D _grayTexture = null; 42 | static Material _drawMatT = null; 43 | static Material _drawMatC = null; 44 | 45 | [MenuItem( "Tools/UVSheetViewer" )] 46 | static void Init() { 47 | if ( m_window == null ) { 48 | m_window = ( UVSheetViewer )EditorWindow.GetWindow( typeof( UVSheetViewer ), false, "UVSheet Viewer" ); 49 | } 50 | m_window.minSize = new Vector2( 400, 300 ); 51 | m_window.position = new Rect( 0, 0, m_window.minSize.x, m_window.minSize.y ); 52 | m_window.Show(); 53 | } 54 | 55 | void OnDestroy() { 56 | m_window = null; 57 | if ( _grayTexture != null ) { 58 | UnityEngine.Object.DestroyImmediate( _grayTexture ); 59 | _grayTexture = null; 60 | } 61 | if ( _drawMatT != null ) { 62 | UnityEngine.Object.DestroyImmediate( _drawMatT ); 63 | _drawMatT = null; 64 | } 65 | if ( _drawMatC != null ) { 66 | UnityEngine.Object.DestroyImmediate( _drawMatC ); 67 | _drawMatC = null; 68 | } 69 | } 70 | 71 | void OnEnable() { 72 | Selection.selectionChanged += OnSelectionChanged; 73 | UpdateCache(); 74 | } 75 | 76 | void OnDisable() { 77 | Selection.selectionChanged -= OnSelectionChanged; 78 | if ( m_MeshUVCache != null ) { 79 | m_MeshUVCache.Clear(); 80 | } 81 | } 82 | 83 | void OnSelectionChanged() { 84 | if ( m_window != null ) { 85 | m_window.Repaint(); 86 | UpdateCache(); 87 | EditorApplication.delayCall += () => m_window.Repaint(); 88 | m_window.Repaint(); 89 | } 90 | } 91 | 92 | static String GetMeshAssetHash( String path, Mesh mesh ) { 93 | var assets = AssetDatabase.LoadAllAssetRepresentationsAtPath( path ); 94 | var index = Array.IndexOf( assets, mesh ); 95 | if ( path.EndsWith( ".asset" ) || assets.Length == 0 ) { 96 | index = 0; 97 | } else { 98 | UDebug.Assert( index >= 0 ); 99 | } 100 | if ( File.Exists( path ) ) { 101 | return String.Format( "{0}-{1}", EditorUtils.Md5Asset( path ), index ); 102 | } else { 103 | return String.Format( "{0}-{1}", path, mesh.GetInstanceID() ); 104 | } 105 | } 106 | 107 | static UVData GetMeshUVData( Mesh mesh ) { 108 | var assetPath = AssetDatabase.GetAssetPath( mesh ); 109 | UVData result = null; 110 | if ( String.IsNullOrEmpty( assetPath ) ) { 111 | result = null; 112 | } else { 113 | UVData md = null; 114 | var importer = AssetImporter.GetAtPath( assetPath ) as ModelImporter; 115 | var isReadable = true; 116 | var meshCompression = ModelImporterMeshCompression.Off; 117 | if ( importer != null ) { 118 | isReadable = importer.isReadable; 119 | meshCompression = importer.meshCompression; 120 | } 121 | Func readMeshData = _mesh => { 122 | var _md = new UVData(); 123 | _md.name = _mesh.name; 124 | _md.uvs[ 0 ] = _mesh.uv; 125 | _md.uvs[ 1 ] = _mesh.uv2; 126 | _md.uvs[ 2 ] = _mesh.uv3; 127 | _md.uvs[ 3 ] = _mesh.uv4; 128 | _md.subMeshes = new List( _mesh.subMeshCount ); 129 | for ( int s = 0; s < _mesh.subMeshCount; ++s ) { 130 | UDebug.Assert( _mesh.GetTopology( s ) == MeshTopology.Triangles ); 131 | _md.subMeshes.Add( _mesh.GetTriangles( s ) ); 132 | } 133 | return _md; 134 | }; 135 | UVData _cachedMeshData = null; 136 | var key = GetMeshAssetHash( assetPath, mesh ); 137 | if ( m_MeshUVCache.TryGetValue( key, out _cachedMeshData ) ) { 138 | md = _cachedMeshData; 139 | } else { 140 | if ( !isReadable || meshCompression != ModelImporterMeshCompression.Off ) { 141 | if ( importer != null ) { 142 | importer.isReadable = true; 143 | importer.meshCompression = ModelImporterMeshCompression.Off; 144 | AssetDatabase.ImportAsset( assetPath ); 145 | } 146 | } 147 | try { 148 | md = readMeshData( mesh ); 149 | } finally { 150 | if ( !isReadable || meshCompression != ModelImporterMeshCompression.Off ) { 151 | if ( importer != null ) { 152 | importer.isReadable = isReadable; 153 | importer.meshCompression = meshCompression; 154 | AssetDatabase.ImportAsset( assetPath ); 155 | } 156 | } 157 | if ( md != null ) { 158 | m_MeshUVCache.Add( key, md ); 159 | } 160 | } 161 | } 162 | result = md; 163 | } 164 | return result; 165 | } 166 | 167 | static void UpdateCache() { 168 | var objs = Selection.objects; 169 | var meshes = new HashSet(); 170 | var dict = new Dictionary(); 171 | for ( int i = 0; i < objs.Length; ++i ) { 172 | var go = objs[ i ] as GameObject; 173 | if ( go != null ) { 174 | var rs = go.GetComponentsInChildren(); 175 | for ( int j = 0; j < rs.Length; ++j ) { 176 | var r = rs[ j ]; 177 | if ( r != null ) { 178 | Mesh m = null; 179 | Material mat = null; 180 | if ( r is MeshRenderer ) { 181 | var mf = r.GetComponent(); 182 | if ( mf != null ) { 183 | m = mf.sharedMesh; 184 | } 185 | var mr = r.GetComponent(); 186 | if ( mr != null ) { 187 | mat = mr.sharedMaterial; 188 | } 189 | } else if ( r is SkinnedMeshRenderer ) { 190 | var _r = r as SkinnedMeshRenderer; 191 | m = _r.sharedMesh; 192 | if ( _r != null ) { 193 | mat = _r.sharedMaterial; 194 | } 195 | } 196 | if ( m != null ) { 197 | if ( mat != null && mat.HasProperty( "_MainTex" ) ) { 198 | dict[ m ] = mat.mainTexture as Texture2D; 199 | } 200 | meshes.Add( m ); 201 | } 202 | } 203 | } 204 | } else if ( objs[ i ] is Mesh ) { 205 | meshes.Add( objs[ i ] as Mesh ); 206 | } 207 | } 208 | m_selectedUVData = new List>(); 209 | try { 210 | int i = 0; 211 | foreach ( var mesh in meshes ) { 212 | var md = GetMeshUVData( mesh ); 213 | if ( EditorUtility.DisplayCancelableProgressBar( "UVSheetViewer", mesh.name, ( float )i / meshes.Count ) ) { 214 | break; 215 | } 216 | if ( md != null ) { 217 | Texture2D hintTex = null; 218 | dict.TryGetValue( mesh, out hintTex ); 219 | m_selectedUVData.Add( new KeyValuePair( md, hintTex ?? Texture2D.blackTexture ) ); 220 | } 221 | } 222 | } finally { 223 | EditorUtility.ClearProgressBar(); 224 | } 225 | } 226 | 227 | void OnGUI() { 228 | EditorGUILayout.BeginVertical(); 229 | EditorGUILayout.Space(); 230 | EditorGUILayout.ObjectField( "Current Selected:", Selection.activeGameObject, typeof( GameObject ), true ); 231 | m_selectUVChannel = ( UVChannel )EditorGUILayout.EnumPopup( "UVChannel", m_selectUVChannel ); 232 | EditorGUILayout.Space(); 233 | OnGUI_DrawUVSheets(); 234 | EditorGUILayout.Space(); 235 | EditorGUILayout.EndVertical(); 236 | } 237 | 238 | void OnGUI_DrawUVSheets() { 239 | const int MaxPage = 3; 240 | const int SheetWidth = 512; 241 | const int SheetHeight = 512; 242 | const int uvWindowOffsetX = 8; 243 | const int uvWindowOffsetY = 8; 244 | const int uvWindowWidth = SheetWidth - uvWindowOffsetX * 2; 245 | const int uvWindowHeight = SheetHeight - uvWindowOffsetY * 2; 246 | if ( _grayTexture == null ) { 247 | _grayTexture = new Texture2D( 1, 1 ); 248 | _grayTexture.SetPixel( 0, 0, Color.grey ); 249 | } 250 | var uvs = m_selectedUVData; 251 | if ( uvs != null && uvs.Count > 0 ) { 252 | EditorGUILayout.BeginVertical(); 253 | m_pageOffset = EditorGUILayout.IntSlider( "Page", m_pageOffset, 0, Math.Max( 0, uvs.Count - MaxPage ) ); 254 | EditorGUILayout.LabelField( "" ); 255 | var width = 0.0f; 256 | var height = 0.0f; 257 | if ( Event.current.type == EventType.Repaint ) { 258 | var rt = GUILayoutUtility.GetLastRect(); 259 | var x = rt.x; 260 | var y = rt.y; 261 | var gap = 4; 262 | var border = x; 263 | width = border * 2; 264 | height = y + border; 265 | var maxTexHeight = 0; 266 | for ( int i = m_pageOffset; i < uvs.Count; ++i ) { 267 | if ( i > m_pageOffset && ( i - m_pageOffset ) < MaxPage ) { 268 | width += gap; 269 | x += gap; 270 | } 271 | var m = m_selectedUVData[ i ]; 272 | if ( SheetHeight > maxTexHeight ) { 273 | maxTexHeight = SheetHeight; 274 | } 275 | EditorGUI.DrawTextureAlpha( new Rect( x, y, SheetWidth, SheetHeight ), _grayTexture ); 276 | var uv_rt = new Rect( x + uvWindowOffsetX, y + uvWindowOffsetY, uvWindowWidth, uvWindowHeight ); 277 | var inBounds = DrawSheet( uv_rt, m.Key, m_selectUVChannel == UVChannel.UV0, m.Value ); 278 | GUI.color = Color.black; 279 | EditorGUI.LabelField( new Rect( x + uvWindowOffsetX + 1, y + uvWindowOffsetY + 2, 120, 32 ), m.Key.name ); 280 | GUI.color = inBounds ? Color.green : Color.red; 281 | EditorGUI.LabelField( new Rect( x + uvWindowOffsetX, y + uvWindowOffsetY, 120, 32 ), m.Key.name ); 282 | 283 | if ( ( i - m_pageOffset ) < MaxPage ) { 284 | width += SheetWidth; 285 | } 286 | x += SheetWidth; 287 | } 288 | GUI.color = Color.white; 289 | 290 | height += maxTexHeight; 291 | if ( m_window != null ) { 292 | var size = m_window.minSize; 293 | if ( width != size.x ) { 294 | size.x = width; 295 | } 296 | if ( height != size.y ) { 297 | size.y = height; 298 | } 299 | m_window.minSize = size; 300 | m_window.maxSize = size; 301 | } 302 | } 303 | EditorGUILayout.EndVertical(); 304 | } 305 | } 306 | 307 | static float ClampRepeatUV( float value, ref bool modified ) { 308 | if ( Mathf.Abs( value ) < 1e-6f ) { 309 | value = 0; 310 | } 311 | if ( Mathf.Abs( 1 - value ) < 1e-6f ) { 312 | value = 1; 313 | } 314 | if ( value < 0 || value > 1 ) { 315 | var _value = value % 1.0f; 316 | if ( _value < 0.0 ) { 317 | _value += 1.0f; 318 | } 319 | modified = _value != value; 320 | return _value; 321 | } else { 322 | modified = false; 323 | return value; 324 | } 325 | } 326 | 327 | bool DrawSheet( Rect rect, UVData uvset, bool withBG = false, Texture2D tex = null ) { 328 | var result = true; 329 | if ( _drawMatT == null ) { 330 | var shader = Shader.Find( "Unlit/Texture" ); 331 | _drawMatT = new Material( shader ); 332 | } 333 | if ( _drawMatC == null ) { 334 | var shader = Shader.Find( "Hidden/Internal-Colored" ); 335 | _drawMatC = new Material( shader ); 336 | } 337 | if ( Event.current.type == EventType.Repaint ) { 338 | GUI.BeginClip( rect ); 339 | GL.PushMatrix(); 340 | 341 | GL.Clear( true, false, Color.black ); 342 | // background 343 | if ( withBG && tex != null && _drawMatT.HasProperty( "_MainTex" ) ) { 344 | _drawMatT.mainTexture = tex; 345 | } else { 346 | _drawMatT.mainTexture = Texture2D.blackTexture; 347 | } 348 | _drawMatT.SetPass( 0 ); 349 | GL.Begin( GL.QUADS ); 350 | GL.Color( Color.black ); 351 | GL.TexCoord2( 0, 1 ); 352 | GL.Vertex3( 0, 0, 0 ); 353 | GL.TexCoord2( 1, 1 ); 354 | GL.Vertex3( rect.width, 0, 0 ); 355 | GL.TexCoord2( 1, 0 ); 356 | GL.Vertex3( rect.width, rect.height, 0 ); 357 | GL.TexCoord2( 0, 0 ); 358 | GL.Vertex3( 0, rect.height, 0 ); 359 | GL.End(); 360 | 361 | _drawMatC.SetPass( 0 ); 362 | // draw grid 363 | GL.Begin( GL.LINES ); 364 | int count = 25; 365 | var sx = 0; 366 | var sy = 0; 367 | var dx = ( float )rect.width / count; 368 | var dy = ( float )rect.height / count; 369 | for ( int i = 0; i <= count; ++i ) { 370 | float f = ( i % 5 == 0 ) ? 0.5f : 0.2f; 371 | GL.Color( new Color( f, f, f, 1 ) ); 372 | sx = ( int )Math.Ceiling( dx * i ); 373 | sy = ( int )Math.Ceiling( dy * i ); 374 | GL.Vertex3( sx, 0, 0 ); 375 | GL.Vertex3( sx, rect.height, 0 ); 376 | GL.Vertex3( 0, sy, 0 ); 377 | GL.Vertex3( rect.width, sy, 0 ); 378 | } 379 | GL.End(); 380 | 381 | var scale = new Vector2( rect.width, rect.height ); 382 | var subMeshes = uvset.subMeshes; 383 | var uv = uvset.uvs[ ( int )m_selectUVChannel ]; 384 | if ( uv != null && uv.Length > 0 ) { 385 | GL.Begin( GL.LINES ); 386 | GL.Color( Color.green ); 387 | GL.TexCoord2( 0, 0 ); 388 | for ( int j = 0; j < subMeshes.Count; ++j ) { 389 | var tri = subMeshes[ j ]; 390 | for ( int t = 0; t < tri.Length; t += 3 ) { 391 | var pt0 = uv[ tri[ t ] ]; 392 | var pt1 = uv[ tri[ t + 1 ] ]; 393 | var pt2 = uv[ tri[ t + 2 ] ]; 394 | var b = false; 395 | if ( pt0.x < 0 || pt0.x > 1 ) { 396 | result = false; 397 | } 398 | if ( pt0.y < 0 || pt0.y > 1 ) { 399 | result = false; 400 | } 401 | if ( pt1.x < 0 || pt1.x > 1 ) { 402 | result = false; 403 | } 404 | if ( pt1.y < 0 || pt1.y > 1 ) { 405 | result = false; 406 | } 407 | if ( pt2.x < 0 || pt2.x > 1 ) { 408 | result = false; 409 | } 410 | if ( pt2.y < 0 || pt2.y > 1 ) { 411 | result = false; 412 | } 413 | pt0.x = ClampRepeatUV( pt0.x, ref b ); 414 | pt0.y = ClampRepeatUV( pt0.y, ref b ); 415 | pt1.x = ClampRepeatUV( pt1.x, ref b ); 416 | pt1.y = ClampRepeatUV( pt1.y, ref b ); 417 | pt2.x = ClampRepeatUV( pt2.x, ref b ); 418 | pt2.y = ClampRepeatUV( pt2.y, ref b ); 419 | pt0.y = 1 - pt0.y; 420 | pt1.y = 1 - pt1.y; 421 | pt2.y = 1 - pt2.y; 422 | pt0.Scale( scale ); 423 | pt1.Scale( scale ); 424 | pt2.Scale( scale ); 425 | if ( b ) { 426 | GL.Color( Color.red ); 427 | } else { 428 | GL.Color( Color.green ); 429 | } 430 | GL.Vertex3( pt0.x, pt0.y, 0 ); 431 | GL.Vertex3( pt1.x, pt1.y, 0 ); 432 | GL.Vertex3( pt1.x, pt1.y, 0 ); 433 | GL.Vertex3( pt2.x, pt2.y, 0 ); 434 | GL.Vertex3( pt2.x, pt2.y, 0 ); 435 | GL.Vertex3( pt0.x, pt0.y, 0 ); 436 | } 437 | } 438 | GL.End(); 439 | } 440 | 441 | GL.PopMatrix(); 442 | 443 | GUI.EndClip(); 444 | } 445 | return result; 446 | } 447 | } 448 | } 449 | -------------------------------------------------------------------------------- /Assets/Editor/UVSheetViewer.cs.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3bdd190ad7643bf4eb8749d59ac08064 3 | timeCreated: 1517215265 4 | licenseType: Pro 5 | MonoImporter: 6 | serializedVersion: 2 7 | defaultReferences: [] 8 | executionOrder: 0 9 | icon: {instanceID: 0} 10 | userData: 11 | assetBundleName: 12 | assetBundleVariant: 13 | -------------------------------------------------------------------------------- /Assets/Resources.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 919d07bb1fd53484e90da89429f9ced0 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Resources/Prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 92b698bac6a9f2f4daddb637c69ef287 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Resources/Prefab/role.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c5e40a958fd70d5439ea870559810f9d 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Resources/Prefab/role/player_1.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 28a39100d26d8cc4184e3aa84ddbba6d 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/Resources/Prefab/role/player_1/player_1_1_1.prefab: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/Resources/Prefab/role/player_1/player_1_1_1.prefab -------------------------------------------------------------------------------- /Assets/Resources/Prefab/role/player_1/player_1_1_1.prefab.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: dba8b06c5d22f4849bc9069c3830a5f8 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/_Raw.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 028ce344951cc8e44a1eea184f4bc197 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/_Raw/role.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: a9b2d64bdbeb5004bb5593743d7560e6 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/_Raw/role/animation.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 21a073b05f0e4d64e8dd06695eaddafd 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/_Raw/role/animation/player.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 82a3cf5fb6843e94db7dd06f4f53c8b3 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/_Raw/role/animation/player/female.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 49799468cc944de44bfdaebf08228eb5 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/_Raw/role/animation/player/female/battlelost.anim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/_Raw/role/animation/player/female/battlelost.anim -------------------------------------------------------------------------------- /Assets/_Raw/role/animation/player/female/battlelost.anim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 8da406195a3727545b5556e6892dd444 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/_Raw/role/animation/player/female/jump_1.anim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/_Raw/role/animation/player/female/jump_1.anim -------------------------------------------------------------------------------- /Assets/_Raw/role/animation/player/female/jump_1.anim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 547fb1b9148c97241a8d65e93e4da0fd 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/_Raw/role/animation/player/female/jump_2.anim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/_Raw/role/animation/player/female/jump_2.anim -------------------------------------------------------------------------------- /Assets/_Raw/role/animation/player/female/jump_2.anim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: c50e6b5c59a4b554093ead74f6b1d093 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/_Raw/role/animation/player/female/jump_3.anim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/_Raw/role/animation/player/female/jump_3.anim -------------------------------------------------------------------------------- /Assets/_Raw/role/animation/player/female/jump_3.anim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: bbc8cc0e44e3c244bbe5fa83b77ccd8d 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/_Raw/role/animation/player/female/spawn.anim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/_Raw/role/animation/player/female/spawn.anim -------------------------------------------------------------------------------- /Assets/_Raw/role/animation/player/female/spawn.anim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 77660f92641506547b8548d69da5898d 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/_Raw/role/player_1.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 9ef4bb5a9536af749ab4a879f16bffd8 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/_Raw/role/player_1/MergedMeshes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: d8fdf0f8bb8dfcc49811671a48468e8b 3 | folderAsset: yes 4 | timeCreated: 1517912208 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/_Raw/role/player_1/MergedMeshes/player_1_1_1_part1.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/_Raw/role/player_1/MergedMeshes/player_1_1_1_part1.asset -------------------------------------------------------------------------------- /Assets/_Raw/role/player_1/MergedMeshes/player_1_1_1_part1.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 770e7277fc5a35e48b2df78f6b72e48e 3 | timeCreated: 1517912208 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/_Raw/role/player_1/SimplifiedMeshes.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3d41a8a64efe8944e95619d2e20f8be0 3 | folderAsset: yes 4 | timeCreated: 1517912145 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/_Raw/role/player_1/idle.anim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/_Raw/role/player_1/idle.anim -------------------------------------------------------------------------------- /Assets/_Raw/role/player_1/idle.anim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 57ca632e6644b6e429f4502e1c1ac7e1 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/_Raw/role/player_1/player_1_1.FBX: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/_Raw/role/player_1/player_1_1.FBX -------------------------------------------------------------------------------- /Assets/_Raw/role/player_1/player_1_1.FBX.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1a2408a2922c2764c8251f9f6844bd62 3 | timeCreated: 1517907605 4 | licenseType: Pro 5 | ModelImporter: 6 | serializedVersion: 19 7 | fileIDToRecycleName: 8 | 100000: Bip001 9 | 100002: Bip01 L Finger0 10 | 100004: Bip01 L Finger01 11 | 100006: Bip01 L Finger1 12 | 100008: Bip01 L Finger11 13 | 100010: Bip01 R Finger0 14 | 100012: Bip01 R Finger01 15 | 100014: Bip01 R Finger1 16 | 100016: Bip01 R Finger11 17 | 100018: Bip_calfl 18 | 100020: Bip_calfr 19 | 100022: Bip_claviclel 20 | 100024: Bip_clavicler 21 | 100026: Bip_footl 22 | 100028: Bip_footr 23 | 100030: Bip_forearml 24 | 100032: Bip_forearmr 25 | 100034: Bip_handl 26 | 100036: Bip_handr 27 | 100038: Bip_head 28 | 100040: Bip_hit 29 | 100042: Bip_neck 30 | 100044: Bip_root 31 | 100046: Bip_spline 32 | 100048: Bip_thighl 33 | 100050: Bip_thighr 34 | 100052: Bip_toer 35 | 100054: Bip_toer 1 36 | 100056: Bip_upperarml 37 | 100058: Bip_upperarmr 38 | 100060: Bip_w1 39 | 100062: Bone017 40 | 100064: Bone017(mirrored) 41 | 100066: Bone021 42 | 100068: Bone022 43 | 100070: Bone025 44 | 100072: Bone033 45 | 100074: Bone034 46 | 100076: Bone035 47 | 100078: Bone04 48 | 100080: Bone16 49 | 100082: //RootNode 50 | 100084: player_1_1 51 | 400000: Bip001 52 | 400002: Bip01 L Finger0 53 | 400004: Bip01 L Finger01 54 | 400006: Bip01 L Finger1 55 | 400008: Bip01 L Finger11 56 | 400010: Bip01 R Finger0 57 | 400012: Bip01 R Finger01 58 | 400014: Bip01 R Finger1 59 | 400016: Bip01 R Finger11 60 | 400018: Bip_calfl 61 | 400020: Bip_calfr 62 | 400022: Bip_claviclel 63 | 400024: Bip_clavicler 64 | 400026: Bip_footl 65 | 400028: Bip_footr 66 | 400030: Bip_forearml 67 | 400032: Bip_forearmr 68 | 400034: Bip_handl 69 | 400036: Bip_handr 70 | 400038: Bip_head 71 | 400040: Bip_hit 72 | 400042: Bip_neck 73 | 400044: Bip_root 74 | 400046: Bip_spline 75 | 400048: Bip_thighl 76 | 400050: Bip_thighr 77 | 400052: Bip_toer 78 | 400054: Bip_toer 1 79 | 400056: Bip_upperarml 80 | 400058: Bip_upperarmr 81 | 400060: Bip_w1 82 | 400062: Bone017 83 | 400064: Bone017(mirrored) 84 | 400066: Bone021 85 | 400068: Bone022 86 | 400070: Bone025 87 | 400072: Bone033 88 | 400074: Bone034 89 | 400076: Bone035 90 | 400078: Bone04 91 | 400080: Bone16 92 | 400082: //RootNode 93 | 400084: player_1_1 94 | 4300000: player_1_1 95 | 11100000: //RootNode 96 | 13700000: Bip_root 97 | materials: 98 | importMaterials: 0 99 | materialName: 0 100 | materialSearch: 1 101 | animations: 102 | legacyGenerateAnimations: 3 103 | bakeSimulation: 0 104 | resampleCurves: 1 105 | optimizeGameObjects: 0 106 | motionNodeName: 107 | animationImportErrors: 108 | animationImportWarnings: 109 | animationRetargetingWarnings: 110 | animationDoRetargetingWarnings: 0 111 | animationCompression: 1 112 | animationRotationError: 0.5 113 | animationPositionError: 0.5 114 | animationScaleError: 0.5 115 | animationWrapMode: 0 116 | extraExposedTransformPaths: [] 117 | clipAnimations: [] 118 | isReadable: 0 119 | meshes: 120 | lODScreenPercentages: [] 121 | globalScale: 1 122 | meshCompression: 2 123 | addColliders: 0 124 | importBlendShapes: 0 125 | swapUVChannels: 0 126 | generateSecondaryUV: 0 127 | useFileUnits: 1 128 | optimizeMeshForGPU: 1 129 | keepQuads: 0 130 | weldVertices: 1 131 | secondaryUVAngleDistortion: 8 132 | secondaryUVAreaDistortion: 15.000001 133 | secondaryUVHardAngle: 88 134 | secondaryUVPackMargin: 4 135 | useFileScale: 0 136 | tangentSpace: 137 | normalSmoothAngle: 60 138 | normalImportMode: 0 139 | tangentImportMode: 2 140 | importAnimation: 1 141 | copyAvatar: 0 142 | humanDescription: 143 | serializedVersion: 2 144 | human: [] 145 | skeleton: [] 146 | armTwist: 0.5 147 | foreArmTwist: 0.5 148 | upperLegTwist: 0.5 149 | legTwist: 0.5 150 | armStretch: 0.05 151 | legStretch: 0.05 152 | feetSpacing: 0 153 | rootMotionBoneName: 154 | rootMotionBoneRotation: {x: 0, y: 0, z: 0, w: 1} 155 | hasTranslationDoF: 0 156 | hasExtraRoot: 0 157 | skeletonHasParents: 0 158 | lastHumanDescriptionAvatarSource: {instanceID: 0} 159 | animationType: 1 160 | humanoidOversampling: 1 161 | additionalBone: 0 162 | userData: 163 | assetBundleName: 164 | assetBundleVariant: 165 | -------------------------------------------------------------------------------- /Assets/_Raw/role/player_1/player_1_1.mat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/_Raw/role/player_1/player_1_1.mat -------------------------------------------------------------------------------- /Assets/_Raw/role/player_1/player_1_1.mat.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3cffb90fff5100845a312649f5d290c0 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/_Raw/role/player_1/player_1_1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/_Raw/role/player_1/player_1_1.png -------------------------------------------------------------------------------- /Assets/_Raw/role/player_1/player_1_1.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3a48a8dbee3bb4c4d8551d56ad86d925 3 | TextureImporter: 4 | fileIDToRecycleName: {} 5 | serializedVersion: 2 6 | mipmaps: 7 | mipMapMode: 0 8 | enableMipMap: 0 9 | linearTexture: 0 10 | correctGamma: 0 11 | fadeOut: 0 12 | borderMipMap: 0 13 | mipMapFadeDistanceStart: 1 14 | mipMapFadeDistanceEnd: 3 15 | bumpmap: 16 | convertToNormalMap: 0 17 | externalNormalMap: 0 18 | heightScale: .25 19 | normalMapFilter: 0 20 | isReadable: 0 21 | grayScaleToAlpha: 0 22 | generateCubemap: 0 23 | seamlessCubemap: 0 24 | textureFormat: -1 25 | maxTextureSize: 512 26 | textureSettings: 27 | filterMode: 1 28 | aniso: 3 29 | mipBias: 0 30 | wrapMode: 1 31 | nPOTScale: 1 32 | lightmap: 0 33 | compressionQuality: 100 34 | spriteMode: 0 35 | spriteExtrude: 1 36 | spriteMeshType: 1 37 | alignment: 0 38 | spritePivot: {x: .5, y: .5} 39 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 40 | spritePixelsToUnits: 100 41 | alphaIsTransparency: 0 42 | textureType: -1 43 | buildTargetSettings: 44 | - buildTarget: Android 45 | maxTextureSize: 512 46 | textureFormat: 34 47 | compressionQuality: 100 48 | - buildTarget: iPhone 49 | maxTextureSize: 512 50 | textureFormat: 32 51 | compressionQuality: 100 52 | spriteSheet: 53 | sprites: [] 54 | spritePackingTag: 55 | userData: 56 | -------------------------------------------------------------------------------- /Assets/__backup_animations__.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cb42e7d32229e114aac3f5aba5b023fc 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/__backup_animations__/_Raw.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 45798c8b9cc898b4fbfd0ad7ad8c9ff4 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/__backup_animations__/_Raw/role.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 6dd55d6b0a7eda244824eaa949f3ce91 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/__backup_animations__/_Raw/role/player_1.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 0f7ba3f47173bc64f83d97e5ea1d5de0 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/__backup_animations__/_Raw/role/player_1/battlewin.anim: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/__backup_animations__/_Raw/role/player_1/battlewin.anim -------------------------------------------------------------------------------- /Assets/__backup_animations__/_Raw/role/player_1/battlewin.anim.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: cf821d0a72a4aa34686e16b8d10fd012 3 | NativeFormatImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/__export_record__.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 3221a7de101fe34439cbe060ab922f16 3 | folderAsset: yes 4 | DefaultImporter: 5 | userData: 6 | -------------------------------------------------------------------------------- /Assets/__export_record__/AnimationCompressRecord.json: -------------------------------------------------------------------------------- 1 | { 2 | "Assets/_Raw/role/player_1/battlewin.anim":"8d13fbd68d9da2792e1d8035f83dd062 | 1016febe2603777619237ce647deb7a7 <= battlewin : p = 0.01, r = 0.05, s = 0.01, d = 1.125, rms = false" 3 | } -------------------------------------------------------------------------------- /Assets/__export_record__/AnimationCompressRecord.json.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 098bfd25cbb49b243b6146182916b9be 3 | TextScriptImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/gmcs.rsp: -------------------------------------------------------------------------------- 1 | -unsafe 2 | -nowarn:0219,0414,0162,0618,0169 3 | -warnaserror:0472,0114,0108,0162,0109,0168 -------------------------------------------------------------------------------- /Assets/gmcs.rsp.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1bb6d7b69b9273d43b65786504366a27 3 | timeCreated: 1510053363 4 | licenseType: Pro 5 | DefaultImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/test.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 4bc166eff50eb8e4f9223377e3295f05 3 | folderAsset: yes 4 | timeCreated: 1517907148 5 | licenseType: Pro 6 | DefaultImporter: 7 | userData: 8 | assetBundleName: 9 | assetBundleVariant: 10 | -------------------------------------------------------------------------------- /Assets/test.unity: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/test.unity -------------------------------------------------------------------------------- /Assets/test.unity.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 1671c7b076c437146bf2842826ba5843 3 | DefaultImporter: 4 | userData: 5 | -------------------------------------------------------------------------------- /Assets/test/LightingData.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/test/LightingData.asset -------------------------------------------------------------------------------- /Assets/test/LightingData.asset.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: 18eed874012528a4184d19bde0bc916f 3 | timeCreated: 1517908554 4 | licenseType: Pro 5 | NativeFormatImporter: 6 | userData: 7 | assetBundleName: 8 | assetBundleVariant: 9 | -------------------------------------------------------------------------------- /Assets/test/Lightmap-0_comp_dir.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/test/Lightmap-0_comp_dir.png -------------------------------------------------------------------------------- /Assets/test/Lightmap-0_comp_dir.png.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: b1c63845feedb0d42be24426b8720153 3 | timeCreated: 1517908554 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 0 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: 1 31 | aniso: 3 32 | mipBias: 0 33 | wrapMode: 1 34 | nPOTScale: 1 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 1 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 0 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 0 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | spriteSheet: 62 | serializedVersion: 2 63 | sprites: [] 64 | outline: [] 65 | spritePackingTag: 66 | userData: 67 | assetBundleName: 68 | assetBundleVariant: 69 | -------------------------------------------------------------------------------- /Assets/test/Lightmap-0_comp_light.exr: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/Assets/test/Lightmap-0_comp_light.exr -------------------------------------------------------------------------------- /Assets/test/Lightmap-0_comp_light.exr.meta: -------------------------------------------------------------------------------- 1 | fileFormatVersion: 2 2 | guid: f72f511e7446ebf419f920765e650005 3 | timeCreated: 1517908554 4 | licenseType: Pro 5 | TextureImporter: 6 | fileIDToRecycleName: {} 7 | serializedVersion: 4 8 | mipmaps: 9 | mipMapMode: 0 10 | enableMipMap: 1 11 | sRGBTexture: 1 12 | linearTexture: 0 13 | fadeOut: 0 14 | borderMipMap: 0 15 | mipMapFadeDistanceStart: 1 16 | mipMapFadeDistanceEnd: 3 17 | bumpmap: 18 | convertToNormalMap: 0 19 | externalNormalMap: 0 20 | heightScale: 0.25 21 | normalMapFilter: 0 22 | isReadable: 0 23 | grayScaleToAlpha: 0 24 | generateCubemap: 6 25 | cubemapConvolution: 0 26 | seamlessCubemap: 0 27 | textureFormat: 1 28 | maxTextureSize: 2048 29 | textureSettings: 30 | filterMode: 1 31 | aniso: 3 32 | mipBias: 0 33 | wrapMode: 1 34 | nPOTScale: 1 35 | lightmap: 0 36 | compressionQuality: 50 37 | spriteMode: 0 38 | spriteExtrude: 1 39 | spriteMeshType: 1 40 | alignment: 0 41 | spritePivot: {x: 0.5, y: 0.5} 42 | spriteBorder: {x: 0, y: 0, z: 0, w: 0} 43 | spritePixelsToUnits: 100 44 | alphaUsage: 0 45 | alphaIsTransparency: 0 46 | spriteTessellationDetail: -1 47 | textureType: 6 48 | textureShape: 1 49 | maxTextureSizeSet: 0 50 | compressionQualitySet: 0 51 | textureFormatSet: 0 52 | platformSettings: 53 | - buildTarget: DefaultTexturePlatform 54 | maxTextureSize: 2048 55 | textureFormat: -1 56 | textureCompression: 0 57 | compressionQuality: 50 58 | crunchedCompression: 0 59 | allowsAlphaSplitting: 0 60 | overridden: 0 61 | spriteSheet: 62 | serializedVersion: 2 63 | sprites: [] 64 | outline: [] 65 | spritePackingTag: 66 | userData: 67 | assetBundleName: 68 | assetBundleVariant: 69 | -------------------------------------------------------------------------------- /ProjectSettings/AudioManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/AudioManager.asset -------------------------------------------------------------------------------- /ProjectSettings/ClusterInputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/ClusterInputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/DynamicsManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/DynamicsManager.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorBuildSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/EditorBuildSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/EditorSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/EditorSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/GraphicsSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/GraphicsSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/InputManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/InputManager.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshAreas.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/NavMeshAreas.asset -------------------------------------------------------------------------------- /ProjectSettings/NavMeshLayers.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/NavMeshLayers.asset -------------------------------------------------------------------------------- /ProjectSettings/NetworkManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/NetworkManager.asset -------------------------------------------------------------------------------- /ProjectSettings/Physics2DSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/Physics2DSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/ProjectSettings.asset -------------------------------------------------------------------------------- /ProjectSettings/ProjectVersion.txt: -------------------------------------------------------------------------------- 1 | m_EditorVersion: 5.5.4f1 2 | -------------------------------------------------------------------------------- /ProjectSettings/QualitySettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/QualitySettings.asset -------------------------------------------------------------------------------- /ProjectSettings/TagManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/TagManager.asset -------------------------------------------------------------------------------- /ProjectSettings/TimeManager.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/TimeManager.asset -------------------------------------------------------------------------------- /ProjectSettings/UnityConnectSettings.asset: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ProjectSettings/UnityConnectSettings.asset -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # UnityToolDist 2 | My unity tool set distribution 3 | - AnimationClip Compressor 4 | - Material Cleanner 5 | - MonoScript Serialization info dump & viewer 6 | - Matrix Viewer ( For better understand Unity's Matrix notation ) 7 | - LightmapUV Viwer 8 | 9 | ### AnimationClip Compressor 10 | ![image](https://github.com/lujian101/UnityToolDist/blob/master/ScreenShot/animationclip-compressor.png?raw=true) 11 | 12 | ### Matrix Viewer 13 | 14 | Unity's Notation | Memory Layout 15 | ---|--- 16 | ![image](https://github.com/lujian101/UnityToolDist/blob/master/ScreenShot/matrix-viewer.png?raw=true) | ![image](https://github.com/lujian101/UnityToolDist/blob/master/ScreenShot/matrix-viewer-memory.png?raw=true) 17 | 18 | 19 | ### MonoScript SerializedField Viewer 20 | ![image](https://github.com/lujian101/UnityToolDist/blob/master/ScreenShot/mono-script-viewer.png?raw=true) 21 | 22 | ### LightmapUV Viewer 23 | ![image](https://github.com/lujian101/UnityToolDist/blob/master/ScreenShot/lightmap-viewer.png?raw=true) 24 | 25 | ### UVSheet Viewer 26 | ![image](https://github.com/lujian101/UnityToolDist/blob/master/ScreenShot/uvsheet_viewer.png) 27 | -------------------------------------------------------------------------------- /ScreenShot/animationclip-compressor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ScreenShot/animationclip-compressor.png -------------------------------------------------------------------------------- /ScreenShot/lightmap-viewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ScreenShot/lightmap-viewer.png -------------------------------------------------------------------------------- /ScreenShot/matrix-viewer-memory.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ScreenShot/matrix-viewer-memory.png -------------------------------------------------------------------------------- /ScreenShot/matrix-viewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ScreenShot/matrix-viewer.png -------------------------------------------------------------------------------- /ScreenShot/mono-script-viewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ScreenShot/mono-script-viewer.png -------------------------------------------------------------------------------- /ScreenShot/uvsheet_viewer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lujian101/UnityToolDist/f2e43ecb5204bf9d1ad0372a49a7bb51cbd59629/ScreenShot/uvsheet_viewer.png -------------------------------------------------------------------------------- /UnityToolDist.CSharp.Editor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 10.0.20506 7 | 2.0 8 | {7D706BE7-3C6E-8D8F-8C31-E457BD34C281} 9 | Library 10 | Assembly-CSharp-Editor 11 | 512 12 | {E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 13 | .NETFramework 14 | v3.5 15 | Unity Full v3.5 16 | Assets\gmcs.rsp 17 | Editor:5 18 | StandaloneWindows:5 19 | 5.5.4f1 20 | 21 | 4 22 | 23 | 24 | pdbonly 25 | false 26 | Temp\UnityVS_bin\Debug\ 27 | Temp\UnityVS_obj\Debug\ 28 | prompt 29 | 4 30 | DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_5_OR_NEWER;UNITY_5_5_4;UNITY_5_5;UNITY_5;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_GENERICS;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_LZMA;ENABLE_UNITYEVENTS;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;INCLUDE_PUBNUB;ENABLE_PLAYMODE_TESTS_RUNNER;ENABLE_SCRIPTING_NEW_CSHARP_COMPILER;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_UNITYWEBREQUEST;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_EVENT_QUEUE;ENABLE_CLUSTERINPUT;ENABLE_VIDEO;ENABLE_VR;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE;ENABLE_VSTU;UNITY_PRO_LICENSE; 31 | true 32 | 33 | 34 | pdbonly 35 | false 36 | Temp\UnityVS_bin\Release\ 37 | Temp\UnityVS_obj\Release\ 38 | prompt 39 | 4 40 | TRACE;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_5_OR_NEWER;UNITY_5_5_4;UNITY_5_5;UNITY_5;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_GENERICS;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_LZMA;ENABLE_UNITYEVENTS;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;INCLUDE_PUBNUB;ENABLE_PLAYMODE_TESTS_RUNNER;ENABLE_SCRIPTING_NEW_CSHARP_COMPILER;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_UNITYWEBREQUEST;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_EVENT_QUEUE;ENABLE_CLUSTERINPUT;ENABLE_VIDEO;ENABLE_VR;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE;ENABLE_VSTU;UNITY_PRO_LICENSE; 41 | true 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | Library\UnityAssemblies\UnityEngine.dll 54 | 55 | 56 | Library\UnityAssemblies\UnityEditor.dll 57 | 58 | 59 | Library\UnityAssemblies\UnityEditor.Advertisements.dll 60 | 61 | 62 | Library\UnityAssemblies\nunit.framework.dll 63 | 64 | 65 | Library\UnityAssemblies\UnityEditor.EditorTestsRunner.dll 66 | 67 | 68 | Library\UnityAssemblies\UnityEngine.UI.dll 69 | 70 | 71 | Library\UnityAssemblies\UnityEditor.UI.dll 72 | 73 | 74 | Library\UnityAssemblies\UnityEngine.Networking.dll 75 | 76 | 77 | Library\UnityAssemblies\UnityEditor.Networking.dll 78 | 79 | 80 | Library\UnityAssemblies\UnityEditor.PlaymodeTestsRunner.dll 81 | 82 | 83 | Library\UnityAssemblies\UnityEngine.PlaymodeTestsRunner.dll 84 | 85 | 86 | Library\UnityAssemblies\UnityEditor.TreeEditor.dll 87 | 88 | 89 | Library\UnityAssemblies\UnityEngine.Analytics.dll 90 | 91 | 92 | Library\UnityAssemblies\UnityEditor.Analytics.dll 93 | 94 | 95 | Library\UnityAssemblies\UnityEditor.HoloLens.dll 96 | 97 | 98 | Library\UnityAssemblies\UnityEngine.HoloLens.dll 99 | 100 | 101 | Library\UnityAssemblies\UnityEditor.VR.dll 102 | 103 | 104 | Library\UnityAssemblies\UnityEngine.VR.dll 105 | 106 | 107 | Library\UnityAssemblies\UnityEditor.Graphs.dll 108 | 109 | 110 | Library\UnityAssemblies\UnityEditor.Android.Extensions.dll 111 | 112 | 113 | Library\UnityAssemblies\UnityEditor.iOS.Extensions.dll 114 | 115 | 116 | Library\UnityAssemblies\UnityEditor.WindowsStandalone.Extensions.dll 117 | 118 | 119 | Library\UnityAssemblies\SyntaxTree.VisualStudio.Unity.Bridge.dll 120 | 121 | 122 | Library\UnityAssemblies\UnityEditor.iOS.Extensions.Xcode.dll 123 | 124 | 125 | Library\UnityAssemblies\UnityEditor.iOS.Extensions.Common.dll 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | -------------------------------------------------------------------------------- /UnityToolDist.CSharp.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 10.0.20506 7 | 2.0 8 | {FCB53BBC-5F47-9A36-A841-FB5BE892AB89} 9 | Library 10 | Assembly-CSharp 11 | 512 12 | {E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 13 | .NETFramework 14 | v3.5 15 | Unity Subset v3.5 16 | 17 | Game:1 18 | StandaloneWindows:5 19 | 5.5.4f1 20 | 21 | 4 22 | 23 | 24 | pdbonly 25 | false 26 | Temp\UnityVS_bin\Debug\ 27 | Temp\UnityVS_obj\Debug\ 28 | prompt 29 | 4 30 | DEBUG;TRACE;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_5_OR_NEWER;UNITY_5_5_4;UNITY_5_5;UNITY_5;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_GENERICS;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_LZMA;ENABLE_UNITYEVENTS;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;INCLUDE_PUBNUB;ENABLE_PLAYMODE_TESTS_RUNNER;ENABLE_SCRIPTING_NEW_CSHARP_COMPILER;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_UNITYWEBREQUEST;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_EVENT_QUEUE;ENABLE_CLUSTERINPUT;ENABLE_VIDEO;ENABLE_VR;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE;ENABLE_VSTU;UNITY_PRO_LICENSE 31 | false 32 | 33 | 34 | pdbonly 35 | false 36 | Temp\UnityVS_bin\Release\ 37 | Temp\UnityVS_obj\Release\ 38 | prompt 39 | 4 40 | TRACE;UNITY_5_3_OR_NEWER;UNITY_5_4_OR_NEWER;UNITY_5_5_OR_NEWER;UNITY_5_5_4;UNITY_5_5;UNITY_5;ENABLE_AUDIO;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_DUCK_TYPING;ENABLE_GENERICS;ENABLE_MICROPHONE;ENABLE_MULTIPLE_DISPLAYS;ENABLE_PHYSICS;ENABLE_SPRITERENDERER_FLIPPING;ENABLE_SPRITES;ENABLE_TERRAIN;ENABLE_RAKNET;ENABLE_UNET;ENABLE_LZMA;ENABLE_UNITYEVENTS;ENABLE_WEBCAM;ENABLE_WWW;ENABLE_CLOUD_SERVICES_COLLAB;ENABLE_CLOUD_SERVICES_ADS;ENABLE_CLOUD_HUB;ENABLE_CLOUD_PROJECT_ID;ENABLE_CLOUD_SERVICES_UNET;ENABLE_CLOUD_SERVICES_BUILD;ENABLE_CLOUD_LICENSE;ENABLE_EDITOR_METRICS;ENABLE_EDITOR_METRICS_CACHING;INCLUDE_DYNAMIC_GI;INCLUDE_GI;PLATFORM_SUPPORTS_MONO;RENDER_SOFTWARE_CURSOR;INCLUDE_PUBNUB;ENABLE_PLAYMODE_TESTS_RUNNER;ENABLE_SCRIPTING_NEW_CSHARP_COMPILER;UNITY_STANDALONE_WIN;UNITY_STANDALONE;ENABLE_SUBSTANCE;ENABLE_RUNTIME_GI;ENABLE_MOVIES;ENABLE_NETWORK;ENABLE_CRUNCH_TEXTURE_COMPRESSION;ENABLE_UNITYWEBREQUEST;ENABLE_CLOUD_SERVICES;ENABLE_CLOUD_SERVICES_ANALYTICS;ENABLE_CLOUD_SERVICES_PURCHASING;ENABLE_CLOUD_SERVICES_CRASH_REPORTING;ENABLE_EVENT_QUEUE;ENABLE_CLUSTERINPUT;ENABLE_VIDEO;ENABLE_VR;ENABLE_WEBSOCKET_HOST;ENABLE_MONO;ENABLE_PROFILER;DEBUG;TRACE;UNITY_ASSERTIONS;UNITY_EDITOR;UNITY_EDITOR_64;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE;ENABLE_VSTU;UNITY_PRO_LICENSE 41 | false 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | Library\UnityAssemblies\UnityEngine.dll 54 | 55 | 56 | Library\UnityAssemblies\UnityEngine.UI.dll 57 | 58 | 59 | Library\UnityAssemblies\UnityEngine.Networking.dll 60 | 61 | 62 | Library\UnityAssemblies\UnityEngine.PlaymodeTestsRunner.dll 63 | 64 | 65 | Library\UnityAssemblies\UnityEngine.Analytics.dll 66 | 67 | 68 | Library\UnityAssemblies\UnityEngine.HoloLens.dll 69 | 70 | 71 | Library\UnityAssemblies\UnityEngine.VR.dll 72 | 73 | 74 | Library\UnityAssemblies\UnityEditor.dll 75 | 76 | 77 | Library\UnityAssemblies\UnityEditor.iOS.Extensions.Xcode.dll 78 | 79 | 80 | Library\UnityAssemblies\UnityEditor.iOS.Extensions.Common.dll 81 | 82 | 83 | Assets\MeshBaker\scripts\MeshBakerCore.dll 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 | -------------------------------------------------------------------------------- /UnityVS.UnityToolDist.CSharp.Editor.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Debug 5 | AnyCPU 6 | 10.0.20506 7 | 2.0 8 | {792B9D95-53D9-C6A3-64B7-B5DFB1A25ACB} 9 | Library 10 | Assembly-CSharp-Editor 11 | 512 12 | {E097FAD1-6243-4DAD-9C02-E9B9EFC3FFC1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} 13 | .NETFramework 14 | v3.5 15 | Unity Full v3.5 16 | 17 | Editor:5 18 | StandaloneWindows:5 19 | 4.7.2f1 20 | 21 | 22 | 23 | pdbonly 24 | false 25 | Temp\UnityVS_bin\Debug\ 26 | Temp\UnityVS_obj\Debug\ 27 | prompt 28 | 4 29 | DEBUG;TRACE;UNITY_4_7_2;UNITY_4_7;UNITY_STANDALONE_WIN;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_UNITYEVENTS;ENABLE_NEW_HIERARCHY ;ENABLE_AUDIO_FMOD;UNITY_STANDALONE;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;INCLUDE_IL2CPP;INCLUDE_WP8SUPPORT;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_4_6_FEATURES;INCLUDE_WP_BLUE_SUPPORT;ENABLE_WEBCAM;INCLUDE_METROSUPPORT;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;UNITY5_SCRIPTING_IN_UNITY4;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_2D_PHYSICS;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_NAVMESH_CARVING;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_MONO;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE 30 | false 31 | 32 | 33 | pdbonly 34 | false 35 | Temp\UnityVS_bin\Release\ 36 | Temp\UnityVS_obj\Release\ 37 | prompt 38 | 4 39 | TRACE;UNITY_4_7_2;UNITY_4_7;UNITY_STANDALONE_WIN;ENABLE_MICROPHONE;ENABLE_TEXTUREID_MAP;ENABLE_UNITYEVENTS;ENABLE_NEW_HIERARCHY ;ENABLE_AUDIO_FMOD;UNITY_STANDALONE;ENABLE_TERRAIN;ENABLE_SUBSTANCE;ENABLE_GENERICS;INCLUDE_IL2CPP;INCLUDE_WP8SUPPORT;ENABLE_MOVIES;ENABLE_WWW;ENABLE_IMAGEEFFECTS;ENABLE_4_6_FEATURES;INCLUDE_WP_BLUE_SUPPORT;ENABLE_WEBCAM;INCLUDE_METROSUPPORT;RENDER_SOFTWARE_CURSOR;ENABLE_NETWORK;ENABLE_PHYSICS;UNITY5_SCRIPTING_IN_UNITY4;ENABLE_CACHING;ENABLE_CLOTH;ENABLE_2D_PHYSICS;ENABLE_SHADOWS;ENABLE_AUDIO;ENABLE_NAVMESH_CARVING;ENABLE_DUCK_TYPING;ENABLE_SINGLE_INSTANCE_BUILD_SETTING;ENABLE_MONO;ENABLE_PROFILER;UNITY_EDITOR;UNITY_EDITOR_WIN;UNITY_TEAM_LICENSE;UNITY_PRO_LICENSE 40 | false 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | Library\UnityAssemblies\UnityEngine.dll 53 | 54 | 55 | Library\UnityAssemblies\UnityEditor.dll 56 | 57 | 58 | Library\UnityAssemblies\UnityEngine.UI.dll 59 | 60 | 61 | Library\UnityAssemblies\UnityEditor.UI.dll 62 | 63 | 64 | Library\UnityAssemblies\UnityEditor.Graphs.dll 65 | 66 | 67 | Assets\UnityVS\Editor\SyntaxTree.VisualStudio.Unity.Bridge.dll 68 | 69 | 70 | Assets\UnityVS\Editor\SyntaxTree.VisualStudio.Unity.Messaging.dll 71 | 72 | 73 | Assets\UnityVS\Editor\UnityVS.VersionSpecific.dll 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | -------------------------------------------------------------------------------- /UnityVS.UnityToolDist.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 2015 4 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UnityVS.UnityToolDist.CSharp.Editor", "UnityVS.UnityToolDist.CSharp.Editor.csproj", "{792B9D95-53D9-C6A3-64B7-B5DFB1A25ACB}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Any CPU = Debug|Any CPU 9 | Release|Any CPU = Release|Any CPU 10 | EndGlobalSection 11 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 12 | {792B9D95-53D9-C6A3-64B7-B5DFB1A25ACB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 13 | {792B9D95-53D9-C6A3-64B7-B5DFB1A25ACB}.Debug|Any CPU.Build.0 = Debug|Any CPU 14 | {792B9D95-53D9-C6A3-64B7-B5DFB1A25ACB}.Release|Any CPU.ActiveCfg = Release|Any CPU 15 | {792B9D95-53D9-C6A3-64B7-B5DFB1A25ACB}.Release|Any CPU.Build.0 = Release|Any CPU 16 | EndGlobalSection 17 | GlobalSection(SolutionProperties) = preSolution 18 | HideSolutionNode = FALSE 19 | EndGlobalSection 20 | EndGlobal 21 | --------------------------------------------------------------------------------