zoukankan      html  css  js  c++  java
  • NGUI实现滑动屏幕的时候,进行环形旋转

    在滑动屏幕的时候,上图中的内容饶圆中心旋转,并且箭头的方向保持不变

    每个Item上挂载的脚本:

    1 using UnityEngine;
    2 
    3 public class ItemTest : MonoBehaviour
    4 {
    5     void Update()
    6     {
    7         transform.eulerAngles = Vector3.zero;
    8     }
    9 }

    父结点上挂载的脚本:

     1 using System.Collections;
     2 using System.Collections.Generic;
     3 using UnityEngine;
     4 
     5 public class lgs : MonoBehaviour
     6 {
     7     [SerializeField]
     8     ItemTest[] itemArray;
     9     [SerializeField]
    10     Vector3 centerPos;
    11     [SerializeField]
    12     float radius;
    13 
    14     Vector3[] posArray;
    15     void Start()
    16     {
    17         UIEventListener.Get(gameObject).onDrag = Drag;
    18         InitPosFromCircularRing(out posArray, centerPos, itemArray.Length, radius);
    19         for (int i = 0, iMax = itemArray.Length; i < iMax; i++)
    20         {
    21             itemArray[i].transform.localPosition = posArray[i];
    22         }
    23     }
    24 
    25     float tmpVal = 0;
    26     void Drag(GameObject go, Vector2 vec2)
    27     {
    28         tmpVal += vec2.y > 0 ? 2 : -2;
    29         transform.localEulerAngles = new Vector3(0, 0, tmpVal);
    30     }
    31 
    32     void InitPosFromCircularRing(out Vector3[] posArray, Vector3 centerPos, int count, float radius)
    33     {
    34         posArray = new Vector3[count];
    35         float copies = (360.0f / count) * Mathf.Deg2Rad;
    36         for (int i = 0, j = count; i < j; ++i)
    37         {
    38             float x = radius * Mathf.Cos(copies * i);
    39             //float y = centerPos.y;
    40             float z = radius * Mathf.Sin(copies * i);
    41             Vector3 vec3 = new Vector3(x, z, 0) + centerPos;
    42             posArray[i] = vec3;
    43         }
    44     }
    45 }
  • 相关阅读:
    android cts 命令的说明
    k8s认证授权和dashboard部署
    Pod对象的基本概念
    k8s创建自定义资源
    flannel网络插件介绍
    go语言包的介绍
    安装k8s的自动代码生成器
    k8s的pv和pvc概念
    Es索引匹配查询
    shell实现自动化部署项目
  • 原文地址:https://www.cnblogs.com/luguoshuai/p/10764468.html
Copyright © 2011-2022 走看看