当前位置:网站首页>Unity item model rotating display
Unity item model rotating display
2022-06-11 04:22:00 【Sea moon】
Panel structure

Camera structure

Implementation method
Use RawImage Show RenderTexture,RenderTexture The image source of is the item detail camera .
Generate the item at the specified location , Then use a controller to make it rotate automatically , And then light it with a spotlight , It's done. .



effect
Unity Backpack system
Code
Item details panel
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ItemDetailPanel : BasePanel
{
static readonly string path = "Prefabs/UI/ItemDetailPanel";
Item itemToDisplayed;
public ItemDetailPanel(Item item) : base(new PanelType(path))
{
itemToDisplayed = item;
}
Transform itemPosition;
public override void OnEnter()
{
SetViewPosition();
itemPosition = GameObject.Find("ItemPosition").transform;
panelBindingTool.GetOrAddComponentInChildren<Button>(" close ").onClick.AddListener(() =>
{
panelStack.Pop();
}
);
DisplayItemDetail(itemToDisplayed);
DisplayItemBeief(itemToDisplayed);
OrbitCamera.Instance.work = false;
}
RawImage display;
void SetViewPosition()
{
display = panelBindingTool.GetOrAddComponentInChildren<RawImage>("Display");
if (itemToDisplayed.id / 100 - 1 == 0)
display.texture = Resources.Load<Texture>("Texture/ItemDetail/ItemDetail Horizontal");
else
display.texture = Resources.Load<Texture>("Texture/ItemDetail/ItemDetail Up View");
}
public override void OnExit()
{
GameObject.Destroy(DetailViewController.Instance.modelDisplayed);
panelManager.DestroyPanel(this.panelType);
OrbitCamera.Instance.work = true;
}
public override void OnPause()
{
panelBindingTool.GetOrAddComponent<CanvasGroup>().blocksRaycasts = false;
}
public override void OnResume()
{
panelBindingTool.GetOrAddComponent<CanvasGroup>().blocksRaycasts = true;
}
public void DisplayItemDetail(Item item)
{
DetailViewController.Instance.modelDisplayed = GameObject.Instantiate(item.model, itemPosition);
}
public void DisplayItemBeief(Item item)
{
panelBindingTool.GetOrAddComponentInChildren<Text>("Item Name").text = item.name;
panelBindingTool.GetOrAddComponentInChildren<Text>("Item Description").text = item.description;
panelBindingTool.GetOrAddComponentInChildren<Image>("Item Image").sprite = Sprite.Create(item.icon, new Rect(0, 0, item.icon.width, item.icon.height), new Vector2(0.5f, 0.5f));
}
}Model rotation controller
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class DetailViewController : MonoSingleton<DetailViewController>
{
public GameObject modelDisplayed;
// Update is called once per frame
void Update()
{
if(modelDisplayed)
AutoRotate();
}
public float rotateSpeed = 5;
void AutoRotate()
{
modelDisplayed.transform.localEulerAngles += new Vector3(0, rotateSpeed * Time.deltaTime, 0);
}
}边栏推荐
- 项目架构演进
- meedu知识付费解决方案 v4.5.4源码
- Eth relay interface
- Market prospect analysis and Research Report of seed laser in 2022
- Vulkan-官方示例解读-RayTracingShadows&在这里边使用模型(1)
- Market prospect analysis and Research Report of hydrogen liquefier in 2022
- Market prospect analysis and Research Report of surround packing machine in 2022
- JVM (3): classloader classification and parental delegation mechanism
- PHP regular use case
- 零时科技 | Discover 闪电贷攻击事件分析
猜你喜欢

JVM(3):类加载器分类、双亲委派机制

为了实现零丢包,数据中心网络到底有多拼?

MySQL stored procedure

Guanghetong 5g module fg650-cn and fm650-cn series are produced in full scale, accelerating the efficient implementation of 5g UWB applications

Sslstrip Ultimate - location hijacking

Feature selection algorithm based on bare bones particleswarm optimization

JVM (3): classloader classification and parental delegation mechanism

Redis持久化(少年一贯快马扬帆,道阻且长不转弯)

Unity 编辑器扩展 保存位置

Unity 高级背包系统
随机推荐
L'avenir est venu, l'ère 5G - Advanced s'ouvre
Unity 可缩放地图的制作
Guanghetong LTE CAT6 module fm101-cg, which supports CBRS band, took the lead in obtaining FCC certification
记一次ES 事故
Feature selection algorithm based on bare bones particleswarm optimization
Market prospect analysis and Research Report of nitrogen liquefier in 2022
Embedded basic interface UART
Ultra simple cameraX face recognition effect package
Redis持久化(少年一贯快马扬帆,道阻且长不转弯)
ETH 中继接口
The future has come and the 5g advanced era has begun
JVM(2):内存结构、类的加载过程
Eth Of Erc20 And Erc721
Unity 消息框架 NotificationCenter
众昂矿业:氟化工是萤石的主要消耗领域
Personalized use of QT log module
未来已来,5G-Advanced时代开启
游戏数学: 计算屏幕点中的平面上的点(上帝视角)
Cloud broadcast alert, guanghetong helps intelligent camera to build a "river protection" drowning prevention system
Vulkan-官方示例解读-RayTracing