美文网首页
AR开发实战AR项目之三清山旅游项目助手

AR开发实战AR项目之三清山旅游项目助手

作者: TonyWan_AR | 来源:发表于2019-10-10 11:59 被阅读0次

一、框架图

二、关键脚本

MainBtnsPanel

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class MainBtnsPanel : MonoBehaviour
{
   
    void Start()
    {
        EventCenter.AddListener(EventDefine.HeatSpotBtnClick, HeatSpotBtnClickHandle);
        EventCenter.AddListener(EventDefine.HeatSpotsReturnBtnClick, HeatSpotsReturnBtnClickHandle);
    }

    private void HeatSpotBtnClickHandle()
    {
        gameObject.SetActive(false);
    }

    private void HeatSpotsReturnBtnClickHandle()
    {
        gameObject.SetActive(true);
    }

    void Update()
    {
        
    }

    private void OnDestroy()
    {
        EventCenter.RemoveListener(EventDefine.HeatSpotBtnClick, HeatSpotBtnClickHandle);
        EventCenter.RemoveListener(EventDefine.HeatSpotsReturnBtnClick, HeatSpotsReturnBtnClickHandle);
    }
}

MainBtnsCtrl

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

public class MainBtnsCtrl : MonoBehaviour
{

    private bool isShow;


    public Sprite unSelect_sp;
    public Sprite select_sp;


    void Start()
    {
       

    
        gameObject.transform.GetComponent<Button>().onClick.AddListener(()=> {
            isShow = !isShow;
            EventCenter.Broadcast(EventDefine.MainBtnClick, tag,isShow);
        });

        EventCenter.AddListener<string,bool>(EventDefine.MainBtnClick, MainBtnClickHandle);
        EventCenter.AddListener(EventDefine.HeatSpotsReturnBtnClick, HeatSpotsReturnBtnClickHandle);
    }

    private void HeatSpotsReturnBtnClickHandle()
    {
        transform.GetComponent<Image>().sprite = unSelect_sp;
    }

    private void MainBtnClickHandle(string btnTag, bool isShow1)
    {
        if (btnTag != tag) {
            isShow = false;
            transform.GetComponent<Image>().sprite = unSelect_sp;
        }
        else {
            transform.GetComponent<Image>().sprite = select_sp;
            switch (btnTag)
            {
                case Tags.BoaBtn:
                    GameManagerUI.InstanceUI.currentMainBtnState = UIMainBtnsState.BoaUIState;
                    break;
                case Tags.SanqinggongBtn:
                    GameManagerUI.InstanceUI.currentMainBtnState = UIMainBtnsState.SanQingGongUIState;
                    break;
                case Tags.CenserBtn:
                    GameManagerUI.InstanceUI.currentMainBtnState = UIMainBtnsState.CenserUIState;
                    break;
                case Tags.CloudSeaBtn:
                    GameManagerUI.InstanceUI.currentMainBtnState = UIMainBtnsState.CloudSeaUIState;
                    break;
                default:
                    break;
            }
        }

            
        
    }

    void Update()
    {
        
    }

    private void OnDestroy()
    {
        EventCenter.RemoveListener<string, bool>(EventDefine.MainBtnClick, MainBtnClickHandle);
        EventCenter.RemoveListener(EventDefine.HeatSpotsReturnBtnClick, HeatSpotsReturnBtnClickHandle);
    }
}


FunctionBtnsCtrl

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FunctionBtnsCtrl : MonoBehaviour
{

    void Start()
    {

        gameObject.SetActive(false);
        EventCenter.AddListener<string,bool>(EventDefine.MainBtnClick, MainBtnClickHandle);
        EventCenter.AddListener(EventDefine.HeatSpotsReturnBtnClick, HeatSpotsReturnBtnClickHandle);
       // EventCenter.AddListener<string>(EventDefine.BtnClick, BrnClickHandle);
    }

    private void BrnClickHandle(string btg)
    {
        if (btg == Tags.MainCtrl)
            gameObject.SetActive(false);
    }

    private void MainBtnClickHandle(string btnTag, bool isShow)
    {
        if (btnTag == tag)
            gameObject.SetActive(isShow);
        else
            gameObject.SetActive(false);

    }

    private void HeatSpotsReturnBtnClickHandle()
    {
        gameObject.SetActive(false);
    }

    void Update()
    {

    }

    private void OnDestroy()
    {
        EventCenter.RemoveListener<string, bool>(EventDefine.MainBtnClick, MainBtnClickHandle);
        EventCenter.RemoveListener(EventDefine.HeatSpotsReturnBtnClick, HeatSpotsReturnBtnClickHandle);
       // EventCenter.RemoveListener<string>(EventDefine.BtnClick, BrnClickHandle);
    }
}

HeatSpotBtn

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

public class HeatSpotBtn : MonoBehaviour
{
    
    void Start()
    {
        gameObject.transform.GetComponent<Button>().onClick.AddListener(()=> {
            EventCenter.Broadcast(EventDefine.HeatSpotBtnClick);
        });



        EventCenter.AddListener(EventDefine.HeatSpotBtnClick, HeatSpotBtnClickHandle);
        EventCenter.AddListener(EventDefine.HeatSpotsReturnBtnClick, HeatSpotsReturnBtnClickHandle);
    }

    private void HeatSpotBtnClickHandle()
    {
        gameObject.SetActive(false);
    }

    private void HeatSpotsReturnBtnClickHandle()
    {
        gameObject.SetActive(true);
    }
    void Update()
    {
        
    }


    private void OnDestroy()
    {
        EventCenter.RemoveListener(EventDefine.HeatSpotBtnClick, HeatSpotBtnClickHandle);
        EventCenter.RemoveListener(EventDefine.HeatSpotsReturnBtnClick, HeatSpotsReturnBtnClickHandle);
    }

}

SettingBtnCtrl

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

public class SettingBtnCtrl : MonoBehaviour
{
   

    void Start()
    {
        gameObject.transform.GetComponent<Button>().onClick.AddListener(()=> {
            ExitBtnClick();
        });    
    }

    
    void Update()
    {
        
    }



    public void ExitBtnClick() {
        StartCoroutine(ExitApp());
    }



    IEnumerator ExitApp()
    {
        yield return new WaitForFixedUpdate();
        Application.Quit();


    }


}

MenuBtn

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


public class MenuBtn : MonoBehaviour
{
    public Sprite open_Sp;
    public Sprite close_Sp;

    private bool isMenu;

    void Start()
    {
        gameObject.transform.GetComponent<Button>().onClick.AddListener(() =>
        {
            isMenu = !isMenu;
            if (isMenu)
                gameObject.transform.GetComponent<Image>().sprite = close_Sp;
            else
                gameObject.transform.GetComponent<Image>().sprite = open_Sp;
            AudioManagerInScene.Instance_Audio.MenuPlay(isMenu);
        });

    }

    void Update()
    {

    }
}

ScenicSpotIntroductionCtrl

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScenicSpotIntroductionCtrl : MonoBehaviour
{
    public UIMainBtnsState mUIMainBtnsState;



    void Start()
    {
        gameObject.SetActive(false);
        EventCenter.AddListener<string, bool>(EventDefine.MainBtnClick, MainBtnClickHandle); 
        EventCenter.AddListener<string>(EventDefine.FunctionBtns_Boa_ChildClick, FunctionBtns_Boa_ChildClickHandle); 
        EventCenter.AddListener(EventDefine.HeatSpotBtnClick, HeatSpotBtnClickHandle);
    }


    private void FunctionBtns_Boa_ChildClickHandle(string curretTag)
    {
      
        if (curretTag==Tags.IntroductionBtn)
        {
            if (mUIMainBtnsState == GameManagerUI.InstanceUI.currentMainBtnState)
                gameObject.SetActive(true);
           else
                gameObject.SetActive(false);
        }
        else
            gameObject.SetActive(false);
    }

    private void MainBtnClickHandle(string btnTag, bool isShow)
    {
            gameObject.SetActive(false);
    }

    private void HeatSpotBtnClickHandle()
    {
        gameObject.SetActive(false);
    }
    void Update()
    {
        
    }

    private void OnDestroy()
    {
        EventCenter.RemoveListener<string, bool>(EventDefine.MainBtnClick, MainBtnClickHandle);
        EventCenter.RemoveListener<string>(EventDefine.FunctionBtns_Boa_ChildClick, FunctionBtns_Boa_ChildClickHandle);
        EventCenter.RemoveListener(EventDefine.HeatSpotBtnClick, HeatSpotBtnClickHandle);
    }
}

FairyStoryCtrl

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class FairyStoryCtrl : MonoBehaviour
{
    public UIMainBtnsState mUIMainBtnsState;

    void Start()
    {
        gameObject.SetActive(false);
        EventCenter.AddListener<string, bool>(EventDefine.MainBtnClick, MainBtnClickHandle); 
        EventCenter.AddListener<string>(EventDefine.FunctionBtns_Boa_ChildClick, FunctionBtns_Boa_ChildClickHandle); 
        EventCenter.AddListener(EventDefine.HeatSpotBtnClick, HeatSpotBtnClickHandle);
    }

    private void FunctionBtns_Boa_ChildClickHandle(string curretTag)
    {

        if (curretTag == Tags.StoryBtn)
        {
            if (mUIMainBtnsState == GameManagerUI.InstanceUI.currentMainBtnState)
                gameObject.SetActive(true);
            else
                gameObject.SetActive(false);
        }
        else
            gameObject.SetActive(false);
    }

    private void MainBtnClickHandle(string btnTag, bool isShow)
    {
        gameObject.SetActive(false);
    }

    private void HeatSpotBtnClickHandle()
    {
        gameObject.SetActive(false);
    }

    void Update()
    {
        
    }


    private void OnDestroy()
    {
        EventCenter.RemoveListener<string, bool>(EventDefine.MainBtnClick, MainBtnClickHandle);
        EventCenter.RemoveListener<string>(EventDefine.FunctionBtns_Boa_ChildClick, FunctionBtns_Boa_ChildClickHandle);
        EventCenter.RemoveListener(EventDefine.HeatSpotBtnClick, HeatSpotBtnClickHandle);
    }
}

PanelCtrl

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PanelCtrl : MonoBehaviour
{
    public bool isActive;
    private string panelBtg;
    void Start()
    {
        gameObject.SetActive(isActive);
        panelBtg = transform.tag;
        EventCenter.AddListener<string>(EventDefine.BtnClick, BrnClickHandle);
        EventCenter.AddListener<string>(EventDefine.ReturnBtnClick, ReturnBtnClickHandle);
    }

    private void ReturnBtnClickHandle(string arg)
    {
        if (arg == panelBtg)
            gameObject.SetActive(true);
        else
            gameObject.SetActive(false);
    }

    private void BrnClickHandle(string btg)
    {
        if (btg == panelBtg)
            gameObject.SetActive(true);
        else
            gameObject.SetActive(false);
    }

    void Update()
    {
        
    }

    private void OnDestroy()
    {
        EventCenter.RemoveListener<string>(EventDefine.BtnClick, BrnClickHandle);
        EventCenter.RemoveListener<string>(EventDefine.ReturnBtnClick, BrnClickHandle);
    }
}

HeatSpotsPanel

using System.Collections;
using System.Collections.Generic;
using UnityEngine;



public class HeatSpotsPanel : MonoBehaviour
{
  
    void Start()
    {
        gameObject.SetActive(false);
        EventCenter.AddListener(EventDefine.HeatSpotBtnClick, HeatSpotBtnClickHandle);
        EventCenter.AddListener(EventDefine.HeatSpotsReturnBtnClick, HeatSpotsReturnBtnClickHandle);
    }

    private void HeatSpotBtnClickHandle()
    {
        gameObject.SetActive(true);
    }

    private void HeatSpotsReturnBtnClickHandle()
    {
      gameObject.SetActive(false);
    }
    void Update()
    {
        
    }
    private void OnDestroy()
    {
        EventCenter.RemoveListener(EventDefine.HeatSpotBtnClick, HeatSpotBtnClickHandle);
        EventCenter.RemoveListener(EventDefine.HeatSpotsReturnBtnClick, HeatSpotsReturnBtnClickHandle);
    }
}

Taoist_SanqinggongPanel

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;

public class Taoist_SanqinggongPanel : MonoBehaviour
{

    private Button blessingBtn;
    private Text mText;
    private string tempTxt;
    private Tweener tweener;

    void Start()
    {
        gameObject.SetActive(false);
        blessingBtn = transform.Find("BlessingBtn").GetComponent<Button>();
        blessingBtn.onClick.AddListener(() =>
        {
            gameObject.SetActive(false);
            EventCenter.Broadcast(EventDefine.BlessingBtn_SanQingGong);
        });
        EventCenter.AddListener<string>(EventDefine.BtnClick, BtnClickHandle);


        blessingBtn.gameObject.SetActive(false);
        mText = transform.GetChild(0).transform.GetComponentInChildren<Text>();
        tempTxt = mText.text.ToString();
        mText.text = "";
       
    }

    private void BtnClickHandle(string btnTag)
    {
        if (btnTag == Tags.MainCtrl)
        {
            if (GameManagerUI.InstanceUI.currentMainBtnState == UIMainBtnsState.SanQingGongUIState)
            {
                gameObject.SetActive(true);
                StartCoroutine("ShowBlessingBtn");
            }
            else
            {
                gameObject.SetActive(false);
                StopCoroutine("ShowBlessingBtn");

            }
        }
        else
        {
            gameObject.SetActive(false);
            StopCoroutine("ShowBlessingBtn");

        }



    }


    IEnumerator ShowBlessingBtn()
    {
        // mText.text = "";
        blessingBtn.gameObject.SetActive(false);
        yield return new WaitForSeconds(1.5f);
        blessingBtn.gameObject.SetActive(true);
        mText.text = "";
        tweener = mText.DOText(tempTxt, 10f);
        tweener.SetEase(Ease.Linear);
        tweener.SetAutoKill(true);
        tweener.Restart();

    }



    void Update()
    {

    }

    private void OnDestroy()
    {
        EventCenter.RemoveListener<string>(EventDefine.BtnClick, BtnClickHandle);
    }
}

Taoist_CenserPanel

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;

public class Taoist_CenserPanel : MonoBehaviour
{
    private Button blessingBtn;
    private Text mText;
    private string tempTxt;
    private Tweener tweener;

    void Start()
    {
        gameObject.SetActive(false);
        blessingBtn = transform.Find("BlessingBtn").GetComponent<Button>();
        blessingBtn.onClick.AddListener(() =>
        {
            gameObject.SetActive(false);
            EventCenter.Broadcast(EventDefine.BlessingBtn_Censer);
        });
        EventCenter.AddListener<string>(EventDefine.BtnClick, BtnClickHandle);


 
        blessingBtn.gameObject.SetActive(false);
        mText = transform.GetChild(0).transform.GetComponentInChildren<Text>();
        tempTxt = mText.text.ToString();
        mText.text = "";
    }

    private void BtnClickHandle(string btnTag)
    {
        if (btnTag == Tags.MainCtrl)
        {
            if (GameManagerUI.InstanceUI.currentMainBtnState == UIMainBtnsState.CenserUIState)
            {
                gameObject.SetActive(true);
                StartCoroutine("ShowBlessingBtn");
            }
            else
            {
                gameObject.SetActive(false);
                StopCoroutine("ShowBlessingBtn");
            }

        }
        else {
            gameObject.SetActive(false);
            StopCoroutine("ShowBlessingBtn");
        }
            

    }


    IEnumerator ShowBlessingBtn()
    {
        // mText.text = "";
        blessingBtn.gameObject.SetActive(false);
        yield return new WaitForSeconds(2.5f);
        blessingBtn.gameObject.SetActive(true);
        mText.text = "";
        tweener = mText.DOText(tempTxt, 12f);
        tweener.SetEase(Ease.Linear);
        tweener.SetAutoKill(true);
        tweener.Restart();

    }

    void Update()
    {

    }

    private void OnDestroy()
    {
        EventCenter.RemoveListener<string>(EventDefine.BtnClick, BtnClickHandle);
    }
}

ImageTargetBehaviour_Boa

//=============================================================================================================================
//
// Copyright (c) 2015-2017 VisionStar Information Technology (Shanghai) Co., Ltd. All Rights Reserved.
// EasyAR is the registered trademark or trademark of VisionStar Information Technology (Shanghai) Co., Ltd in China
// and other countries for the augmented reality technology developed by VisionStar Information Technology (Shanghai) Co., Ltd.
//
//=============================================================================================================================
using UnityEngine;
using EasyAR;
using System;

namespace EasyAR
{
    public class ImageTargetBehaviour_Boa : ImageTargetBaseBehaviour
    {

        protected override void Awake()
        {
            base.Awake();

            TargetFound += OnTargetFound;
            TargetLost += OnTargetLost;
            TargetLoad += OnTargetLoad;
            TargetUnload += OnTargetUnload;
        }

        protected override void Start()
        {
            base.Start();
            gameObject.transform.GetChild(0).gameObject.SetActive(false);
            EventCenter.AddListener<string>(EventDefine.ArScan, ArScanHandle);
            EventCenter.AddListener<string>(EventDefine.FunctionBtns_Boa_ChildClick, FunctionBtns_Boa_ChildClickHandle); 
            EventCenter.AddListener<string, bool>(EventDefine.MainBtnClick, MainBtnClickHandle);
            EventCenter.AddListener(EventDefine.HeatSpotBtnClick, HeatSpotBtnClickHandle);
        }

        protected override void OnDestroy()
        {
            base.OnDestroy();
            EventCenter.RemoveListener<string>(EventDefine.ArScan, ArScanHandle);
            EventCenter.RemoveListener<string>(EventDefine.FunctionBtns_Boa_ChildClick, FunctionBtns_Boa_ChildClickHandle); 
            EventCenter.RemoveListener<string, bool>(EventDefine.MainBtnClick, MainBtnClickHandle);
            EventCenter.RemoveListener(EventDefine.HeatSpotBtnClick, HeatSpotBtnClickHandle);
        }
        private void MainBtnClickHandle(string btnTag, bool isShow)
        {
            gameObject.transform.GetChild(0).gameObject.SetActive(false);
        }
        private void FunctionBtns_Boa_ChildClickHandle(string curretTag)
        {
            
            if (curretTag != Tags.ScanBtn)
            {
                gameObject.transform.GetChild(0).gameObject.SetActive(false);
            }
        }
        private void HeatSpotBtnClickHandle()
        {
            gameObject.transform.GetChild(0).gameObject.SetActive(false);
        }
        private void ArScanHandle(string goTag)
        {
            if (goTag == tag)
                gameObject.transform.GetChild(0).gameObject.SetActive(true);
            else
                gameObject.transform.GetChild(0).gameObject.SetActive(false);
        }

        void OnTargetFound(TargetAbstractBehaviour behaviour)
        {
            Debug.Log("Found: " + Target.Id);
         
        }

        void OnTargetLost(TargetAbstractBehaviour behaviour)
        {
            Debug.Log("Lost: " + Target.Id);
        }

        void OnTargetLoad(ImageTargetBaseBehaviour behaviour, ImageTrackerBaseBehaviour tracker, bool status)
        {
            Debug.Log("Load target (" + status + "): " + Target.Id + " (" + Target.Name + ") " + " -> " + tracker);
        }

        void OnTargetUnload(ImageTargetBaseBehaviour behaviour, ImageTrackerBaseBehaviour tracker, bool status)
        {
            Debug.Log("Unload target (" + status + "): " + Target.Id + " (" + Target.Name + ") " + " -> " + tracker);
        }
    }
}

GameManagerUI

using System.Collections;
using System.Collections.Generic;
using UnityEngine;



public enum UIMainBtnsState
{
    BoaUIState,
    SanQingGongUIState,
    CenserUIState,
    CloudSeaUIState,
 

}
public class GameManagerUI : MonoBehaviour
{

    public static GameManagerUI InstanceUI;

    private void Awake()
    {
        InstanceUI = this;
        
    }

    [HideInInspector]
    public Sprite unSelect_sp;
    [HideInInspector]
    public Sprite select_sp;

    public UIMainBtnsState currentMainBtnState;

    void Start()
    {
        unSelect_sp = ResourcesManager.LoadSprite("ChildBtnsUI/unSelect_sp");
        select_sp = ResourcesManager.LoadSprite("ChildBtnsUI/select_sp");
    }


    void Update()
    {

    }
}

GameManager

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.UI;
using UnityEngine.Video;
using LitJson;
using System.IO;
using EasyAR;

public enum UIPanelState {
    MainPanel,
    GivingPanel,
    GivingAmountPanel,
    PaymentOrderPanel,
    PaySuccessPanel

}


public class GameManager : MonoBehaviour
{

    public Text textTips; 

    public UIPanelState currentUIPanelState;

    private double payAmount; 

    public static GameManager Instance;

    string url;

   
    public CameraDeviceBehaviour cdb;


    private void Awake()
    {
        Instance = this;


      url = PlayerPrefs.GetString("IPAddT");

 

    }

    void Start()
    {
        // SendData();
        EventCenter.AddListener(EventDefine.ImmediatetPayBtnClick, SendData);
        EventCenter.AddListener<double>(EventDefine.PayBtnClick, PayBtnClickHandle);
        EventCenter.AddListener<string>(EventDefine.BtnClick, BtnClickEnum);
       // cdb.StopCapture();
    }


    public void StartCaptureAR()
    {

        cdb.StartCapture();

    }


    public void StopCaptureAR() {

        cdb.StopCapture();

    }



    private void BtnClickEnum(string btg)
    {
        switch (btg)
        {
            case Tags.GivingCtrl:
                currentUIPanelState = UIPanelState.GivingPanel;
                break;
            case Tags.GivingAmountCtrl:
                currentUIPanelState = UIPanelState.GivingAmountPanel;
                break;
            case Tags.PaymentOrderCtrl:
                currentUIPanelState = UIPanelState.PaymentOrderPanel;
                break;
            case Tags.PaySuccessCtrl:
                currentUIPanelState = UIPanelState.PaySuccessPanel;
                break;
            case Tags.MainCtrl:
                currentUIPanelState = UIPanelState.MainPanel;
                break;
            default:
                break;
        }
    }

    private void PayBtnClickHandle(double payMoney)
    {
        payAmount = payMoney;
    }

    private void OnDestroy()
    {
        EventCenter.RemoveListener(EventDefine.ImmediatetPayBtnClick, SendData);
        EventCenter.RemoveListener<double>(EventDefine.PayBtnClick, PayBtnClickHandle);
        EventCenter.RemoveListener<string>(EventDefine.BtnClick, BtnClickEnum);
    }


    void Update()
    {

    }






    public void SendData() {

        List<string> names = new List<string>();
        names.Add("梁小明");
        names.Add("李X林");
        names.Add("付小福");
        names.Add("王小华");
        names.Add("周小军");
        names.Add("吴小轩");


       // string url ="http://192.168.1.169:8088/artss/ncShowResult/add";
        //string url ="http://192.168.1.188:8080/artss2/ncShowResult/add";
       // string url ="http://172.26.141.1:8080/artss2/ncShowResult/add"; //0325
        MessageJson msgJson = new MessageJson();

        msgJson.name = names[UnityEngine.Random.Range(0,names.Count)] ;
        msgJson.examAllTime = payAmount;
        string jd = JsonMapper.ToJson(msgJson);
        StartCoroutine(PostUrl(url, jd));

    }

    public IEnumerator PostUrl(string url, string postData)
    {
        WWWForm form = new WWWForm();
        form.AddField("json", Base64Code(postData));
        using (UnityWebRequest www = UnityWebRequest.Post(url, form))
        {
            yield return www.SendWebRequest();
            if (www.isNetworkError)
            {
                Debug.Log(www.error);
            }
            else
            {
                // Show results as text  
                if (www.responseCode == 200)
                {
                    string str = www.downloadHandler.text;
                    ParseData(str);
                }
            }
        }
    }


    

    public void ParseData(string str){

        RootContent cj = JsonMapper.ToObject<RootContent>(str);
        string str1 = Base64Decode(cj.content.data);
        Root dj = JsonMapper.ToObject<Root>(str1);
      
    }









    public string Base64Code(string Message)
    {
        byte[] bytes = Encoding.UTF8.GetBytes(Message);
        return Convert.ToBase64String(bytes);

    }



    public static string Base64Decode(string result)
    {
        return Base64Decode(Encoding.UTF8, result);

    }


    public static string Base64Decode(Encoding encodeType, string result)
    {
        string decode = string.Empty;
        byte[] bytes = Convert.FromBase64String(result);
        try
        {
            decode = encodeType.GetString(bytes);
        }
        catch
        {
            decode = result;
        }
        return decode;
    }



    public string Read()
    {

        string strReadFilePath = Application.streamingAssetsPath + @"/IPTxt.txt";

        string strReadLine = "";

        try
        {
            StreamReader srReadFile = new StreamReader(strReadFilePath);
            while (!srReadFile.EndOfStream)
            {
                strReadLine = srReadFile.ReadLine(); 
            }
            srReadFile.Close();
        }
        catch (Exception)
        {
        }
        return strReadLine.Trim();
    }



}

[Serializable]
public class MessageJson
{
    public string name;
    public double examAllTime;

}

[Serializable]
public class Content
{
    /// <summary>
    /// eyJyZXN1bHRDb2RlIjoyMDAsInJlc3VsdE1zZyI6Ik9LIiwicmVzdWx0Ijp7InRvdGFsIjoxLCJyb3dzIjpbeyJpZCI6NDMsIm5hbWUiOiLmooHlsI/卖萌I4iLCJvcGVyYXRpb25OYW1lIjoiIiwicHJvamVjdERlc2NyaXB0aW9uIjoiIiwiZXhhbUFsbFRpbWUiOjEuMCwicXVlc3Rpb25MaXN0IjoiIiwidXNlcklkIjoiIiwic3RhdHVzIjoiIiwiZ210Q3JlYXRlIjoiMjAxOS0wMy0yMSAxNDo0NjoyNCIsImdtdE1vZGlmaWVkIjoiMjAxOS0wMy0yMSAxNDo0NjoyNCIsImNyZWF0b3JJZCI6MSwibW9kaWZpZXJJZCI6MX1dfX0=
    /// </summary>
    public string data { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public bool success { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public int status { get; set; }
}

public class RootContent
{
    /// <summary>
    /// 
    /// </summary>
    public bool hasError { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public Content content { get; set; }
}




[Serializable]
public class RowsItem
{
    /// <summary>
    /// 
    /// </summary>
    public int id { get; set; }
    /// <summary>
    /// 梁小明
    /// </summary>
    public string name { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public string operationName { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public string projectDescription { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public double examAllTime { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public string questionList { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public string userId { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public string status { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public string gmtCreate { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public string gmtModified { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public int creatorId { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public int modifierId { get; set; }
}
[Serializable]
public class Result
{
    /// <summary>
    /// 
    /// </summary>
    public int total { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public List<RowsItem> rows { get; set; }
}

[Serializable]
public class Root
{
    /// <summary>
    /// 
    /// </summary>
    public int resultCode { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public string resultMsg { get; set; }
    /// <summary>
    /// 
    /// </summary>
    public Result result { get; set; }
}


Taoist_Sanqinggong

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Taoist_Sanqinggong : MonoBehaviour
{
   
    void Start()
    {
        gameObject.SetActive(false);
        EventCenter.AddListener<string>(EventDefine.BtnClick, BtnClickHandle);
        EventCenter.AddListener(EventDefine.BlessingBtn_SanQingGong, BlessingBtn_SanQingGongHandle);
    }

    private void BlessingBtn_SanQingGongHandle()
    {
        gameObject.SetActive(false);
    }

    private void BtnClickHandle(string btnTag)
    {
        if (btnTag == Tags.MainCtrl)
        {
            if (GameManagerUI.InstanceUI.currentMainBtnState == UIMainBtnsState.SanQingGongUIState)
                gameObject.SetActive(true);
            else
                gameObject.SetActive(false);
        }
        else
            gameObject.SetActive(false);

    }

    void Update()
    {
        
    }
    private void OnDestroy()
    {
        EventCenter.AddListener<string>(EventDefine.BtnClick, BtnClickHandle);
    }
}

三、效果图

相关文章

网友评论

      本文标题:AR开发实战AR项目之三清山旅游项目助手

      本文链接:https://www.haomeiwen.com/subject/pfnviqtx.html