Exemplo n.º 1
0
        //生成交互的UI 按钮
        private void SpawnKingdomButton(Kingdom k)
        {
            Kingdom kingdom       = k;
            Button  kingdomButton = Instantiate(kingdomButtonPrefab, kingdomButtonsContainer).GetComponent <Button>();

            kingdomButton.onClick.AddListener(() => LookAtKingdom(kingdom));

            kingdomButton.transform.GetChild(0).GetComponentInChildren <Text>().text = k.name;
        }
Exemplo n.º 2
0
        //生成黄色的点
        private void SpawnKingdomPoint(Kingdom k)
        {
            GameObject kingdom = Instantiate(kingdomPointPrefab, modelTransform);

            kingdom.transform.localEulerAngles = new Vector3(k.y + visualOffset.y, -k.x - visualOffset.x, 0);
            k.visualPoint = kingdom.transform.GetChild(0);

            SpawnKingdomButton(k);
        }
Exemplo n.º 3
0
        //摄像机转向物体  UI转换坐标出现在物体上
        public void LookAtKingdom(Kingdom k)
        {
            Transform cameraParent = Camera.main.transform.parent;
            Transform cameraPivot  = cameraParent.parent;

            cameraParent.DOLocalRotate(new Vector3(k.y, 0), lookDuration, RotateMode.Fast).SetEase(lookEase);
            cameraPivot.DOLocalRotate(new Vector3(0, -k.x, 0), lookDuration, RotateMode.Fast).SetEase(lookEase);

            FindObjectOfType <FollowTarget>().target = k.visualPoint;
        }