雪中做梦吧 关注:436贴子:9,034
  • 5回复贴,共1

【程序篇】实践。

只看楼主收藏回复

抽空写一写小程序,小游戏。


IP属地:广东1楼2021-01-05 15:48回复
    什么样的?现在流行手游


    IP属地:山东来自Android客户端2楼2021-01-08 22:01
    收起回复
      时间:2021年1月22日
      简述:突然发现不能发东西在贴吧,算了,无所谓了。
      为了方便学习美术,用Unity弄了个小实践,可以转动几何体,方便我观察,一般情况下,我也只是在Unity里面用,方便添加模型。
      截图说明:





      IP属地:广东3楼2021-01-22 19:25
      回复
        代码只有一个:
        public class CameraSurround : MonoBehaviour {
        public GameObject look_objects;
        private int shape_count = 0;
        private int shape_index = 0;
        public Light gameobject_light;
        private bool is_self_rotate = true;
        public Text target_text;
        public Text color_text;
        private void Start()
        {
        look_objects = GameObject.Find("ReferShapes");
        shape_count = look_objects.transform.childCount;
        shape_index = 0;
        }
        void Update () {
        if(Input.GetKey(KeyCode.LeftArrow))
        {
        Vector3 rotate = new Vector3(0f, 1f, 0f);
        if(is_self_rotate)
        {
        transform.RotateAround(look_objects.transform.GetChild(shape_index).transform.position, rotate, 5f);
        }
        else
        {
        look_objects.transform.GetChild(shape_index).transform.Rotate(rotate);
        }
        }
        else if(Input.GetKey(KeyCode.RightArrow))
        {
        Vector3 rotate = new Vector3(0f, -1f, 0f);
        if (is_self_rotate)
        {
        transform.RotateAround(look_objects.transform.GetChild(shape_index).transform.position, rotate, 5f);
        }
        else
        {
        look_objects.transform.GetChild(shape_index).transform.Rotate(rotate);
        }
        }
        else if (Input.GetKey(KeyCode.UpArrow))
        {
        Vector3 rotate = new Vector3(1f, 0f, 0f);
        if (is_self_rotate)
        {
        transform.RotateAround(look_objects.transform.GetChild(shape_index).transform.position, rotate, 5f);
        }
        else
        {
        look_objects.transform.GetChild(shape_index).transform.Rotate(rotate);
        }
        }
        else if (Input.GetKey(KeyCode.DownArrow))
        {
        Vector3 rotate = new Vector3(-1f, 0f, 0f);
        if (is_self_rotate)
        {
        transform.RotateAround(look_objects.transform.GetChild(shape_index).transform.position, rotate, 5f);
        }
        else
        {
        look_objects.transform.GetChild(shape_index).transform.Rotate(rotate);
        }
        }
        else if (Input.GetKeyDown(KeyCode.R))
        {
        if(is_self_rotate)
        {
        transform.position = new Vector3(0, 0, 0);
        transform.rotation = new Quaternion(0f, 0f, 0f, 0f);
        }
        else
        {
        look_objects.transform.GetChild(shape_index).transform.rotation = new Quaternion(0f, 0f, 0f, 0f);
        }
        }
        else if(Input.GetKeyDown(KeyCode.N))
        {
        look_objects.transform.GetChild(shape_index).gameObject.SetActive(false);
        shape_index = shape_index < (shape_count - 1) ? (shape_index + 1) : 0;
        look_objects.transform.GetChild(shape_index).gameObject.SetActive(true);
        }
        else if(Input.GetKeyDown(KeyCode.M))
        {
        is_self_rotate = !is_self_rotate;
        target_text.text = is_self_rotate == true ? "目前旋转者为:摄像机" : "目前旋转者为:物体";
        }
        else if (Input.GetKeyDown(KeyCode.H))
        {
        float h, s, v;
        Color.RGBToHSV(gameobject_light.color, out h, out s, out v);
        h = h < 1f ? h + 0.05f : 0f;
        gameobject_light.color = Color.HSVToRGB(h,s,v);
        color_text.text = string.Format("当前颜色值为:H{0:P},S{1:P},V{2:P}", h, s, v);
        }
        else if (Input.GetKeyDown(KeyCode.S))
        {
        float h, s, v;
        Color.RGBToHSV(gameobject_light.color, out h, out s, out v);
        s = s < 1f ? s + 0.05f : 0f;
        gameobject_light.color = Color.HSVToRGB(h, s, v);
        color_text.text = string.Format("当前颜色值为:H{0:P},S{1:P},V{2:P}", h, s, v);
        }
        else if (Input.GetKeyDown(KeyCode.V))
        {
        float h, s, v;
        Color.RGBToHSV(gameobject_light.color, out h, out s, out v);
        v = v < 1f ? v + 0.05f : 0f;
        gameobject_light.color = Color.HSVToRGB(h, s, v);
        color_text.text = string.Format("当前颜色值为:H{0:P},S{1:P},V{2:P}", h, s, v);
        }
        if (Input.GetKeyDown(KeyCode.Escape) || Input.GetKeyDown(KeyCode.Home))
        {
        Application.Quit();
        }
        }
        }


        IP属地:广东4楼2021-01-22 19:25
        回复
          喵🐱,很努力哦


          来自iPhone客户端5楼2021-01-23 11:19
          回复