资源简介

抽空做的一个小Demo,基本功能还是能实现的。  1.左下遥杆控制移动 2.右下区域遥杆控制人物转向及相机跟随转向 3.右上遥杆控制视野(相机角度)

资源截图

代码片段和文件信息

using UnityEngine;
using System.Collections;
using UnityEngine.EventSystems;
using UnityEditor;
using UnityEngine.UI;

public class PlayersMove : MonoBehaviour {
    Gameobject Playerobject;//玩家物体
    float Range;//范围
    public Gameobject center;
    public Gameobject centerobject;//摇杆

    //方向遥感
    public Gameobject FangXiang;
    //bool fx = false;//判断是否为方向遥感区域

        //视野遥感
    public Gameobject ShiYe;
    public Gameobject SY;

    Vector3 offset = new Vector3();
    void Start()
    {
        offset = Camera.main.transform.position - transform.position;

        //centerUICreation();
        Playerobject = gameobject;
        print(Playerobject.name);
        Range = center.GetComponent().sizeDelta.x / 2;
        ///UIEventTrigger (自有脚本UI事件触发器)
        UIEventTrigger.Get(centerobject).onPointerDown = BtnEvent;//移动遥感事件
        UIEventTrigger.Get(FangXiang).onPointerEnter = FXYGEvent1;//方向遥感1
        UIEventTrigger.Get(FangXiang).onPointerExit = FXYGEvent2;//方向遥感2
        UIEventTrigger.Get(SY).onPointerDown = SYEvent;//视野遥感事件

    }

    private void Update()
    {
        if (zx==false)
        {
            Camera.main.transform.position = transform.position + offset;
        }
        
        //Camera.main.transform.LookAt(transform.position);
        
    }
    //void centerUICreation()
    //{
    //    Transform canvas = Gameobject.Find(“Canvas“).transform;
    //    center = new Gameobject(“Center“);
    //    center.transform.SetParent(canvas);
    //    Image centerImage= center.AddComponent();
    //    centerImage.sprite = Resources.Load(“Textures/Center/RadialJoy_Area“);
    //    RectTransform centerRectTransform = center.GetComponent();
    //    centerRectTransform.localPosition = new Vector3(1701700);
    //    centerRectTransform.sizeDelta = new Vector2(200200);
    //    centerRectTransform.anchorMin = new Vector2(00);
    //    centerRectTransform.anchorMax = new Vector2(0 0);
    //    centerRectTransform.pivot = new Vector2(0.5f 0.5f);
    //    centerRectTransform.Rotate(new Vector3());
    //    centerRectTransform.localScale = Vector3.one;
    //    //--------------------------------
    //    centerobject = new Gameobject(“Centerobject“);
    //    centerobject.transform.SetParent(center.transform);
    //    Image centerobjectImage = centerobject.AddComponent();
    //    centerobjectImage.sprite = Resources.Load(“Textures/Center/Button_active“);
    //    Button centerobjectButton = centerobject.AddComponent

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-10-24 15:00  YaoGan\
     目录           0  2018-10-23 19:10  YaoGan\.vs\
     目录           0  2018-10-23 19:10  YaoGan\.vs\YaoGan\
     目录           0  2018-10-23 19:15  YaoGan\.vs\YaoGan\v15\
     文件       43008  2018-10-24 15:00  YaoGan\.vs\YaoGan\v15\.suo
     目录           0  2018-10-23 19:11  YaoGan\.vs\YaoGan\v15\Server\
     目录           0  2018-10-23 19:11  YaoGan\.vs\YaoGan\v15\Server\sqlite3\
     文件           0  2018-10-23 19:11  YaoGan\.vs\YaoGan\v15\Server\sqlite3\db.lock
     文件      446464  2018-10-23 21:32  YaoGan\.vs\YaoGan\v15\Server\sqlite3\storage.ide
     文件       32768  2018-10-24 13:58  YaoGan\.vs\YaoGan\v15\Server\sqlite3\storage.ide-shm
     文件     4124152  2018-10-24 15:01  YaoGan\.vs\YaoGan\v15\Server\sqlite3\storage.ide-wal
     目录           0  2018-10-24 14:57  YaoGan\Assets\
     文件       37188  2018-10-24 14:57  YaoGan\Assets\DuoYaoGan.unity
     文件         174  2018-10-23 20:19  YaoGan\Assets\DuoYaoGan.unity.meta
     文件        5016  2018-10-23 20:18  YaoGan\Assets\Red.mat
     文件         179  2018-10-23 19:22  YaoGan\Assets\Red.mat.meta
     目录           0  2018-10-24 15:01  YaoGan\Assets\Resources\
     文件         191  2018-09-19 23:02  YaoGan\Assets\Resources.meta
     目录           0  2018-10-24 14:55  YaoGan\Assets\scripts\
     文件        9136  2018-10-24 14:55  YaoGan\Assets\scripts\PlayersMove.cs
     文件         262  2018-09-19 09:58  YaoGan\Assets\scripts\PlayersMove.cs.meta
     文件        4810  2018-09-19 10:14  YaoGan\Assets\scripts\UIEventTrigger.cs
     文件         262  2018-09-19 10:16  YaoGan\Assets\scripts\UIEventTrigger.cs.meta
     文件         191  2018-09-19 23:02  YaoGan\Assets\scripts.meta
     目录           0  2018-10-23 19:53  YaoGan\Assets\Sprite\
     文件       14244  2018-09-19 11:06  YaoGan\Assets\Sprite\Button_active.png
     文件        1261  2018-09-19 11:10  YaoGan\Assets\Sprite\Button_active.png.meta
     文件       17634  2018-09-19 11:06  YaoGan\Assets\Sprite\Button_normal.png
     文件        1261  2018-09-19 11:10  YaoGan\Assets\Sprite\Button_normal.png.meta
     目录           0  2018-10-23 19:53  YaoGan\Assets\Sprite\Materials\
     文件        5012  2018-10-23 19:53  YaoGan\Assets\Sprite\Materials\ing-02f28715.mat
............此处省略440个文件信息

评论

共有 条评论