//特殊物体属性处理
	private void SetSpecialObjInfo(string spe_name, string spe_type, string spe_value, ref bool is_right)
	{
		Transform speTrans = null;
		try
		{
			speTrans = GameObject.Find(spe_name).transform;
		}
		catch
		{
			UnityEngine.Debug.LogError(spe_name + ",该物体在当前场景中不存在,请确认!");
			is_right = false;
			return;
		}
		if (spe_type.ToUpper() == "CAMERAMOTION")
		{  //Camera View的大小
			Camera tempCamera;
			try
			{
				tempCamera = speTrans.gameObject.camera;
			}
			catch
			{
				UnityEngine.Debug.LogError(spe_name + ",该物体不是摄像机或者Camera无效,请确认!");
				is_right = false;
				return;
			}
			BaseCompute baseCal = new BaseCompute();
			float sValue = baseCal.FloatConversion(spe_value, ref is_right);
			if (!is_right)
			{
				UnityEngine.Debug.LogError(spe_value + ",该值无效,请检查!");
				return;
			}
			if (tempCamera.orthographic)
			{
				tempCamera.orthographicSize = sValue;
			}
			else
			{
				tempCamera.fieldOfView = sValue;
			}
		}
		else if (spe_type.ToUpper() == "CAMERAACTIVE")
		{  //Camera当前是否处于激活状态,为了考虑多个Camera情况
			Camera tempCamera;
			try
			{
				tempCamera = speTrans.gameObject.camera;
			}
			catch
			{
				UnityEngine.Debug.LogError(spe_name + ",该物体不是摄像机或者Camera无效,请确认!");
				is_right = false;
				return;
			}
			if (spe_value.ToString() == "TRUE")
			{
				if (!tempCamera.enabled)
					tempCamera.enabled = true;
				if(CameraMotion.CurrentCamera != null)
					CameraMotion.CurrentStr = spe_name;
			}
			else
			{
				if (tempCamera.enabled)
					tempCamera.enabled = false;
			}
		}
		else
		{
			//TODO
		}
	}
Exemple #2
0
    //特殊物体属性处理
    private void SetSpecialObjInfo(string spe_name, string spe_type, string spe_value, ref bool is_right)
    {
        Transform speTrans = null;

        try
        {
            speTrans = GameObject.Find(spe_name).transform;
        }
        catch
        {
            UnityEngine.Debug.LogError(spe_name + ",该物体在当前场景中不存在,请确认!");
            is_right = false;
            return;
        }
        if (spe_type.ToUpper() == "CAMERAMOTION")
        {          //Camera View的大小
            Camera tempCamera;
            try
            {
                tempCamera = speTrans.gameObject.camera;
            }
            catch
            {
                UnityEngine.Debug.LogError(spe_name + ",该物体不是摄像机或者Camera无效,请确认!");
                is_right = false;
                return;
            }
            BaseCompute baseCal = new BaseCompute();
            float       sValue  = baseCal.FloatConversion(spe_value, ref is_right);
            if (!is_right)
            {
                UnityEngine.Debug.LogError(spe_value + ",该值无效,请检查!");
                return;
            }
            if (tempCamera.orthographic)
            {
                tempCamera.orthographicSize = sValue;
            }
            else
            {
                tempCamera.fieldOfView = sValue;
            }
        }
        else if (spe_type.ToUpper() == "CAMERAACTIVE")
        {          //Camera当前是否处于激活状态,为了考虑多个Camera情况
            Camera tempCamera;
            try
            {
                tempCamera = speTrans.gameObject.camera;
            }
            catch
            {
                UnityEngine.Debug.LogError(spe_name + ",该物体不是摄像机或者Camera无效,请确认!");
                is_right = false;
                return;
            }
            if (spe_value.ToString() == "TRUE")
            {
                if (!tempCamera.enabled)
                {
                    tempCamera.enabled = true;
                }
                if (CameraMotion.CurrentCamera != null)
                {
                    CameraMotion.CurrentStr = spe_name;
                }
            }
            else
            {
                if (tempCamera.enabled)
                {
                    tempCamera.enabled = false;
                }
            }
        }
        else
        {
            //TODO
        }
    }
	//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;
		}
	}
Exemple #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;
        }
    }