18.
QRコード読み取り
using ZXing;
using ZXing.QrCode;
public class Sample {
public string Read()
{
var reader = new BarcodeReader();
Color32[] color = new Color32();
int width = 256;
int height = 256;
Result result = reader.Decode(color, width, height);
return result.text;
}
}
19.
カメラからとる場合
using ZXing;
using ZXing.QrCode;
public class Sample {
public WebCamTexture cameraTexture;
public string Read()
{
var reader = new BarcodeReader();
Color32 color = cameraTexture.GetPixels32();
int width = cameraTexture.width;
int height = cameraTexture.height;
Result result = reader.Decode(color, width, height);
return result.text;
}
}
20.
QRコード画像生成
public Color32[] Write(string content, int width, int height)
{
var writer = new BarcodeWriter
{
Format = BarcodeFormat.QR_CODE,
Options = new QrCodeEncodingOptions
{
Height = height,
Width = width
}
};
return writer.Write(content);
}
21.
QRコード画像生成
using ZXing;
using ZXing.QrCode;
public class Sample {
public Texture2D texture;
public void CreateQRCode()
{
var qrCodeColors = Write( hoge , 256, 256);
texture.SetPixels32(qrCodeColors);
texture.Apply();
}
}
35.
public class EventMessage : ScriptableObject {
public int eventId;
public string message;
public string GenerateEventMessage(Dao.Log model)
{
string generateMessage = message;
foreach(var p in model.parameters)
{
generateMessage = generateMessage.Replace("$" + p.Key, p.Value);
}
return generateMessage;
}
}