美文网首页
背包系统(2)

背包系统(2)

作者: 胤醚貔貅 | 来源:发表于2017-05-04 17:35 被阅读24次

显示物品的描述信息

用一个单例存放信息

usingUnityEngine;

usingSystem.Collections;

publicclassUIManager:MonoBehaviour{

public Gameobject  panel;

private UIManager( ) {  }

private static UIManager  instance;

public static UIManager Instance{

get{

if(instance==null){

instance =new UIManager ( );

instance.panel =Gameobject.Find("Canvas").transform.FindChild("panel").gameobject;

}

return instance;

}

}

}

显示panel(//挂在预设体item上)

usingUnityEngine;

usingSystem.Collections;

usingUnityEngine.UI;

usingUnityEngine.EventSystems;

publicclassItemDescriptionScript:MonoBehaviour,IPointerEnterHandler,IPointerExitHandler{

//private Gameobject  panel;

public BaseScript goods;

voidStart( ){

//       panel = transform.root.FindChild ("Panel").gameObject ;//item最底层的父物体(Canvas)和panel的父物体相同

}

voidUpdate( ){

}

#regionIPointerEnterHandlerimplementation

publicvoidOnPointerEnter(PointerEventDataeventData)

{

if(!UIManager.Instance.panel.activeSelf){

UIManager.Instance.panel.SetActive(true);

UIManager.Instance.panel.GetComponent<ShowDetalScript>.Goods=goods;

}

}

#endregion

#regionIPointerExitHandlerimplementation

publicvoidOnPointerExit(PointerEventDataeventData)

{

if(UIManager.Instance.panel.activeSelf){

UIManager.Instance.panel.SetActive(false);

}

}

#endregion

}

将物品加载到panel上(//描述,挂在Panel上)

usingUnityEngine;

usingSystem.Collections;

usingUnityEngine.UI;

public classShowDetalScript:MonoBehaviour{

private BaseScript goods;

public BaseScript Goods{

get{

returngoods;

}

set{

goods=value;

headImage.overrideSprite=Resources.Load("Texture/"+goods.iconName);

goodsName.text=goods.name;

description.text=goods.description;

}

}

private  Image  headImage;

private  Text   goodsName;

private  Text    description;

voidAwake( ){

headImage=transform.GetChild(0).gameObject.GetComponent<Image>( );

description=transform.GetChild(1).gameObject.GetComponent<Text>( );

goodsName=transform.GetChild(2).gameObject.GetComponent<Text>( );

}

voidUpdate( ){

}

}

翻页(挂载在Canvas上)

usingUnityEngine;

usingSystem.Collections;

publicclassNextPageScript:MonoBehaviour{

publicGameObjectcontent;

voidStart(){

}

voidUpdate(){

}

publicvoidButtonPressed( ){

content.transform.localPosition=newVector3(content.transform.localPosition.x,content.transform.localPosition.y+400f,0);

}

publicvoidButtonPressed_1( ){

content.transform.localPosition=newVector3(content.transform.localPosition.x,content.transform.localPosition.y-400f,0);

}

}


相关文章

  • 背包系统(2)

    显示物品的描述信息 用一个单例存放信息 usingUnityEngine; usingSystem.Collect...

  • NGUI背包系统

    NGUI背包系统实现装备的拾取、拖拽,交换以及数量的叠加 步骤一:实现游戏装备的拖拽 首先导入NGUI插件,导入后...

  • 背包问题2(完全背包)

    01背包是指每件物品有且只有一件,而完全背包则是每件物品件数无限,求装入背包所对应的最值。完全背包也有公式,在01...

  • 18NGUI之背包系统

    NGUI背包系统的制作## 一、背包系统的搭建## 二、格子里面物品(预制物的制作)## 格子里面的物体需要实现可...

  • 21UGUI背包系统

    一、UGUI背包系统展示## 二、背包系统的搭建## 三、加载预支物的制作## 四、预支物基类的建立以及各种相应的...

  • Unity背包系统设计

    背包系统设计思路 基本思路:玩家在场景中捡到东西——放入背包中对应Item栏——点击装备武器放入人物装备槽(改变s...

  • 5.3背包系统(1)

    基类脚本 usingUnityEngine; usingSystem.Collections; publiccla...

  • UGUI事件系统和背包系统

    IPointerEnterHandler OnPointerEnter 当鼠标进入 IPointerE...

  • Unity MMORPG 背包系统如何设计

    前言 MMORPG游戏中背包系统是很重要的一个模块, 大部分的背包系统的讲解,都是讲如何设计UI,如何显示这些,其...

  • Unity MMORPG 背包系统如何设计

    MMORPG游戏中背包系统是很重要的一个模块, 大部分的背包系统的讲解,都是讲如何设计UI,如何显示这些,其实这些...

网友评论

      本文标题:背包系统(2)

      本文链接:https://www.haomeiwen.com/subject/pnrdtxtx.html