//------------------------------------------------------------------------------------------------------------------ private void DrawProTexTextureField(ProTexMaterialBinder proTexMaterialBinder) { if (Event.current.commandName == "ObjectSelectorUpdated") { var newProTexTexture = EditorGUIUtility.GetObjectPickerObject() as ProTexTexture; if (newProTexTexture != null) { SetProTexTexture(proTexMaterialBinder, newProTexTexture); } } else { var oldProTexTexture = proTexMaterialBinder.proTexTexture; var newProTexTexture = (ProTexTexture)EditorGUILayout.ObjectField( "ProTexTexture", oldProTexTexture, typeof(ProTexTexture), false); if (newProTexTexture != oldProTexTexture) { SetProTexTexture(proTexMaterialBinder, newProTexTexture); } } }
//------------------------------------------------------------------------------------------------------------------ private void DrawTextureSizeSelector(ProTexMaterialBinder proTexMaterialBinder) { TextureSize textureSize = GetTextureSize(proTexMaterialBinder); TextureSize newTextureSize = (TextureSize)EditorGUILayout.EnumPopup(textureSize); if (textureSize != newTextureSize) { proTexMaterialBinder.runtimeTextureSize = (int)newTextureSize; } }
//------------------------------------------------------------------------------------------------------------------ private TextureSize GetTextureSize(ProTexMaterialBinder proTexMaterialBinder) { int textureSize = proTexMaterialBinder.runtimeTextureSize; foreach (var size in Enum.GetValues(typeof(TextureSize))) { if (Convert.ToInt32(size) >= textureSize) { return((TextureSize)size); } } return(TextureSize.TextureSize256x256); }
//------------------------------------------------------------------------------------------------------------------ private void SetProTexTexture(ProTexMaterialBinder proTexMaterialBinder, ProTexTexture proTexTexture) { if ((proTexTexture == null) || (proTexTexture.GetVersionNumber() <= ProTexTexture.VersionNumber)) { proTexMaterialBinder.proTexTexture = proTexTexture; proTexMaterialBinder.SetEditorPreviewTextures(); EditorSceneManager.MarkSceneDirty(proTexMaterialBinder.gameObject.scene); } else { EditorUtility.DisplayDialog( "Invalid texture version", "The selected ProTexTexture version is newer than the current version", "OK"); } }