Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
2 captures
13 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
This question was closed Jun 02 at 08:10 AM by andrew-lukasik for the following reason:

The question is answered, right answer was accepted

avatar image
0
Question by fireblacksage · Jun 02 at 08:08 AM · spritesimages

I am trying to make my sprite show up as an image from a card database.


Card Database.cs

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class CardDatabase : MonoBehaviour
 {
     public static List<Card> cardList = new List<Card>();
 
     private void Awake()
     {
         cardList.Add(new Card(0, "Apple", 1, 1, 1, Resources.Load<Sprite>("111b")));
         cardList.Add(new Card(1, "So", 1, 1, 2, Resources.Load<Sprite>("112b")));
     }
 }


Display Card.cs

 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 using UnityEngine.EventSystems;
 
 public class DisplayCard : MonoBehaviour
 {
     public List<Card> displayCard = new List<Card>();
     public int displayId;
 
     public int id;
     public string cardName;
     public int speed;
     public int attack;
     public int defense;
     public Sprite spriteImage;
 
     public Text nameText;
     public Text speedText;
     public Text attackText;
     public Text defenseText;
     public Image artImage;
 
 
     // Start is called before the first frame update
     void Start()
     {
         displayCard[0] = CardDatabase.cardList[displayId];
     }
 
     // Update is called once per frame
     void Update()
     {
         id = displayCard[0].id;
         cardName = displayCard[0].cardName;
         speed = displayCard[0].speed;
         attack = displayCard[0].attack;
         defense = displayCard[0].defense;
         spriteImage = displayCard[0].spriteImage;
 
 
         nameText.text = " " + cardName;
         speedText.text = " " + speed;
         attackText.text = " " + attack;
         defenseText.text = " " + defense;
         artImage.sprite = spriteImage;
     }
 }


Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

  • Sort: 
avatar image
0
Best Answer

Answer by fireblacksage · Jun 02 at 02:56 AM

I solved it

 void Start()
 {
     displayCard[0] = CardDatabase.cardList[displayId];
     rend = GetComponent<Image>();
 }

 // Update is called once per frame
 void Update()
 {
     id = displayCard[0].id;
     cardName = displayCard[0].cardName;
     speed = displayCard[0].speed;
     attack = displayCard[0].attack;
     defense = displayCard[0].defense;
     imageName = displayCard[0].imageName;
     spriteImage = Resources.Load<Sprite>(imageName);
     rend.sprite = spriteImage;


     nameText.text = " " + cardName;
     speedText.text = " " + speed;
     attackText.text = " " + attack;
     defenseText.text = " " + defense;
     rend.sprite = spriteImage;
 }


Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

189 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Decreasing PNG image size result increasing in edges artifacts 0 Answers

Strange Blurry Sprites 1 Answer

How to make a double sided sprite that has two different images on each side? 0 Answers

Help with Zelda type health bar! 0 Answers

How to dynamically place images/sprites 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges