Exemplo n.º 1
0
    //Json文件加载
    private void JsonLoad(string path_name, CRSpline crSpline, ref bool is_right, Transform parent_trans)
    {
        string filePath = MotionPara.taskRootPath + MotionPara.taskName + "/PathControl.json";

        if (File.Exists(filePath))
        {
            JsonOperator jsonOp    = new JsonOperator();
            DataTable    jsonTable = jsonOp.JsonReader(filePath, path_name);
            if (jsonTable == null)
            {
                Debug.LogError(path_name + ", 该路径名称不存在!");
                return;
            }
            GameObject loadEmpty = new GameObject();
            loadEmpty.name             = "JsonLoad_empty";
            loadEmpty.transform.parent = parent_trans;
            for (int i = 0; i < jsonTable.Rows.Count; i++)
            {
                loadEmpty.transform.localPosition    = ConvertToVector3((string)jsonTable.Rows[i][0].ToString());
                loadEmpty.transform.localEulerAngles = ConvertToVector3((string)jsonTable.Rows[i][1].ToString());
                crSpline.controlPoints.Add(loadEmpty.transform.position);
                crSpline.rotationList.Add(loadEmpty.transform.eulerAngles);
                crSpline.cameraViewList.Add(float.Parse((string)jsonTable.Rows[i][2].ToString()));
            }
            GameObject.DestroyImmediate(loadEmpty);
        }
        else
        {
            Debug.LogError(filePath + ", 该文件不存在!");
        }
    }
Exemplo n.º 2
0
	//Json数据提取
	private void JsonLocationSet(string nodeName, string column_name)
	{
		nodeName = nodeName.ToUpper();
		//检查是否存在以该数模命名的文件夹
		string locationPath = MotionPara.taskRootPath + MotionPara.taskName + "/";
		string subPath = "";
		if (nodeName.StartsWith("C"))
		{
			subPath = "C/";
		}
		else if (nodeName.StartsWith("Y"))
		{
			subPath = "Y/";
		}
		else if (nodeName.StartsWith("Z"))
		{
			subPath = "Z/";
		}
		else
		{
			UnityEngine.Debug.LogError("输入的节点名称:" + nodeName + ",格式不正确!");
			return;
		}
		//检查数字是否正确
		int fileNum = 0;
		try
		{
			fileNum = int.Parse(nodeName.Substring(1));
		}
		catch
		{
			UnityEngine.Debug.LogError("输入的节点名称:" + nodeName + ",格式不正确!");
			return;
		}
		string filePreName = nodeName.Substring(0, 1) + fileNum.ToString();
		//Json处理类
		JsonOperator jsonOp = new JsonOperator();
		if (File.Exists(locationPath + subPath + filePreName + "Location.json"))
		{
			DataTable posTable = jsonOp.JsonReader(locationPath + subPath + filePreName + "Location.json", "LOCATION" + column_name);
			Transform objTransform = null;
			bool isRight = true;
			BaseCompute baseCal = new BaseCompute();
			for (int i = 0; i < posTable.Rows.Count; i++)
			{
				try
				{
					objTransform = GameObject.Find((string)posTable.Rows[i][0].ToString()).transform;
				}
				catch
				{
					UnityEngine.Debug.LogError((string)posTable.Rows[i][0].ToString() + ",该物体在当前场景中不存在,请确认!");
					return;
				}
				objTransform.position = baseCal.Vector3Conversion((string)posTable.Rows[i][1].ToString(), ref isRight);
				if (!isRight)
				{
					UnityEngine.Debug.LogError((string)posTable.Rows[i][1].ToString() + ",位置向量转化错误,请检查!");
					return;
				}
				objTransform.eulerAngles = baseCal.Vector3Conversion((string)posTable.Rows[i][2].ToString(), ref isRight);
				if (!isRight)
				{
					UnityEngine.Debug.LogError((string)posTable.Rows[i][2].ToString() + ",角度向量转化错误,请检查!");
					return;
				}
			}
			if (File.Exists(locationPath + subPath + filePreName + "Location.json"))
			{
				DataTable speTable = jsonOp.JsonReader(locationPath + subPath + filePreName + "Location.json", "SPECIAL" + column_name);
				string speName = "";
				string speType = "";
				string speValue = "";
				for (int i = 0; i < speTable.Rows.Count; i++)
				{
					speName = (string)speTable.Rows[i][0].ToString();
					speType = (string)speTable.Rows[i][1].ToString();
					speValue = (string)speTable.Rows[i][2].ToString();
					SetSpecialObjInfo(speName, speType, speValue, ref isRight);
					if (!isRight)
					{
						UnityEngine.Debug.LogError((string)speTable.Rows[i][0].ToString() + ",该处信息有误,请检查!");
						return;
					}
				}
			}
		}
		else
		{
			UnityEngine.Debug.LogError(locationPath + subPath + filePreName + "Location.json,该文件不存在,请确认!");
			return;
		}
	}
Exemplo n.º 3
0
	//Json文件加载
	private void JsonLoad(string path_name, CRSpline crSpline, ref bool is_right, Transform parent_trans)
	{
		string filePath = MotionPara.taskRootPath + MotionPara.taskName + "/PathControl.json";
		if (File.Exists(filePath))
		{
			JsonOperator jsonOp = new JsonOperator();
			DataTable jsonTable = jsonOp.JsonReader(filePath, path_name);
			if (jsonTable == null)
			{
				Debug.LogError(path_name + ", 该路径名称不存在!");
				return;
			}
			GameObject loadEmpty = new GameObject();
			loadEmpty.name = "JsonLoad_empty";
			loadEmpty.transform.parent = parent_trans;
			for (int i = 0; i < jsonTable.Rows.Count; i++)
			{
				loadEmpty.transform.localPosition = ConvertToVector3((string)jsonTable.Rows[i][0].ToString());
				loadEmpty.transform.localEulerAngles = ConvertToVector3((string)jsonTable.Rows[i][1].ToString());
				crSpline.controlPoints.Add(loadEmpty.transform.position);
				crSpline.rotationList.Add(loadEmpty.transform.eulerAngles);
				crSpline.cameraViewList.Add(float.Parse((string)jsonTable.Rows[i][2].ToString()));
			}
			GameObject.DestroyImmediate(loadEmpty);
		}
		else
		{
			Debug.LogError(filePath + ", 该文件不存在!");
		}
	}
Exemplo n.º 4
0
    //Json数据提取
    private void JsonLocationSet(string nodeName, string column_name)
    {
        nodeName = nodeName.ToUpper();
        //检查是否存在以该数模命名的文件夹
        string locationPath = MotionPara.taskRootPath + MotionPara.taskName + "/";
        string subPath      = "";

        if (nodeName.StartsWith("C"))
        {
            subPath = "C/";
        }
        else if (nodeName.StartsWith("Y"))
        {
            subPath = "Y/";
        }
        else if (nodeName.StartsWith("Z"))
        {
            subPath = "Z/";
        }
        else
        {
            UnityEngine.Debug.LogError("输入的节点名称:" + nodeName + ",格式不正确!");
            return;
        }
        //检查数字是否正确
        int fileNum = 0;

        try
        {
            fileNum = int.Parse(nodeName.Substring(1));
        }
        catch
        {
            UnityEngine.Debug.LogError("输入的节点名称:" + nodeName + ",格式不正确!");
            return;
        }
        string filePreName = nodeName.Substring(0, 1) + fileNum.ToString();
        //Json处理类
        JsonOperator jsonOp = new JsonOperator();

        if (File.Exists(locationPath + subPath + filePreName + "Location.json"))
        {
            DataTable   posTable     = jsonOp.JsonReader(locationPath + subPath + filePreName + "Location.json", "LOCATION" + column_name);
            Transform   objTransform = null;
            bool        isRight      = true;
            BaseCompute baseCal      = new BaseCompute();
            for (int i = 0; i < posTable.Rows.Count; i++)
            {
                try
                {
                    objTransform = GameObject.Find((string)posTable.Rows[i][0].ToString()).transform;
                }
                catch
                {
                    UnityEngine.Debug.LogError((string)posTable.Rows[i][0].ToString() + ",该物体在当前场景中不存在,请确认!");
                    return;
                }
                objTransform.position = baseCal.Vector3Conversion((string)posTable.Rows[i][1].ToString(), ref isRight);
                if (!isRight)
                {
                    UnityEngine.Debug.LogError((string)posTable.Rows[i][1].ToString() + ",位置向量转化错误,请检查!");
                    return;
                }
                objTransform.eulerAngles = baseCal.Vector3Conversion((string)posTable.Rows[i][2].ToString(), ref isRight);
                if (!isRight)
                {
                    UnityEngine.Debug.LogError((string)posTable.Rows[i][2].ToString() + ",角度向量转化错误,请检查!");
                    return;
                }
            }
            if (File.Exists(locationPath + subPath + filePreName + "Location.json"))
            {
                DataTable speTable = jsonOp.JsonReader(locationPath + subPath + filePreName + "Location.json", "SPECIAL" + column_name);
                string    speName  = "";
                string    speType  = "";
                string    speValue = "";
                for (int i = 0; i < speTable.Rows.Count; i++)
                {
                    speName  = (string)speTable.Rows[i][0].ToString();
                    speType  = (string)speTable.Rows[i][1].ToString();
                    speValue = (string)speTable.Rows[i][2].ToString();
                    SetSpecialObjInfo(speName, speType, speValue, ref isRight);
                    if (!isRight)
                    {
                        UnityEngine.Debug.LogError((string)speTable.Rows[i][0].ToString() + ",该处信息有误,请检查!");
                        return;
                    }
                }
            }
        }
        else
        {
            UnityEngine.Debug.LogError(locationPath + subPath + filePreName + "Location.json,该文件不存在,请确认!");
            return;
        }
    }
Exemplo n.º 5
0
    //Json文件加载
    private void JsonLoad()
    {
        string filePath = Application.dataPath + "/_TempExcel/TempPathInfo.json";

        if (File.Exists(filePath))
        {
            JsonOperator jsonOp    = new JsonOperator();
            DataTable    jsonTable = jsonOp.JsonReader(filePath, _target.pathName);
            if (jsonTable == null)
            {
                Debug.LogError(_target.pathName + ", 该路径名称不存在!");
                return;
            }
            //移动到起点
            _target.transform.position = _target.nodes[0];
            if (_target.camera != null)
            {
                _target.CameraView = _target.cameraViewList[0];
            }
            if (_target.isCamera && _target.camera != null)
            {
                if (_target.isLookAt && _target.lookAt != null)
                {
                    _target.transform.LookAt(_target.lookAt);
                }
                else
                {
                    _target.transform.eulerAngles = _target.rotationList[0];
                }
            }
            else
            {
                _target.transform.eulerAngles = _target.rotationList[0];
            }
            GameObject loadEmpty = new GameObject();
            loadEmpty.name             = "JsonLoad_empty";
            loadEmpty.transform.parent = _target.transform;
            _target.nodes.Clear();
            _target.rotationList.Clear();
            _target.cameraViewList.Clear();
            _target.displayInfoList.Clear();
            _target.handleDisplay.Clear();
            for (int i = 0; i < jsonTable.Rows.Count; i++)
            {
                loadEmpty.transform.localPosition    = ConvertToVector3((string)jsonTable.Rows[i][0].ToString());
                loadEmpty.transform.localEulerAngles = ConvertToVector3((string)jsonTable.Rows[i][1].ToString());
                _target.nodes.Add(loadEmpty.transform.position);
                _target.rotationList.Add(loadEmpty.transform.eulerAngles);
                _target.cameraViewList.Add(float.Parse((string)jsonTable.Rows[i][2].ToString()));
                _target.displayInfoList.Add(false);
                _target.handleDisplay.Add(true);
            }
            _target.nodeCount = _target.nodes.Count;
            AngleOptimization();
            GameObject.DestroyImmediate(loadEmpty);
        }
        else
        {
            Debug.LogError(filePath + ", 该文件不存在!");
        }
    }
Exemplo n.º 6
0
 //Json文件加载
 private void JsonLoad()
 {
     string filePath = Application.dataPath + "/_TempExcel/TempPathInfo.json";
     if (File.Exists(filePath))
     {
         JsonOperator jsonOp = new JsonOperator();
         DataTable jsonTable = jsonOp.JsonReader(filePath, _target.pathName);
         if (jsonTable == null)
         {
             Debug.LogError(_target.pathName + ", 该路径名称不存在!");
             return;
         }
         //移动到起点
         _target.transform.position = _target.nodes[0];
         if (_target.camera != null)
         {
             _target.CameraView = _target.cameraViewList[0];
         }
         if (_target.isCamera && _target.camera != null)
         {
             if (_target.isLookAt && _target.lookAt != null)
             {
                 _target.transform.LookAt(_target.lookAt);
             }
             else
             {
                 _target.transform.eulerAngles = _target.rotationList[0];
             }
         }
         else
         {
             _target.transform.eulerAngles = _target.rotationList[0];
         }
         GameObject loadEmpty = new GameObject();
         loadEmpty.name = "JsonLoad_empty";
         loadEmpty.transform.parent = _target.transform;
         _target.nodes.Clear();
         _target.rotationList.Clear();
         _target.cameraViewList.Clear();
         _target.displayInfoList.Clear();
         _target.handleDisplay.Clear();
         for (int i = 0; i < jsonTable.Rows.Count; i++)
         {
             loadEmpty.transform.localPosition = ConvertToVector3((string)jsonTable.Rows[i][0].ToString());
             loadEmpty.transform.localEulerAngles = ConvertToVector3((string)jsonTable.Rows[i][1].ToString());
             _target.nodes.Add(loadEmpty.transform.position);
             _target.rotationList.Add(loadEmpty.transform.eulerAngles);
             _target.cameraViewList.Add(float.Parse((string)jsonTable.Rows[i][2].ToString()));
             _target.displayInfoList.Add(false);
             _target.handleDisplay.Add(true);
         }
         _target.nodeCount = _target.nodes.Count;
         AngleOptimization();
         GameObject.DestroyImmediate(loadEmpty);
     }
     else
     {
         Debug.LogError(filePath + ", 该文件不存在!");
     }
 }