Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Copyright (c) UserJoy Technology
- * All Rights Reserved.
- */
- using UnityEditor;
- using UnityEngine;
- using System.Reflection;
- namespace Edit.Postprocessor {
- public sealed class TextureReviewer : AssetPostprocessor {
- #region AssetPostprocessor Hooks
- void OnPreprocessTexture() {
- // Unity Code Snippet: Getting the original size of a Texture2D
- // http://philippseifried.com/blog/2012/07/30/unity3d-code-original-texture-siz/
- var textureImporter = (TextureImporter) assetImporter;
- if (textureImporter != null) {
- var args = new object[2] { 0, 0 };
- MethodInfo mi = typeof(TextureImporter).GetMethod("GetWidthAndHeight", BindingFlags.NonPublic | BindingFlags.Instance);
- mi.Invoke(textureImporter, args);
- int width = (int) args[0];
- int height = (int) args[1];
- if (width > 2048 || height > 2048) {
- Debug.LogError(string.Format("texture width or height must small than 4096, width:{0}, height:{1}", width, height));
- }
- }
- }
- #endregion
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement