Unity回放系統(tǒng)

前言

用了一些視屏錄制插件豹悬,不過文件讀比較大范抓,后來改成記錄事件狀態(tài),文件就比較小了拇砰,在使用Probuff來傳輸數(shù)據(jù)梅忌,回放的時候就不會有卡頓。

ReTenderPlay.cs

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Serialization.Formatters.Binary;
using GGTPlugin;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using Google.Protobuf;
using Tenders.Protobuf;

/// <summary>
/// 回放
/// </summary>
public class ReTenderPlay : MonoBehaviour
{

    public List<GameObject> ReparenetGameObjects;
    public List<GameObject> RePlayGameObjects;

    public List<GameObject> putlab;

    //    public Hashtable ht;
    //    public Hashtable ht1;
    //    public Hashtable reht;
    //    public Hashtable reht1;
    //    public int maxFrame;
    //    public int reMaxFrame;
    public DateTime date;
    public DateTime reDate;
    public string SGYQ;
    public string filepath;
    public static ReTenderPlay instance;
    public float time;
    public int step;
    public bool flag = false;
    public bool putflag;
    public ShowTianqi st;
    public ReTenderplayWnd rw;
    public Image zhezhao;
    public ReTenderplayData Hd = new ReTenderplayData();                      //記錄回放數(shù)據(jù)
    public ReTenderplayData rd = new ReTenderplayData();                      //加載回放數(shù)據(jù)

    public bool flag_cun = false;
    public int zengliang;                           //每一個回放的鄭亮
    public int ZhenSum;                             //每一個回放的總幀數(shù)
    public int CurrentmaxZhen;                      //播放開始幀數(shù)
    public static ReTenderPlay _instance;
    void Awake()
    {
        _instance = this;
    }
    public void Start()
    {
        instance = this;

        // ht = new Hashtable();
        foreach (var VARIABLE1 in ReparenetGameObjects.SelectMany(VARIABLE => VARIABLE.GetComponentsInChildren<Scrollbar>(true)))
        {
            RePlayGameObjects.Add(VARIABLE1.gameObject);
        }
        foreach (var VARIABLE1 in ReparenetGameObjects.SelectMany(VARIABLE => VARIABLE.GetComponentsInChildren<Dropdown>(true)))
        {
            RePlayGameObjects.Add(VARIABLE1.gameObject);
        }
        foreach (var VARIABLE1 in ReparenetGameObjects.SelectMany(VARIABLE => VARIABLE.GetComponentsInChildren<Button>(true)))
        {
            RePlayGameObjects.Add(VARIABLE1.gameObject);
            VARIABLE1.gameObject.AddComponent<TenderClickTrigger>();
        }
        foreach (var VARIABLE1 in ReparenetGameObjects.SelectMany(VARIABLE => VARIABLE.GetComponentsInChildren<InputField>(true)))
        {
            RePlayGameObjects.Add(VARIABLE1.gameObject);
        }
        foreach (var VARIABLE1 in ReparenetGameObjects.SelectMany(VARIABLE => VARIABLE.GetComponentsInChildren<Slider>(true)))
        {
            RePlayGameObjects.Add(VARIABLE1.gameObject);
            VARIABLE1.gameObject.AddComponent<TenderClickTrigger>();
        }
        foreach (var VARIABLE1 in ReparenetGameObjects.SelectMany(VARIABLE => VARIABLE.GetComponentsInChildren<Toggle>(true)))
        {
            RePlayGameObjects.Add(VARIABLE1.gameObject);
            VARIABLE1.gameObject.AddComponent<TenderClickTrigger>();
        }
        //RePlayGameObjects.Add(st.gameObject);

    }

    //  void FixedUpdate()
    //  {
    ////        ZhenSum++;
    ////        if(flag)
    ////        {
    ////            Play();
    ////        }
    //  }
    void Update()
    {
        ZhenSum++;
        if (flag)
        {

            Play();
        }
    }
    //執(zhí)行回放
    public void Play()
    {
        rw.Play();
        foreach (var VARIABLE in rd.Ht.Keys)
        {

            if (Time.frameCount == CurrentmaxZhen + Int32.Parse(VARIABLE.ToString().Substring(0, VARIABLE.ToString().IndexOf("_"))))
            {
                //根據(jù)Id找到物體
                string o = (string)rd.Ht[VARIABLE];
                string buttonid = null;
                string sliderid = null;
                string sliderNum = null;
                string inputId = null;
                string inputValue = null;
                string toggleID = null;
                bool togglevalue = false;
                string Scrollbarid = null;
                float ScrollbarValue = 0;
                string DropDownid = null;
                int DropDownValue = 0;

                for (int j = 0; j < DoSplit(o).Length; j++)
                {
                    if (DoSplit(o)[j].Contains("[s]"))
                    {
                        sliderid = DoSplit(o)[j].Replace("[s]", "");
                    }
                    if (DoSplit(o)[j].Contains("[b]"))
                    {
                        buttonid = DoSplit(o)[j].Replace("[b]", "");
                    }
                    if (DoSplit(o)[j].Contains("[t]"))
                    {
                        toggleID = DoSplit(o)[j].Replace("[t]", "");
                    }
                    if (DoSplit(o)[j].Contains("[tv]"))
                    {
                        togglevalue = bool.Parse(DoSplit(o)[j].Replace("[tv]", ""));
                    }
                    if (DoSplit(o)[j].Contains("[v]"))
                    {
                        sliderNum = DoSplit(o)[j].Replace("[v]", "");
                    }
                    if (DoSplit(o)[j].Contains("[i]"))
                    {
                        inputId = DoSplit(o)[j].Replace("[i]", "");
                    }
                    if (DoSplit(o)[j].Contains("[n]"))
                    {
                        inputValue = DoSplit(o)[j].Replace("[n]", "");
                    }
                    if (DoSplit(o)[j].Contains("[SV]"))
                    {
                        ScrollbarValue = float.Parse(DoSplit(o)[j].Replace("[SV]", ""));
                    }
                    if (DoSplit(o)[j].Contains("[SC]"))
                    {
                        Scrollbarid = DoSplit(o)[j].Replace("[SC]", "");
                    }
                    if (DoSplit(o)[j].Contains("[DV]"))
                    {
                        DropDownValue = int.Parse(DoSplit(o)[j].Replace("[DV]", ""));
                    }
                    if (DoSplit(o)[j].Contains("[DC]"))
                    {
                        DropDownid = DoSplit(o)[j].Replace("[DC]", "");
                    }
                    //記錄鼠標(biāo)
                    foreach (var VARIABLE1 in RePlayGameObjects)
                    {
                        //按鈕
                        if (VARIABLE1.GetComponent<Tender_GUID>().ID == (Convert.ToInt32(buttonid)))
                        {
                            if (VARIABLE1.GetComponent<Button>() != null)
                            {
                                VARIABLE1.GetComponent<Button>().onClick.Invoke();
                            }
                        }
                        //toggle
                        if (VARIABLE1.GetComponent<Tender_GUID>().ID == Convert.ToInt32(toggleID))
                        {
                            if (VARIABLE1.GetComponent<Toggle>() != null)
                            {
                                VARIABLE1.GetComponent<Toggle>().isOn = togglevalue;
                                try
                                {
                                    RYDownShow._instance.updateData();
                                }
                                catch (Exception ex)
                                {

                                }


                            }
                        }
                        //滑動
                        if (VARIABLE1.GetComponent<Tender_GUID>().ID == Convert.ToInt32(sliderid))
                        {
                            if (VARIABLE1.GetComponent<Slider>() != null)
                            {
                                VARIABLE1.GetComponent<Slider>().value = Convert.ToInt32(sliderNum);
                            }
                        }
                        //滾動條
                        if (VARIABLE1.GetComponent<Tender_GUID>().ID == Convert.ToInt32(Scrollbarid))
                        {
                            if (VARIABLE1.GetComponent<Scrollbar>() != null)
                            {
                                VARIABLE1.GetComponent<Scrollbar>().value = ScrollbarValue;
                                VARIABLE1.GetComponent<Scrollbar>().onValueChanged.Invoke(-1);
                            }
                        }
                        //下拉列表
                        if (VARIABLE1.GetComponent<Tender_GUID>().ID == Convert.ToInt32(DropDownid))
                        {
                            if (VARIABLE1.GetComponent<Dropdown>() != null)
                            {
                                VARIABLE1.GetComponent<Dropdown>().value = DropDownValue;
                            }
                        }
                        //輸入
                        if (VARIABLE1.GetComponent<Tender_GUID>().ID == Convert.ToInt32(inputId))
                        {
                            if (VARIABLE1.GetComponent<InputField>() != null)
                            {
                                VARIABLE1.GetComponent<InputField>().text = Convert.ToString(inputValue);
                                VARIABLE1.GetComponent<InputField>().onEndEdit.Invoke("CheckZZS");
                                VARIABLE1.GetComponent<InputField>().onEndEdit.Invoke("WeightComper");
                                VARIABLE1.GetComponent<InputField>().onEndEdit.Invoke("updateData");
                            }
                        }

                    }
                    //                  if (o.Contains("[w]"))
                    //                  {
                    //                      var str = o.Replace("[w]", "");
                    //                      st.a = Convert.ToInt32(DoSplit1(str)[0]);
                    //                      st.b = Convert.ToInt32(DoSplit1(str)[1]);
                    //                      st.i = Convert.ToInt32(DoSplit1(str)[2]);
                    //                      st.j = Convert.ToInt32(DoSplit1(str)[3]);
                    //                      st.m = Convert.ToInt32(DoSplit1(str)[4]);
                    //                      st.n = Convert.ToInt32(DoSplit1(str)[5]);
                    //                  }
                }
                //記錄攝像機(jī)的移動
                if (o.Contains("[p]"))
                {
                    int li_index = 0;
                    int last_index = o.LastIndexOf("|");
                    string str = o.Substring(0, last_index);
                    str = str.Replace("[p]", "").Replace("(", "").Replace(")", "");
                    Camera.main.transform.localPosition = new Vector3(Convert.ToSingle(DoSplit1(str)[0]), Convert.ToSingle(DoSplit1(str)[1]), Convert.ToSingle(DoSplit1(str)[2]));

                    string str1 = o.Substring(last_index + 1);
                    str1 = str1.Replace("[r]", "").Replace("(", "").Replace(")", "");
                    Camera.main.transform.localRotation = Quaternion.Euler(Convert.ToSingle(DoSplit1(str1)[0]), Convert.ToSingle(DoSplit1(str1)[1]), Convert.ToSingle(DoSplit1(str1)[2]));
                    //putflag = true;
                }
                //記錄點擊單塔
                if (o.Contains("[ST]"))
                {
                    int li_index = 0;
                    int last_index = o.LastIndexOf("|");
                    string str = o.Substring(0, last_index);
                    str = str.Replace("[ST]", "").Replace("(", "").Replace(")", "");
                    RunScript._instance.taPrefab.transform.localPosition = new Vector3(Convert.ToSingle(DoSplit1(str)[0]), Convert.ToSingle(DoSplit1(str)[1]), Convert.ToSingle(DoSplit1(str)[2]));

                    string str1 = o.Substring(last_index + 1);
                    str1 = str1.Replace("[Sr]", "").Replace("(", "").Replace(")", "");
                    RunScript._instance.taPrefab.transform.transform.localRotation = Quaternion.Euler(Convert.ToSingle(DoSplit1(str1)[0]), Convert.ToSingle(DoSplit1(str1)[1]), Convert.ToSingle(DoSplit1(str1)[2]));
                    UIControl._instance.ShowTowerMiddle();
                }
                //記錄批量設(shè)置塔型
                if (o.Contains("[PT]"))
                {
                    int li_index = 0;
                    int last_index = o.LastIndexOf("|");
                    string str = o.Substring(0, last_index);
                    str = str.Replace("[PT]", "").Replace("(", "").Replace(")", "");
                    string str1 = o.Substring(last_index + 1);
                    str1 = str1.Replace("[S]", "").Replace("(", "").Replace(")", "");
                    if (str1 == "1")
                    {
                        RunScript._instance.PlTiShi.transform.FindChild("Text").GetComponent<Text>().text = "請點擊選擇截止點";
                        RunScript._instance.PLFirstTaPrefab = new Vector3(Convert.ToSingle(DoSplit1(str)[0]), Convert.ToSingle(DoSplit1(str)[1]), Convert.ToSingle(DoSplit1(str)[2]));
                    }
                    else if (str1 == "2")
                    {
                        RunScript._instance.PlTiShi.SetActive(false);
                        RunScript._instance.PlTiShi.transform.FindChild("Text").GetComponent<Text>().text = "請點擊選擇起始點";
                        RunScript._instance.PLSencondPrefab = new Vector3(Convert.ToSingle(DoSplit1(str)[0]), Convert.ToSingle(DoSplit1(str)[1]), Convert.ToSingle(DoSplit1(str)[2]));
                        UIControl._instance.PLShowTowerMiddle();
                    }

                }
                //點擊塔型出現(xiàn)桿塔配置
                if (o.Contains("[D]"))
                {

                    int li_index = 0;
                    int last_index = o.LastIndexOf("|");
                    string str = o.Substring(0, last_index);
                    str = str.Replace("[D]", "").Replace("(", "").Replace(")", "");
                    UIControl._instance.TowerClickCheck(int.Parse(str));
                }
            }
        }
    }

    public string[] DoSplit(string str)
    {
        string[] sarray = str.Split(Convert.ToChar("|"));
        return sarray;
    }

    public string[] DoSplit1(string str)
    {
        string[] sarray = str.Split(Convert.ToChar(","));
        return sarray;
    }

    public void isRepalay()
    {
        //flag = true;
    }


    //    #region 保存到文件
    //
    //    public void SerializeObject(string filename)
    //    {
    //        FileStream fs = new FileStream(filename, FileMode.Create);
    //        BinaryFormatter serialize = new BinaryFormatter();
    //        serialize.Serialize(fs, ht);
    //        serialize.Serialize(fs, maxFrame);
    //        serialize.Serialize(fs, date);
    //        fs.Close();
    //    }
    //
    //    #endregion
    //    public void reDeSerialize(string filename)
    //    {
    //        BinaryFormatter serialize = new BinaryFormatter();
    //        FileStream fs = new FileStream(filename, FileMode.Open);
    //        reht = (Hashtable)serialize.Deserialize(fs);
    //        reMaxFrame = (int)serialize.Deserialize(fs);
    //        Debug.Log(reMaxFrame.ToString());
    //        //時間
    //        reDate = (DateTime)serialize.Deserialize(fs);
    //        Debug.Log(reDate.ToString());
    //        fs.Close();
    //    }
    //  private void OnGUI()
    //  {
    //          if (GUI.Button(new Rect(100, 100, 30, 30), "保存"))
    //          {
    //              maxFrame = Time.frameCount;
    //              Debug.Log("CUN");
    //              SerializeObject(Application.dataPath+"http://Savedata.dat");
    //              //SaveToNet();
    //          }
    //      if (GUI.Button(new Rect(150, 100, 30,30 ), "回放"))
    //      {
    //          reDeSerialize(Application.dataPath+"http://Savedata.dat");
    //          flag=true;
    //      }
    //
    //  }

}

TenderClickTrigger.cs

using System;
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class TenderClickTrigger : MonoBehaviour, IPointerClickHandler, IPointerUpHandler
{

    void Update()
    {

    }

    public void OnPointerClick(PointerEventData eventData)
    {
        if(UIControl._instance.IsPlayBack&&ReTenderPlay._instance.flag==false)
        {
            //某些button不需要觸發(fā)點擊事件
            if (gameObject.GetComponent<Button>())
            {
                
                switch (gameObject.name)
                {
                case "MoNi_DW":
                    break;
                case "MoNi_Reset":
                    break;
                case "YL_Reset":
                    break;
                case "YL_SubmitData":
                    break;
                case "YL_Cancel":
                    break;
                default:
                    ReTenderPlay.instance.Hd.Ht.Add(ReTenderPlay.instance.ZhenSum+"_" + ReTenderPlay.instance.zengliang++, "[b]" + gameObject.GetComponent<Tender_GUID>().ID);
                
                    break;
                }
            }
            if (gameObject.GetComponent<Slider>())
            {

                ReTenderPlay.instance.Hd.Ht.Add(ReTenderPlay.instance.ZhenSum + "_" + ReTenderPlay.instance.zengliang++, "[s]" + gameObject.GetComponent<Tender_GUID>().ID + "|" + "[v]" + (int)gameObject.GetComponent<Slider>().value);



            }
            if (gameObject.GetComponent<Scrollbar>())
            {

                //Debug.Log("@#@#"+gameObject.GetComponent<Scrollbar>().value+"#@#$#$"+(float)gameObject.GetComponent<Scrollbar>().value);
                ReTenderPlay.instance.Hd.Ht.Add(ReTenderPlay.instance.ZhenSum + "_" + ReTenderPlay.instance.zengliang++, "[S]" + gameObject.GetComponent<Tender_GUID>().ID+ "|" + "[V]" + (float)gameObject.GetComponent<Scrollbar>().value);



            }
            if(UIControl._instance.IsPlayBack&&ReTenderPlay._instance.flag==false&&UIControl._instance.isToogleType)
            {
                if (gameObject.GetComponent<Toggle>())
                {
                    ReTenderPlay.instance.Hd.Ht.Add(ReTenderPlay.instance.ZhenSum + "_" + ReTenderPlay.instance.zengliang++, "[t]" + gameObject.GetComponent<Tender_GUID>().ID+ "|" + "[tv]" + (bool)gameObject.GetComponent<Toggle>().isOn);



                }
            }
        
        }


    }

    public void OnPointerUp(PointerEventData eventData)
    {
        if(UIControl._instance.IsPlayBack&&ReTenderPlay._instance.flag==false)
        {
        if (gameObject.GetComponent<Slider>())
        {

                ReTenderPlay.instance.Hd.Ht.Add(ReTenderPlay.instance.ZhenSum + "_" + ReTenderPlay.instance.zengliang++, "[s]" + gameObject.GetComponent<Tender_GUID>().ID + "|" + "[v]" + (int)gameObject.GetComponent<Slider>().value);



        }
        if (gameObject.GetComponent<Scrollbar>())
        {

                ReTenderPlay.instance.Hd.Ht.Add(ReTenderPlay.instance.ZhenSum + "_" + ReTenderPlay.instance.zengliang++, "[S]" + gameObject.GetComponent<Tender_GUID>().ID + "|" + "[V]" + (float)gameObject.GetComponent<Scrollbar>().value);



        }
        }
    }
}

cameraFlyYJJ.cs

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

public class cameraFlyYJJ : MonoBehaviour
{

    enum Axes { MouseXandY, MouseX, MouseY }
    Axes Axis = Axes.MouseXandY;
    [Tooltip("攝像機(jī)旋轉(zhuǎn)速度")]
    public float sensitivityX = 15.0f;               //旋轉(zhuǎn)速度
    public float sensitivityY = 15.0f;

    float minimumX = -360.0f;
    float maximumX = 360.0f;

    float minimumY = -150.0f;
    float maximumY = 60.0f;
    public float rotationX = 0.0f;
    public float rotationY = 0.0f;

    float traY = 0.0f;
    float traX = 0.0f;

    [Tooltip("中鍵移動速度")]
    public float speed = 200.0f;
    //public float traXSpeed = 250.0f;               //按中建之后攝像機(jī)的移動速度
    //public float traYSpeed = 100.0f;               //按中建之后攝像機(jī)的移動速度

    [Tooltip("方向鍵速度")]
    public float tXSpeed = 1.0f;                   //方向鍵速度
    public float tZSpeed = 1.0f;

    public GameObject cameraReference;
    [HideInInspector]
    public TerrainData td;
    [HideInInspector]
    public Terrain ter;
    Vector3 Pos;
    public static cameraFlyYJJ _insance;
    void Awake()
    {
        _insance = this;
    }
    void Update()
    {
        if (UIControl._instance.IsPlayBack && ReTenderPlay._instance.flag == false)
        {
            //當(dāng)攝像機(jī)的坐標(biāo)和旋轉(zhuǎn)發(fā)生改變時記錄
            if (cameraReference.transform.localPosition != Pos)
            {
                ReTenderPlay.instance.Hd.Ht.Add(ReTenderPlay._instance.ZhenSum + "_" + ReTenderPlay.instance.zengliang++, "[p]" + cameraReference.transform.localPosition.ToString()
                    + "|" + "[r]" + cameraReference.transform.localEulerAngles);
                Pos = cameraReference.transform.localPosition;
            }
        }

        if (EventSystem.current.IsPointerOverGameObject())
        {
            return;
        }

        traY = 0.0f;
        traX = 0.0f;
        if (Input.GetAxis("Mouse ScrollWheel") != 0)
        {
            float distance;
            distance = Input.GetAxis("Mouse ScrollWheel") * speed;
            float height = TerrainControl._instance.TaVector3(cameraReference.transform.localPosition);
            Pos = cameraReference.transform.localPosition;
            if (Pos.y <= height + 40)
            {
                if (distance < 0)
                {
                    cameraReference.transform.localPosition += cameraReference.transform.localRotation * new Vector3(0, 0, distance * 0.5f);
                }
            }
            else
            {
                cameraReference.transform.localPosition += cameraReference.transform.localRotation * new Vector3(0, 0, distance * 0.5f);
            }
        }
        if (Input.GetMouseButton(1))
        {
            if (UIControl._instance.CameraRig != null)
            {
                UIControl._instance.CameraRig.isKinematic = false;
            }
            float translationZ = Input.GetAxis("Vertical");
            cameraReference.transform.localPosition += cameraReference.transform.localRotation * new Vector3(0, 0, translationZ * 0.5f * tZSpeed);
            float translationX = Input.GetAxis("Horizontal");
            cameraReference.transform.localPosition += cameraReference.transform.localRotation * new Vector3(translationX * 0.5f * tXSpeed, 0, 0);
            if (UIControl._instance.IsPlayBack && ReTenderPlay._instance.flag == false)
            {
                ReTenderPlay.instance.Hd.Ht.Add(ReTenderPlay._instance.ZhenSum + "_" + ReTenderPlay.instance.zengliang++, "[p]" + cameraReference.transform.localPosition.ToString()
                + "|" + "[r]" + cameraReference.transform.localEulerAngles);
            }
        }
        if (Input.GetMouseButton(1))
        {
            if (Axis == Axes.MouseXandY)
            {

                rotationX += Input.GetAxis("Mouse X") * sensitivityX;
                rotationY += Input.GetAxis("Mouse Y") * sensitivityY;

                Adjust360andClamp();

                KeyLookAround();

                KeyLookUp();
            }
            else if (Axis == Axes.MouseX)
            {
                rotationX += Input.GetAxis("Mouse X") * sensitivityX;

                Adjust360andClamp();

                KeyLookAround();

                KeyLookUp();
            }
            else
            {
                rotationY += Input.GetAxis("Mouse Y") * sensitivityY;

                Adjust360andClamp();

                KeyLookAround();

                KeyLookUp();
            }
            if (UIControl._instance.IsPlayBack && ReTenderPlay._instance.flag == false)
            {
                ReTenderPlay.instance.Hd.Ht.Add(ReTenderPlay._instance.ZhenSum + "_" + ReTenderPlay.instance.zengliang++, "[p]" + cameraReference.transform.localPosition.ToString()
                + "|" + "[r]" + cameraReference.transform.localEulerAngles);
            }
        }
        if (td != null)
        {

            float h = ter.SampleHeight(transform.position) + 1.8f;
            if (transform.position.y < h)
            {
                transform.position = new Vector3(transform.position.x, h, transform.position.z);
            }
        }
    }

    void KeyLookAround()
    {
        Adjust360andClamp();

        transform.localRotation = Quaternion.AngleAxis(rotationX, Vector3.up);
    }

    void KeyLookUp()
    {
        Adjust360andClamp();

        transform.localRotation *= Quaternion.AngleAxis(rotationY, Vector3.left);
    }

    void Adjust360andClamp()
    {

        if (rotationX < -360)
        {
            rotationX += 360;
        }
        else if (rotationX > 360)
        {
            rotationX -= 360;
        }

        if (rotationY < -360)
        {
            rotationY += 360;
        }
        else if (rotationY > 360)
        {
            rotationY -= 360;
        }

        rotationX = Mathf.Clamp(rotationX, minimumX, maximumX);
        rotationY = Mathf.Clamp(rotationY, minimumY, maximumY);
    }

    void Start()
    {
        Time.timeScale = 1.0f;

        if (GetComponent<Rigidbody>())
        {
            GetComponent<Rigidbody>().freezeRotation = true;
        }
        if (ter != null)
        {
            td = ter.terrainData;
        }
    }
}

TenderInputAdlistener.cd

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class TenderInputAdlistener : MonoBehaviour {

    void Start()
    {
        if(gameObject.GetComponent<InputField>()!=null)
        {
            gameObject.GetComponent<InputField>().onEndEdit.AddListener(delegate
                {
                    if(UIControl._instance.IsPlayBack&&ReTenderPlay._instance.flag==false)
                    {
                        ReTenderPlay.instance.Hd.Ht.Add(ReTenderPlay._instance.ZhenSum + "_" + ReTenderPlay.instance.zengliang++, "[i]" + gameObject.GetComponent<Tender_GUID>().ID + "|" + "[n]" + gameObject.GetComponent<InputField>().text);
                    //Debug.Log("InputField="+ gameObject.GetInstanceID().ToString());

                    }
                });
        }
    
        if(gameObject.GetComponent<Scrollbar>()!=null)
        {
            gameObject.GetComponent<Scrollbar>().onValueChanged.AddListener(delegate
                {
                    if(UIControl._instance.IsPlayBack&&ReTenderPlay._instance.flag==false)
                    {
                        ReTenderPlay.instance.Hd.Ht.Add(ReTenderPlay._instance.ZhenSum + "_" + ReTenderPlay.instance.zengliang++, "[SC]" + gameObject.GetComponent<Tender_GUID>().ID + "|" + "[SV]" + (float) gameObject.GetComponent<Scrollbar>().value);

                    //Debug.Log("Scrollbar="+ gameObject.GetComponent<Scrollbar>().value.ToString());

                    }
                });
        }
        if(gameObject.GetComponent<Dropdown>()!=null)
        {
            gameObject.GetComponent<Dropdown>().onValueChanged.AddListener(delegate
                {
                    if(UIControl._instance.IsPlayBack&&ReTenderPlay._instance.flag==false)
                    {
                        ReTenderPlay.instance.Hd.Ht.Add(ReTenderPlay._instance.ZhenSum + "_" + ReTenderPlay.instance.zengliang++, "[DC]" + gameObject.GetComponent<Tender_GUID>().ID + "|" + "[DV]" + (int) gameObject.GetComponent<Dropdown>().value);
                        Debug.Log("Dropdown  =  "+gameObject.GetComponent<Dropdown>().value.ToString());
                        //Debug.Log("Scrollbar="+ gameObject.GetComponent<Scrollbar>().value.ToString());

                    }
                });
        }
    }
}

proto生成:鏈接:http://pan.baidu.com/s/1slnP5Pr 密碼:a56f

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末除破,一起剝皮案震驚了整個濱河市牧氮,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌瑰枫,老刑警劉巖踱葛,帶你破解...
    沈念sama閱讀 212,332評論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場離奇詭異光坝,居然都是意外死亡尸诽,警方通過查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,508評論 3 385
  • 文/潘曉璐 我一進(jìn)店門盯另,熙熙樓的掌柜王于貴愁眉苦臉地迎上來性含,“玉大人,你說我怎么就攤上這事鸳惯∩淘蹋” “怎么了?”我有些...
    開封第一講書人閱讀 157,812評論 0 348
  • 文/不壞的土叔 我叫張陵悲敷,是天一觀的道長究恤。 經(jīng)常有香客問我,道長后德,這世上最難降的妖魔是什么部宿? 我笑而不...
    開封第一講書人閱讀 56,607評論 1 284
  • 正文 為了忘掉前任,我火速辦了婚禮瓢湃,結(jié)果婚禮上理张,老公的妹妹穿的比我還像新娘。我一直安慰自己绵患,他們只是感情好雾叭,可當(dāng)我...
    茶點故事閱讀 65,728評論 6 386
  • 文/花漫 我一把揭開白布。 她就那樣靜靜地躺著落蝙,像睡著了一般织狐。 火紅的嫁衣襯著肌膚如雪暂幼。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,919評論 1 290
  • 那天移迫,我揣著相機(jī)與錄音旺嬉,去河邊找鬼。 笑死厨埋,一個胖子當(dāng)著我的面吹牛邪媳,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播荡陷,決...
    沈念sama閱讀 39,071評論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼雨效,長吁一口氣:“原來是場噩夢啊……” “哼!你這毒婦竟也來了废赞?” 一聲冷哼從身側(cè)響起徽龟,我...
    開封第一講書人閱讀 37,802評論 0 268
  • 序言:老撾萬榮一對情侶失蹤,失蹤者是張志新(化名)和其女友劉穎蛹头,沒想到半個月后顿肺,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,256評論 1 303
  • 正文 獨居荒郊野嶺守林人離奇死亡渣蜗,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點故事閱讀 36,576評論 2 327
  • 正文 我和宋清朗相戀三年屠尊,在試婚紗的時候發(fā)現(xiàn)自己被綠了。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片耕拷。...
    茶點故事閱讀 38,712評論 1 341
  • 序言:一個原本活蹦亂跳的男人離奇死亡讼昆,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出骚烧,到底是詐尸還是另有隱情浸赫,我是刑警寧澤,帶...
    沈念sama閱讀 34,389評論 4 332
  • 正文 年R本政府宣布赃绊,位于F島的核電站既峡,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏碧查。R本人自食惡果不足惜运敢,卻給世界環(huán)境...
    茶點故事閱讀 40,032評論 3 316
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望忠售。 院中可真熱鬧传惠,春花似錦、人聲如沸稻扬。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,798評論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽泰佳。三九已至盼砍,卻和暖如春尘吗,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背浇坐。 一陣腳步聲響...
    開封第一講書人閱讀 32,026評論 1 266
  • 我被黑心中介騙來泰國打工摇予, 沒想到剛下飛機(jī)就差點兒被人妖公主榨干…… 1. 我叫王不留,地道東北人吗跋。 一個月前我還...
    沈念sama閱讀 46,473評論 2 360
  • 正文 我出身青樓,卻偏偏與公主長得像宁昭,于是被迫代替她去往敵國和親跌宛。 傳聞我的和親對象是個殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點故事閱讀 43,606評論 2 350

推薦閱讀更多精彩內(nèi)容