This repository has been archived on 2026-01-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
AW_2025/Assets/Scripts/Frontec/QRCodeViewer.cs
2025-02-24 15:18:12 +09:00

49 lines
1.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class QRCodeManager : MonoBehaviour
{
[SerializeField] private Texture m_texture = null;
// Start is called before the first frame update
void Start()
{
Vector3[] vertices = new Vector3[]
{
new Vector3(-1f, 1f, -1f),
new Vector3(1f, 1f, -1f),
new Vector3(1f, -1f, -1f),
new Vector3(-1f, -1f, -1f),
};
int[] triangles = new int[] { 0, 1, 2, 0, 2, 3 };
Mesh mesh = new Mesh();
Vector2[] uvs = new Vector2[] {
new Vector2(0f, 1f),
new Vector2(1f,1f),
new Vector2(1f, 0f),
new Vector2(0f,0f),
};
mesh.vertices = vertices;
mesh.triangles = triangles;
mesh.uv = uvs;
mesh.RecalculateBounds();
mesh.RecalculateNormals();
GetComponent<MeshFilter>().sharedMesh = mesh;
Material material = new Material(Shader.Find("Standard"));
material.SetTexture("_MainTex", m_texture);
GetComponent<MeshRenderer>().material = material;
}
// Update is called once per frame
void Update()
{
}
}