- Home /
How to display gameobject(prefab folder) as image?
Hi guys.I'm new here.I develop a fishing game.I have in prefab folders a lot of fishes.I go fish , i catch , increase score etc. but i want to display in a corner last fish that i catch.How can i do that? There is my code :
if (Sansa == 1) // rechin
{
RoosterAnimC.Play("Main|Ridicare_Undita");
LabelButon.text = "";
ComponentaButon.interactable = false;
yield return new WaitForSeconds(10);
PestePrins = (GameObject)Instantiate(Peste.gameObject, PunctIntrare.transform.position, PunctIntrare.transform.rotation);
NrPesti.text = (System.Int32.Parse(NrPesti.text) + 1).ToString();
Score.text = (System.Int32.Parse(Score.text) - 70).ToString();
// TextNotificare.text = "That’s not a demo. Give me your money!";
TextNotificare.text = getRandomMessagefromRechin();
Debug.Log(PestePrins);
ReplicaPeste.text = "";
yield return new WaitForSeconds(10);
}
PestePrins means CatchedFish in english.I translate because i'm from Romania and i want you to understand my variable names. I instantiate PestePrins as gamobject. If u notice , a few rows down , i Debug.Log(PestePrins) , i dispplay my catched fish . How can i display it in a corner as image ? Or display anywhere for this moment.I don't find anything to help me on internet. I'm newbie by the way. Thanks for helping me,have a nice day! :)
Answer by Zee-Play · Feb 22, 2017 at 01:10 PM
There are two ways to do this:
1 - Create an image of each fish that you have into a JPG or PNG (if you need transparent background), and use Canvas-Image where you replace the Source Image with your rendered ones based on what fish you catch. Can draw your own images, or render them via 3d software.
2 - use Render Texture, and have a second camera positioned somewhere off screen where your fish models will load in front of it. The rendered texture will again be assigned to a Canvas-Image, and make sure your render texture camera has a cooling mask so it can only see the fish. This option will allow you to have your fish in the corner of the screen also animated.\ https://www.youtube.com/watch?v=pA7ZC8owaeo
Hmm , pretty hard for me :( i'm newbie.$$anonymous$$y problem is how can i do this in script? Thanks anyway , i will try ur method :)