当前位置:网站首页>Implementation of unity transport mechanism
Implementation of unity transport mechanism
2022-06-11 04:21:00 【Sea moon】
effect
Location storage

Anchor point setting

Transfer interface

Transmission effect

Code
Location
using System.Collections.Generic;
using UnityEngine;
[CreateAssetMenu]
public class Locations : ScriptableObject
{
public List<Location> locations;
}Location saving tool
using UnityEditor;
using UnityEngine;
public class LocationSavingTool : Editor
{
public static Locations locationsAsset = Resources.Load<Locations>("Configurations/Locations");
[MenuItem("CONTEXT/Transform/ Save the location ")]
static void SaveLocationToAsset()
{
GameObject thisObject = Selection.activeGameObject;
locationsAsset.locations.Add(new Location(thisObject.name, thisObject.transform.position));
}
}Location manager
using UnityEngine;
public class LocationsManager : Singleton<LocationsManager>
{
public Locations locationsAsset = Resources.Load<Locations>("Configurations/Locations");
public Vector3 GetLocationByName(string name)
{
foreach (var i in locationsAsset.locations)
{
if (i.name == name)
{
return i.location;
}
}
return Vector3.zero;
}
}delivery
using UnityEngine;
public class Teleport : MonoBehaviour
{
void Start()
{
NotificationCenter.DefaultCenter().AddObserver(this, "PlayerTeleport");
}
public void PlayerTeleport(Notification notification)
{
GameObject player = GameObject.FindGameObjectWithTag("Player");
player.transform.position = (Vector3)notification.data;
}
}Transfer anchor
using UnityEngine;
public class TeleportPoint : MonoBehaviour
{
public string name;
public void OnClicked()
{
NotificationCenter.DefaultCenter().PostNotification(this, "PlayerTeleport", LocationsManager.Instance.GetLocationByName(name));
}
}边栏推荐
- Esp32 development -lvgl uses internal and external fonts
- 项目架构演进
- 图像检测相关模型数据格式
- Methods to detect whether PHP websites have been broken
- 2022 love analysis · privacy computing vendor panoramic report | love Analysis Report
- 2022 年 5 月产品大事记
- MySQL锁总结
- 直播助力杭州电商独角兽冲击上市,分账系统重构电商交易新格局
- Unity Advanced Backpack System
- Eth Of Erc20 And Erc721
猜你喜欢

给你一个项目,你将如何开展性能测试工作?

Esp32 development -lvgl uses internal and external fonts

Emlog新版导航源码/带用户中心

Guanghetong launched a new generation of 3GPP R16 industrial 5g module fg160 engineering sample

JVM(1):介绍、结构、运行和生命周期

Unity 遮挡剔除

Rational use of thread pool and thread variables

游戏数学: 计算屏幕点中的平面上的点(上帝视角)

Guanghetong officially released the sc126 series of intelligent modules to promote more intelligent connection

MySQL stored procedure
随机推荐
Embedded basic interface PWM
Methods to detect whether PHP websites have been broken
七个好用的装饰器
Market prospect analysis and Research Report of single photon counting detector in 2022
Guanghetong successfully won the bidding for China Unicom Yanfei CAT1 customized module with the largest share
Unity 高級背包系統
Embedded basic interface-i2s
【CustomView】Glide+BitmapTransformation 图片上下边框波浪处理(WaveTransformation)
2022 年 5 月产品大事记
d结构用作多维数组的索引
JVM(6):Slot变量槽、操作数栈、代码追踪、栈顶缓存技术
游戏数学: 计算屏幕点中的平面上的点(上帝视角)
直播助力杭州电商独角兽冲击上市,分账系统重构电商交易新格局
Guanghetong launched a new generation of 3GPP R16 industrial 5g module fg160 engineering sample
Vulkan-官方示例解读-RayTracingShadows&在这里边使用模型(1)
Guanghetong 5g module fg650-cn and fm650-cn series are produced in full scale, accelerating the efficient implementation of 5g UWB applications
2022 love analysis · privacy computing vendor panoramic report | love Analysis Report
域名解析耗时是什么?域名解析耗时影响因素有哪些?
Code replicates CSRF attack and resolves it
ESP series module burning firmware