QRC测试
This commit is contained in:
parent
a0dd67aa87
commit
f718efa04e
8
TheStrongestSnail/Assets/QRCodeShare.meta
Normal file
8
TheStrongestSnail/Assets/QRCodeShare.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bec599fa54b00bc4083b5ad1982969ef
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
TheStrongestSnail/Assets/QRCodeShare/Packages.meta
Normal file
8
TheStrongestSnail/Assets/QRCodeShare/Packages.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 448ef2c0eecf08e40a75b40b87eb66a8
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc250842edadef9449789dacf1d1c519
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
TheStrongestSnail/Assets/QRCodeShare/Packages/ZXing.Net.0.16.9/lib.meta
vendored
Normal file
8
TheStrongestSnail/Assets/QRCodeShare/Packages/ZXing.Net.0.16.9/lib.meta
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0bb20b9e9e81a7c41af680000f434910
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
TheStrongestSnail/Assets/QRCodeShare/Packages/ZXing.Net.0.16.9/lib/netstandard2.1.meta
vendored
Normal file
8
TheStrongestSnail/Assets/QRCodeShare/Packages/ZXing.Net.0.16.9/lib/netstandard2.1.meta
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 872e105bef1ff2941a97e3f59dda7275
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
TheStrongestSnail/Assets/QRCodeShare/Packages/ZXing.Net.0.16.9/lib/netstandard2.1/ZXing.Unity.dll
vendored
Normal file
BIN
TheStrongestSnail/Assets/QRCodeShare/Packages/ZXing.Net.0.16.9/lib/netstandard2.1/ZXing.Unity.dll
vendored
Normal file
Binary file not shown.
@ -0,0 +1,35 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6c15d988b2bf6bb4eaeec9006b012ad2
|
||||
labels:
|
||||
- NuGetForUnity
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
TheStrongestSnail/Assets/QRCodeShare/Packages/ZXing.Net.0.16.9/lib/netstandard2.1/zxing.dll
vendored
Normal file
BIN
TheStrongestSnail/Assets/QRCodeShare/Packages/ZXing.Net.0.16.9/lib/netstandard2.1/zxing.dll
vendored
Normal file
Binary file not shown.
35
TheStrongestSnail/Assets/QRCodeShare/Packages/ZXing.Net.0.16.9/lib/netstandard2.1/zxing.dll.meta
vendored
Normal file
35
TheStrongestSnail/Assets/QRCodeShare/Packages/ZXing.Net.0.16.9/lib/netstandard2.1/zxing.dll.meta
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ab2d6a21ac1b4554a81dcb38ca013547
|
||||
labels:
|
||||
- NuGetForUnity
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
Windows Store Apps: WindowsStoreApps
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
TheStrongestSnail/Assets/QRCodeShare/Plugins.meta
Normal file
8
TheStrongestSnail/Assets/QRCodeShare/Plugins.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f9006c5e8d3a6fb45ac43c84ba471675
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,44 @@
|
||||
mergeInto(LibraryManager.library, {
|
||||
|
||||
DownloadFile: function (fileName, base64Data) {
|
||||
var a = document.createElement("a"); //Create <a>
|
||||
a.href = "data:image/png;base64," + UTF8ToString(base64Data); //Image Base64 Goes here
|
||||
a.download = UTF8ToString(fileName); //File name Here
|
||||
a.style.display = 'none';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
},
|
||||
|
||||
UploadFile: function (callbackMethodName) {
|
||||
var input = document.createElement("input");
|
||||
input.type = "file";
|
||||
input.accept = "image/png";
|
||||
|
||||
input.onchange = function (event) {
|
||||
var file = event.target.files[0];
|
||||
if (file) {
|
||||
// Check if the file is a PNG or JPEG
|
||||
if(file.type === "image/png" || file.type === "image/jpeg") {
|
||||
const reader = new FileReader();
|
||||
reader.onload = function(event) {
|
||||
const img = new Image();
|
||||
img.onload = function() {
|
||||
const canvas = document.createElement('canvas');
|
||||
canvas.width = img.width;
|
||||
canvas.height = img.height;
|
||||
const ctx = canvas.getContext('2d');
|
||||
ctx.drawImage(img, 0, 0);
|
||||
// Convert to PNG format
|
||||
const base64String = canvas.toDataURL('image/png');
|
||||
{{{ makeDynCall('vi', 'callbackMethodName') }}} (stringToNewUTF8(base64String));
|
||||
};
|
||||
img.src = event.target.result;
|
||||
};
|
||||
reader.readAsDataURL(file);
|
||||
}
|
||||
}
|
||||
};
|
||||
input.click();
|
||||
}
|
||||
});
|
@ -0,0 +1,77 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e7046c8ffa484ed448ad124360c1d5d1
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
: Any
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
Exclude Android: 1
|
||||
Exclude Editor: 0
|
||||
Exclude Linux64: 1
|
||||
Exclude OSXUniversal: 1
|
||||
Exclude WebGL: 0
|
||||
Exclude Win: 1
|
||||
Exclude Win64: 1
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
AndroidSharedLibraryType: Executable
|
||||
CPU: ARMv7
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 1
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
DefaultValueInitialized: true
|
||||
OS: AnyOS
|
||||
- first:
|
||||
Standalone: Linux64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: OSXUniversal
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
Standalone: Win64
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
CPU: AnyCPU
|
||||
- first:
|
||||
WebGL: WebGL
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
21
TheStrongestSnail/Assets/QRCodeShare/README.md
Normal file
21
TheStrongestSnail/Assets/QRCodeShare/README.md
Normal file
@ -0,0 +1,21 @@
|
||||
#### QR Code Sharing System
|
||||
|
||||
Enable players to share the puzzles they create with friends or on social media without diving into the complexities of multiplayer modes or requiring identifiable accounts. Integrate this QR Code sharing system into your game, inspired by the QR Code sharing system of [Mekorama](https://www.mekorama.com/) (not affiliated).
|
||||
|
||||
To use this asset, first drag the **Packages** folder containing [ZXing.net](https://github.com/micjahn/ZXing.Net) to the root **Assets** Folder. ZXing is the base library that allows this asset to handle QR Codes.
|
||||
|
||||
Next, you can run the demo scene in the **DemoScene** folder (target platform: WebGL / need TextMesh Pro). The asset itself is cross-platform; you'll just need to write your own upload and download file system for other platforms. Here are some excellent free assets to get you started (not affiliated).
|
||||
|
||||
- (Desktop) [Runtime File Browser](https://assetstore.unity.com/packages/tools/gui/runtime-file-browser-113006) by yasirkula
|
||||
- (Mobile) [Native Gallery for Android & iOS](https://assetstore.unity.com/packages/tools/integration/native-gallery-for-android-ios-112630) by yasirkula
|
||||
|
||||
There is also an online version of the demo scene [here](https://devilintheeden.itch.io/qrcode-share-demo) if you want to try it out.
|
||||
|
||||
**Clarification**: The local version include with the asset doesn't allow outside copy & paste. This is a known issue for Unity3D webGL build. Look at this [thread](https://forum.unity.com/threads/copy-paste-in-textfields-in-webgl-builds.1291664/) for possible solutions.
|
||||
|
||||
**Demo Art Resource Source**:
|
||||
|
||||
1. Milk tea Logo: from [svgrepo](https://www.svgrepo.com/svg/530622/milk-tea) under CC0 license.
|
||||
2. Flight Logo: from [svgrepo](https://www.svgrepo.com/svg/438544/flight-round) under GP license.
|
||||
3. Background Image: I take the photo myself in San Diego, California.
|
||||
|
7
TheStrongestSnail/Assets/QRCodeShare/README.md.meta
Normal file
7
TheStrongestSnail/Assets/QRCodeShare/README.md.meta
Normal file
@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e1b79493b2ef5fb4a84602660d0820f3
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
TheStrongestSnail/Assets/QRCodeShare/Scripts.meta
Normal file
8
TheStrongestSnail/Assets/QRCodeShare/Scripts.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a8015a2b8ba48f949baa50a8634d9b31
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
120
TheStrongestSnail/Assets/QRCodeShare/Scripts/ImageProcessing.cs
Normal file
120
TheStrongestSnail/Assets/QRCodeShare/Scripts/ImageProcessing.cs
Normal file
@ -0,0 +1,120 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QRCodeShareMain
|
||||
{
|
||||
public static class ImageProcessing
|
||||
{
|
||||
public static Texture2D ResizeTexture(Texture2D source, int width, int height)
|
||||
{
|
||||
Texture2D result = new Texture2D(width, height, source.format, false);
|
||||
Color[] resizedPixels = new Color[width * height];
|
||||
float xRatio = (float)source.width / width;
|
||||
float yRatio = (float)source.height / height;
|
||||
|
||||
for (int y = 0; y < height; y++)
|
||||
{
|
||||
for (int x = 0; x < width; x++)
|
||||
{
|
||||
float px = x * xRatio;
|
||||
float py = y * yRatio;
|
||||
resizedPixels[y * width + x] = source.GetPixelBilinear(px / source.width, py / source.height);
|
||||
}
|
||||
}
|
||||
|
||||
result.SetPixels(resizedPixels);
|
||||
result.Apply();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
public static Texture2D AddPadding(Texture2D original, int top, int bottom, int left, int right, Color paddingColor)
|
||||
{
|
||||
int newWidth = original.width + left + right;
|
||||
int newHeight = original.height + top + bottom;
|
||||
|
||||
Texture2D paddedTexture = new Texture2D(newWidth, newHeight);
|
||||
|
||||
// Filling the background padding color
|
||||
Color[] paddingColors = new Color[newWidth * newHeight];
|
||||
System.Array.Fill(paddingColors, paddingColor);
|
||||
paddedTexture.SetPixels(paddingColors);
|
||||
|
||||
// Copy the original texture into the desired position
|
||||
for (int y = 0; y < original.height; y++)
|
||||
{
|
||||
for (int x = 0; x < original.width; x++)
|
||||
{
|
||||
paddedTexture.SetPixel(x + left, y + bottom, original.GetPixel(x, y));
|
||||
}
|
||||
}
|
||||
|
||||
paddedTexture.Apply();
|
||||
return paddedTexture;
|
||||
}
|
||||
|
||||
public static Texture2D CropTexture(Texture2D originalTexture, int top, int bottom, int left, int right)
|
||||
{
|
||||
int newWidth = originalTexture.width - left - right;
|
||||
int newHeight = originalTexture.height - top - bottom;
|
||||
|
||||
if (newWidth <= 0 || newHeight <= 0)
|
||||
{
|
||||
Debug.LogError("Invalid margins provided. The resulting cropped texture would have non-positive dimensions.");
|
||||
return null;
|
||||
}
|
||||
|
||||
Color[] pixels = originalTexture.GetPixels(left, bottom, newWidth, newHeight);
|
||||
|
||||
Texture2D croppedTexture = new Texture2D(newWidth, newHeight);
|
||||
croppedTexture.SetPixels(pixels);
|
||||
croppedTexture.Apply();
|
||||
|
||||
return croppedTexture;
|
||||
}
|
||||
|
||||
|
||||
// The BlendImage function only support front image that has an alpha value of 1, it doesn't support semi-transparent pixels for now
|
||||
// center is the center position of the front image on the background image, the image would get cropped if it is outside the boundary
|
||||
public static Texture2D BlendImages(Texture2D frontImage, Texture2D backgroundImage, Vector2Int center)
|
||||
{
|
||||
Texture2D blendedTexture = new Texture2D(backgroundImage.width, backgroundImage.height);
|
||||
|
||||
int offsetX = center.x - (frontImage.width / 2);
|
||||
int offsetY = center.y - (frontImage.height / 2);
|
||||
|
||||
Texture2D frontImageCropped = CropTexture(frontImage, offsetY < 0 ? -offsetY : 0, 0, offsetX < 0 ? -offsetX : 0, 0);
|
||||
offsetX = Mathf.Max(0, offsetX);
|
||||
offsetY = Mathf.Max(0, offsetY);
|
||||
for (int x = 0; x < backgroundImage.width; x++)
|
||||
{
|
||||
for (int y = 0; y < backgroundImage.height; y++)
|
||||
{
|
||||
Color backgroundPixel = backgroundImage.GetPixel(x, y);
|
||||
Color blendedPixel = backgroundPixel;
|
||||
if (x > offsetX && x < offsetX + frontImageCropped.width && y > offsetY && y < offsetY + frontImageCropped.height)
|
||||
{
|
||||
Color frontPixel = frontImageCropped.GetPixel(x - offsetX, y - offsetY);
|
||||
blendedPixel = (frontPixel.a > 0.99f) ? frontPixel : blendedPixel;
|
||||
}
|
||||
blendedTexture.SetPixel(x, y, blendedPixel);
|
||||
}
|
||||
}
|
||||
blendedTexture.Apply();
|
||||
return blendedTexture;
|
||||
}
|
||||
|
||||
|
||||
public static Sprite ConvertTexture2DToSprite(Texture2D texture)
|
||||
{
|
||||
return Sprite.Create(
|
||||
texture,
|
||||
new Rect(0, 0, texture.width, texture.height),
|
||||
new Vector2(0.5f, 0.5f)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d118da4d6b1e7404f873726ead46bdb7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
96
TheStrongestSnail/Assets/QRCodeShare/Scripts/QRCodeShare.cs
Normal file
96
TheStrongestSnail/Assets/QRCodeShare/Scripts/QRCodeShare.cs
Normal file
@ -0,0 +1,96 @@
|
||||
using UnityEngine;
|
||||
using ZXing;
|
||||
using ZXing.QrCode;
|
||||
using ZXing.Unity;
|
||||
|
||||
namespace QRCodeShareMain
|
||||
{
|
||||
public static class QRCodeShare
|
||||
{
|
||||
public static string ReadQRCodeImage(Texture2D qrCodeImage)
|
||||
{
|
||||
if (qrCodeImage == null)
|
||||
{
|
||||
Debug.LogError("Invalid Image for extraction!");
|
||||
return null;
|
||||
}
|
||||
|
||||
// create a reader with a custom luminance source
|
||||
var reader = new BarcodeReader();
|
||||
var result = reader.Decode(qrCodeImage.GetPixels32(), qrCodeImage.width, qrCodeImage.height);
|
||||
if (result != null)
|
||||
{
|
||||
return result.Text;
|
||||
}
|
||||
|
||||
Debug.LogError("No Result Extracted from Image!");
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Texture2D CreateQRCodeImage(string content)
|
||||
{
|
||||
var writer = new BarcodeWriter
|
||||
{
|
||||
Format = BarcodeFormat.QR_CODE,
|
||||
Options = new QrCodeEncodingOptions
|
||||
{
|
||||
Margin = 0
|
||||
}
|
||||
};
|
||||
Color32Image color32Image = writer.Write(content);
|
||||
Color32[] colors = color32Image.Pixels;
|
||||
Texture2D texture = new Texture2D(color32Image.Width, color32Image.Height, TextureFormat.RGBA32, false);
|
||||
texture.SetPixels32(colors);
|
||||
texture.Apply();
|
||||
return texture;
|
||||
}
|
||||
|
||||
public static Texture2D CreateQRCodeImage(string content, QRImageProperties properties)
|
||||
{
|
||||
int minSize = QRCodeMinimumSize(content).x;
|
||||
int shorterEdge = Mathf.Min(properties.Width, properties.Height); // the shorter in width and height
|
||||
int targetSize = (Mathf.Max(properties.Width, properties.Width) / minSize + 1) * minSize; // ZXing.net doesn't support non-integer resizing
|
||||
// Give out warning for fallback to min size QR Code
|
||||
if (shorterEdge < minSize)
|
||||
{
|
||||
Debug.LogWarning("Width or height is smaller than minimum QR Code Size. Size Setting ignored. Fallback to Min Size QR Code.");
|
||||
}
|
||||
|
||||
// Create a target size no margin QR Code
|
||||
var writer = new BarcodeWriter
|
||||
{
|
||||
Format = BarcodeFormat.QR_CODE,
|
||||
Options = new QrCodeEncodingOptions
|
||||
{
|
||||
Width = shorterEdge >= minSize ? targetSize : 0, // if shorter edge smaller than min size, fallback to min size QR Code
|
||||
Height = shorterEdge >= minSize ? targetSize : 0,
|
||||
Margin = 0
|
||||
}
|
||||
};
|
||||
((Color32Renderer)writer.Renderer).Foreground = properties.ForegroundColor;
|
||||
((Color32Renderer)writer.Renderer).Background = properties.BackgroundColor;
|
||||
Color32Image color32Image = writer.Write(content);
|
||||
Color32[] colors = color32Image.Pixels;
|
||||
Texture2D texture = new Texture2D(color32Image.Width, color32Image.Height, TextureFormat.RGBA32, false);
|
||||
texture.SetPixels32(colors);
|
||||
texture.Apply();
|
||||
|
||||
// Resize the QR Code to the desired size
|
||||
if (shorterEdge >= minSize)
|
||||
{
|
||||
texture = ImageProcessing.ResizeTexture(texture, properties.Width, properties.Height);
|
||||
}
|
||||
|
||||
Texture2D paddedTexture = ImageProcessing.AddPadding(texture, properties.TopMargin, properties.BottomMargin,
|
||||
properties.LeftMargin, properties.RightMargin, properties.PaddingColor);
|
||||
return paddedTexture;
|
||||
}
|
||||
|
||||
// Get the minimum size for the QR Code based on the content string
|
||||
public static Vector2Int QRCodeMinimumSize(string content)
|
||||
{
|
||||
Texture2D t = CreateQRCodeImage(content);
|
||||
return new Vector2Int(t.width, t.height);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5e9e583517b89244fa9ec079316c37ac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -0,0 +1,236 @@
|
||||
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace QRCodeShareMain
|
||||
{
|
||||
public class QRImageProperties
|
||||
{
|
||||
private int _width; // without margin
|
||||
private int _height; // without margin
|
||||
private int _topMargin;
|
||||
private int _bottomMargin;
|
||||
private int _leftMargin;
|
||||
private int _rightMargin;
|
||||
|
||||
private Color32 _foregroundColor;
|
||||
private Color32 _backgroundColor;
|
||||
private Color32 _paddingColor;
|
||||
|
||||
|
||||
public QRImageProperties()
|
||||
{
|
||||
_width = 0;
|
||||
_height = 0;
|
||||
_topMargin = 0;
|
||||
_bottomMargin = 0;
|
||||
_leftMargin = 0;
|
||||
_rightMargin = 0;
|
||||
_foregroundColor = Color.black;
|
||||
_backgroundColor = Color.white;
|
||||
_paddingColor = Color.white;
|
||||
}
|
||||
|
||||
public QRImageProperties(int width, int height, int topMargin, int bottomMargin, int leftMargin,
|
||||
int rightMargin, Color32 foregroundColor, Color32 backgroundColor, Color32 paddingColor)
|
||||
{
|
||||
if (width < 0 || height < 0 || topMargin < 0 || bottomMargin < 0 || leftMargin < 0 || rightMargin < 0)
|
||||
throw new ArgumentException("All dimensions and margins must be non-negative.");
|
||||
|
||||
if (width > height * 1.5f || height > width * 1.5f)
|
||||
{
|
||||
Debug.LogWarning("One edge of the QR Code would be greater than 1.5 times the other edge. it is not recommended because it may cause problems when scanning.");
|
||||
}
|
||||
_width = width;
|
||||
_height = height;
|
||||
_topMargin = topMargin;
|
||||
_bottomMargin = bottomMargin;
|
||||
_leftMargin = leftMargin;
|
||||
_rightMargin = rightMargin;
|
||||
_foregroundColor = foregroundColor;
|
||||
_backgroundColor = backgroundColor;
|
||||
_paddingColor = paddingColor;
|
||||
}
|
||||
|
||||
public QRImageProperties(int width, int height, int margin)
|
||||
{
|
||||
if (width < 0 || height < 0 || margin < 0)
|
||||
throw new ArgumentException("All dimensions and margins must be non-negative.");
|
||||
if (width > height * 1.5f || height > width * 1.5f)
|
||||
{
|
||||
Debug.LogWarning("One edge of the QR Code would be greater than 1.5 times the other edge. it is not recommended because it may cause problems when scanning.");
|
||||
}
|
||||
_width = width;
|
||||
_height = height;
|
||||
_topMargin = margin;
|
||||
_bottomMargin = margin;
|
||||
_leftMargin = margin;
|
||||
_rightMargin = margin;
|
||||
_foregroundColor = Color.black;
|
||||
_backgroundColor = Color.white;
|
||||
_paddingColor = Color.white;
|
||||
}
|
||||
|
||||
public int Width
|
||||
{
|
||||
get => _width;
|
||||
set
|
||||
{
|
||||
if (value <= 0)
|
||||
throw new ArgumentException("Width must be positive");
|
||||
_width = value;
|
||||
if (_width > _height * 1.5f || _height > _width * 1.5f)
|
||||
{
|
||||
Debug.LogWarning("One edge of the QR Code would be greater than 1.5 times the other edge. it is not recommended because it may cause problems when scanning.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int Height
|
||||
{
|
||||
get => _height;
|
||||
set
|
||||
{
|
||||
if (value <= 0)
|
||||
throw new ArgumentException("Height must be positive");
|
||||
_height = value;
|
||||
if (_width > _height * 1.5f || _height > _width * 1.5f)
|
||||
{
|
||||
Debug.LogWarning("One edge of the QR Code would be greater than 1.5 times the other edge. it is not recommended because it may cause problems when scanning.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int TopMargin
|
||||
{
|
||||
get => _topMargin;
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
throw new ArgumentException("TopMargin cannot be negative");
|
||||
_topMargin = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int BottomMargin
|
||||
{
|
||||
get => _bottomMargin;
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
throw new ArgumentException("BottomMargin cannot be negative");
|
||||
_bottomMargin = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int LeftMargin
|
||||
{
|
||||
get => _leftMargin;
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
throw new ArgumentException("LeftMargin cannot be negative");
|
||||
_leftMargin = value;
|
||||
}
|
||||
}
|
||||
|
||||
public int RightMargin
|
||||
{
|
||||
get => _rightMargin;
|
||||
set
|
||||
{
|
||||
if (value < 0)
|
||||
throw new ArgumentException("RightMargin cannot be negative");
|
||||
_rightMargin = value;
|
||||
}
|
||||
}
|
||||
|
||||
// Outer width with padding
|
||||
public int OuterWidth
|
||||
{
|
||||
get => _width + _leftMargin + _rightMargin;
|
||||
set
|
||||
{
|
||||
if (value - _leftMargin - _rightMargin < 0)
|
||||
throw new ArgumentException("Width cannot be negative");
|
||||
|
||||
_width = value - _leftMargin - _rightMargin;
|
||||
}
|
||||
}
|
||||
|
||||
// Outer height with padding
|
||||
public int OuterHeight
|
||||
{
|
||||
get => _height + _topMargin + _bottomMargin;
|
||||
set
|
||||
{
|
||||
if (value - _topMargin - _bottomMargin < 0)
|
||||
throw new ArgumentException("Height cannot be negative");
|
||||
|
||||
_height = value - _topMargin - _bottomMargin;
|
||||
}
|
||||
}
|
||||
|
||||
public Color32 ForegroundColor
|
||||
{
|
||||
get => _foregroundColor;
|
||||
set => _foregroundColor = value;
|
||||
}
|
||||
|
||||
public Color32 BackgroundColor
|
||||
{
|
||||
get => _backgroundColor;
|
||||
set => _backgroundColor = value;
|
||||
}
|
||||
|
||||
public Color32 PaddingColor
|
||||
{
|
||||
get => _paddingColor;
|
||||
set => _paddingColor = value;
|
||||
}
|
||||
|
||||
// Method to set uniform margin
|
||||
public void SetUniformMargin(int margin)
|
||||
{
|
||||
_topMargin = margin;
|
||||
_bottomMargin = margin;
|
||||
_leftMargin = margin;
|
||||
_rightMargin = margin;
|
||||
}
|
||||
|
||||
// Method to set all margins
|
||||
public void SetAllMargins(int topMargin, int bottomMargin, int leftMargin,
|
||||
int rightMargin)
|
||||
{
|
||||
_topMargin = topMargin;
|
||||
_bottomMargin = bottomMargin;
|
||||
_leftMargin = leftMargin;
|
||||
_rightMargin = rightMargin;
|
||||
}
|
||||
|
||||
// Method to set all colors
|
||||
public void SetAllColors(Color32 foregroundColor, Color32 backgroundColor, Color32 paddingColor)
|
||||
{
|
||||
_foregroundColor = foregroundColor;
|
||||
_backgroundColor = backgroundColor;
|
||||
_paddingColor = paddingColor;
|
||||
}
|
||||
|
||||
public Vector2Int GetQRCodeCenter()
|
||||
{
|
||||
return new Vector2Int(LeftMargin + Width / 2, BottomMargin + Height / 2);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return
|
||||
$"Width: {Width}, Height: {Height}, " +
|
||||
$"Top Margin: {TopMargin}, Bottom Margin: {BottomMargin}, Left Margin: {LeftMargin}, Right Margin: {RightMargin}, " +
|
||||
$"Outer Width: {OuterWidth}, Outer Height: {OuterHeight}" +
|
||||
$"Foreground Color: {ForegroundColor}, Background Color: {BackgroundColor}, Padding Color: {PaddingColor}";
|
||||
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b88de1cb4f813d44b602dae8995cbad
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
TheStrongestSnail/Assets/QRCodeShare/Sprites.meta
Normal file
8
TheStrongestSnail/Assets/QRCodeShare/Sprites.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 926e7a42b54df4b20b3c6e37cfe52cad
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 9.9 KiB |
@ -0,0 +1,153 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b32a1e102fa60ca4499387006bfd26ca
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 1
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 4
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
TheStrongestSnail/Assets/QRCodeShare/Sprites/milk-tea-256.png
Normal file
BIN
TheStrongestSnail/Assets/QRCodeShare/Sprites/milk-tea-256.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.3 KiB |
@ -0,0 +1,153 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 56279b26c3fce41c29144a6e2ebf7669
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 1
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 4
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Binary file not shown.
After Width: | Height: | Size: 1.0 MiB |
@ -0,0 +1,153 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9cefec6094b9d354b9be85584b3af7c2
|
||||
TextureImporter:
|
||||
internalIDToNameTable: []
|
||||
externalObjects: {}
|
||||
serializedVersion: 12
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 1
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
flipGreenChannel: 0
|
||||
isReadable: 1
|
||||
streamingMipmaps: 0
|
||||
streamingMipmapsPriority: 0
|
||||
vTOnly: 0
|
||||
ignoreMipmapLimit: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: 1
|
||||
aniso: 1
|
||||
mipBias: 0
|
||||
wrapU: 0
|
||||
wrapV: 0
|
||||
wrapW: 0
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 100
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 0
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
singleChannelComponent: 0
|
||||
flipbookRows: 1
|
||||
flipbookColumns: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
ignorePngGamma: 0
|
||||
applyGammaDecoding: 0
|
||||
swizzle: 50462976
|
||||
cookieLightType: 0
|
||||
platformSettings:
|
||||
- serializedVersion: 3
|
||||
buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: 4
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: WebGL
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Android
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
- serializedVersion: 3
|
||||
buildTarget: Server
|
||||
maxTextureSize: 2048
|
||||
resizeAlgorithm: 0
|
||||
textureFormat: -1
|
||||
textureCompression: 1
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
ignorePlatformSupport: 0
|
||||
androidETC2FallbackOverride: 0
|
||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
bones: []
|
||||
spriteID:
|
||||
internalID: 0
|
||||
vertices: []
|
||||
indices:
|
||||
edges: []
|
||||
weights: []
|
||||
secondaryTextures: []
|
||||
nameFileIdTable: {}
|
||||
mipmapLimitGroupName:
|
||||
pSDRemoveMatte: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
83
TheStrongestSnail/Assets/Scripts/ToFriend.cs
Normal file
83
TheStrongestSnail/Assets/Scripts/ToFriend.cs
Normal file
@ -0,0 +1,83 @@
|
||||
using Newtonsoft.Json;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using QRCodeShareMain;
|
||||
using static Cinemachine.CinemachineBlendDefinition;
|
||||
using TMPro;
|
||||
|
||||
public class ToFriend : MonoBehaviour
|
||||
{
|
||||
public Image Tofrienf;
|
||||
private Texture2D currentQRCodeGenerate = null;
|
||||
public UserInfomation14 userInfomation14;
|
||||
public Button SaveButton;
|
||||
// Start is called before the first frame update
|
||||
async void Start()
|
||||
{
|
||||
Dictionary<string, string> head14 = new Dictionary<string, string>
|
||||
{
|
||||
{ "Authorization", Global.global.serverResponse.data.token }
|
||||
};
|
||||
|
||||
// 异步查询玩家信息
|
||||
string response14 = await web.SendRequest(web.URL + "/snail/user/queryUserInfo", "POST", "{}", head14);
|
||||
Debug.Log("1.4查询玩家信息" + response14);
|
||||
userInfomation14 = JsonConvert.DeserializeObject<UserInfomation14>(response14);
|
||||
OnClickGenerateQRCode(userInfomation14.data.inviteCodeMy);
|
||||
SaveButton.onClick.AddListener((() =>
|
||||
{
|
||||
StartCoroutine(TakeScreenshotAndSave());
|
||||
}));
|
||||
}
|
||||
private IEnumerator TakeScreenshotAndSave()
|
||||
{
|
||||
yield return new WaitForEndOfFrame();
|
||||
|
||||
Texture2D ss = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false);
|
||||
ss.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0);
|
||||
ss.Apply();
|
||||
|
||||
// Save the screenshot to Gallery/Photos
|
||||
NativeGallery.Permission permission = NativeGallery.SaveImageToGallery(ss, "GalleryTest", "Image.png", (success, path) => Debug.Log("Media save result: " + path + " " + path));
|
||||
|
||||
Debug.Log("Permission result: " + permission);
|
||||
|
||||
// To avoid memory leaks
|
||||
Destroy(ss);
|
||||
}
|
||||
private void OnClickGenerateQRCode(string content)
|
||||
{
|
||||
currentQRCodeGenerate = HelloWorldQRCode(content);
|
||||
|
||||
if (currentQRCodeGenerate != null)
|
||||
{
|
||||
ShowImage(Tofrienf, currentQRCodeGenerate);
|
||||
// Enable the download image button is the texture is not null
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
private void ShowImage(Image showImage, Texture2D image)
|
||||
{
|
||||
showImage.sprite = ImageProcessing.ConvertTexture2DToSprite(image);
|
||||
float imageSize = Mathf.Max(showImage.GetComponent<RectTransform>().sizeDelta.x, showImage.GetComponent<RectTransform>().sizeDelta.y);
|
||||
|
||||
showImage.GetComponent<RectTransform>().sizeDelta = image.width <= image.height ?
|
||||
new Vector2(imageSize / image.height * image.width, imageSize) :
|
||||
new Vector2(imageSize, imageSize * image.height / image.width);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
private Texture2D HelloWorldQRCode(string content)
|
||||
{
|
||||
QRImageProperties properties = new QRImageProperties(500, 500, 50);
|
||||
Texture2D QRCodeImage = QRCodeShare.CreateQRCodeImage(content, properties);
|
||||
return QRCodeImage;
|
||||
}
|
||||
}
|
11
TheStrongestSnail/Assets/Scripts/ToFriend.cs.meta
Normal file
11
TheStrongestSnail/Assets/Scripts/ToFriend.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 858689fc59c57ee4785593706bc446bd
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@ -793,6 +793,7 @@ GameObject:
|
||||
- component: {fileID: 8503404559117813739}
|
||||
- component: {fileID: 8503404559117813736}
|
||||
- component: {fileID: 8503404559117813737}
|
||||
- component: {fileID: 4223448009444047303}
|
||||
m_Layer: 5
|
||||
m_Name: ToFriend
|
||||
m_TagString: Untagged
|
||||
@ -917,6 +918,42 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
retbutton: {fileID: 8503404559117813736}
|
||||
ClosureObj: {fileID: 8503404559117813749}
|
||||
--- !u!114 &4223448009444047303
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8503404559117813749}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 858689fc59c57ee4785593706bc446bd, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Tofrienf: {fileID: 8503404558082051258}
|
||||
userInfomation14:
|
||||
code: 0
|
||||
message:
|
||||
data:
|
||||
userId: 0
|
||||
userName: 0
|
||||
token:
|
||||
nickName:
|
||||
headImg:
|
||||
gender: 0
|
||||
birthday:
|
||||
voluteCoin: 0
|
||||
beansCoin: 0
|
||||
ichorCoin: 0
|
||||
idCard:
|
||||
inviteCodeMy:
|
||||
inviteCodeBind:
|
||||
bindTime:
|
||||
station: 0
|
||||
cuteNo:
|
||||
menberTime:
|
||||
isMember: 0
|
||||
SaveButton: {fileID: 6459671933226748291}
|
||||
--- !u!1 &8503404559183846966
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -928,6 +965,7 @@ GameObject:
|
||||
- component: {fileID: 8503404559183846965}
|
||||
- component: {fileID: 8503404559183846955}
|
||||
- component: {fileID: 8503404559183846964}
|
||||
- component: {fileID: 6459671933226748291}
|
||||
m_Layer: 5
|
||||
m_Name: save
|
||||
m_TagString: Untagged
|
||||
@ -994,6 +1032,50 @@ MonoBehaviour:
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &6459671933226748291
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8503404559183846966}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 8503404559183846964}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!1 &8503404559235756192
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
Loading…
Reference in New Issue
Block a user