// For Load void OnFinishedImagePicker(string message) { if (LoadTextureFromImagePicker.IsLoaded()) { int width, height; var orgTexWidth = LoadTextureFromImagePicker.GetLoadedTextureWidth(); var orgTexHeight = LoadTextureFromImagePicker.GetLoadedTextureHeight(); if (orgTexWidth > orgTexHeight) { width = Mathf.Min(orgTexWidth, maxTextureSize); height = width * orgTexHeight / orgTexWidth; } else { height = Mathf.Min(orgTexHeight, maxTextureSize); width = height * orgTexWidth / orgTexHeight; } bool mipmap = false; Texture2D texture = LoadTextureFromImagePicker.GetLoadedTexture(message, width, height, mipmap); if (texture != null) { // Load Texture ReplaceSprite(texture, width, height); } LoadTextureFromImagePicker.ReleaseLoadedImage(); } else { // Closed LoadTextureFromImagePicker.Release(); } }
// For Load void OnFinishedImagePicker(string message) { lastMessage = message; if (targetMaterial && LoadTextureFromImagePicker.IsLoaded()) { int width, height; if (bUseOriginalImageSize) { width = LoadTextureFromImagePicker.GetLoadedTextureWidth(); height = LoadTextureFromImagePicker.GetLoadedTextureHeight(); } else { width = textureWidth; height = textureHeight; } bool mipmap = true; Texture2D texture = LoadTextureFromImagePicker.GetLoadedTexture(message, width, height, mipmap); if (texture) { // Load Texture Texture lastTexture = targetMaterial.mainTexture; targetMaterial.mainTexture = texture; Destroy(lastTexture); if (isSaveToLocalFile) { // Save to local file LoadTextureFromImagePicker.SaveToLocalFile(saveTexFileName, texture); } } LoadTextureFromImagePicker.ReleaseLoadedImage(); } else { // Closed LoadTextureFromImagePicker.Release(); } }