using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography;
using Unity.IO.LowLevel.Unsafe;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class testBehaviourScript : MonoBehaviour
{
    // Start is called before the first frame update
    private Vector3 nowPosition = Vector3.zero;
    private Texture2D nowFileTexture;
    void Start()
    {
        Debug.Log("11111111111111");
        var text = Resources.Load<Texture2D>("leidianjiangjun.jpeg");
        FileStream fs = File.OpenRead("leidianjiangjun.jpeg");
        fs.Seek(0, SeekOrigin.Begin);
        byte[] image = new byte[(int)fs.Length];
        fs.Read(image, 0, (int)fs.Length);
        var texCopy = new Texture2D(text.width, text.height);
        texCopy.LoadImage(image);
        nowFileTexture = texCopy;
        utilsTools.addTimer_Sec(this.gameObject, "toGame", (name) =>{
            SceneManager.LoadScene("hallScene");
            return false;
        }, 5);
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    public void onTouchBegin()
    {
    }
    public void onTouchEnd()
    {
    }

    public void onTouchClick()
    {
        nowPosition = Input.mousePosition;
        Debug.Log(nowPosition);
        Image image = this.GetComponent<Image>();
        int x = (int)Math.Ceiling(nowPosition.x);
        int y = (int)Math.Ceiling(nowPosition.y);
        
        Color color = nowFileTexture.GetPixel(x, y);
        Debug.Log(color);
    }
}
