当前位置:网站首页>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);
}
}边栏推荐
- Unity 在不平坦的地形上创建河流
- QT日志模块的个性化使用
- 司马炎爷爷 告诉你什么叫做内卷!
- Overview of guanghetong industrial 5g module product line
- Unity 高級背包系統
- Cloud broadcast alert, guanghetong helps intelligent camera to build a "river protection" drowning prevention system
- Unity prefab scene conflict merge tool unityyamlmerge
- Game Mathematics: calculate the points on the plane in the screen points (God's perspective)
- Vulkan-官方示例解读-RayTracingShadows&在这里边使用模型(1)
- Watson K's Secret Diary
猜你喜欢

2022 love analysis · privacy computing vendor panoramic report | love Analysis Report

Unity 高级背包系统

Statistical knowledge required by data analysts

MySQL lock summary

Feature selection algorithm based on bare bones particleswarm optimization

Introduction to the development and production functions of shop facade transfer and rental applet

写给通信年轻人的27个忠告

从初代播种到落地生花,5G商用三周年“催生万物”

2022爱分析· 隐私计算厂商全景报告 | 爱分析报告

详解 | 晶振的构造及工作原理
随机推荐
Data type conversion and conditional control statements
Redis主从复制、哨兵、cluster集群原理+实验(好好等,会晚些,但会更好)
Guanghetong launched a new generation of 3GPP R16 industrial 5g module fg160 engineering sample
2022 年 5 月产品大事记
详解 | 晶振的构造及工作原理
golang泛型:generics
直播助力杭州电商独角兽冲击上市,分账系统重构电商交易新格局
The future has come and the 5g advanced era has begun
JVM (4): active and passive use of classes, internal structure of runtime data area, JVM thread description, PC register
Esp32 porting lvgl
Unity 消息框架 NotificationCenter
Unity 可缩放地图的制作
Market prospect analysis and Research Report of nitrogen liquefier in 2022
AI助力,释放法务势能!iTerms合同智审系统重磅发布
Unity 遮挡剔除
Protection and bypass of repeated contracting
mysql存储过程
JVM(6):Slot变量槽、操作数栈、代码追踪、栈顶缓存技术
你知道MallBook分账与银行分账的区别吗?
Guanghetong 5g module shines brightly and has won the "2021 science and technology award of China Electronics Society"