using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class Native : MonoBehaviour
{
    public Text text;

    void appendToText(string line) { text.text += line + "\n"; }

    void Start()
    {
        text.text = "test";
        showHostMainWindow();
        Debug.Log("UnityStart");
    }
    private void OnEnable()
    {
        Debug.Log("OnEnable");
    }

    void Update()
    {
        
    }
    void showHostMainWindow()
    {
#if UNITY_ANDROID
        try
        {
            AndroidJavaClass jc = new AndroidJavaClass("com.company.product.OverrideUnityActivity");
            AndroidJavaObject overrideActivity = jc.GetStatic<AndroidJavaObject>("instance");
            overrideActivity.Call("showMainActivity", "red");
        }
        catch (Exception e)
        {
            appendToText("Exception during showHostMainWindow");
            appendToText(e.Message);
        }
#endif
    }
    void onNativeMessage(string json)
    {
        Debug.Log("Android调用该方法"+json);
    }
    void loadGameScene()
    {
        SceneManager.LoadScene("Scenes/gameScene");
    }

}
