Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to get clones to instantiate inside Canvas?

Discussion in 'Scripting' started by ACodingLegend, Jan 27, 2016.

  1. ACodingLegend

    ACodingLegend

    Joined:
    Oct 1, 2015
    Posts:
    9
    Hello, I'm instantiating a game object called projectile. I want it to appear on the canvas so It can be viable during game play.

    My fire method, which triggers the creating of a projectile.
    hellp1.PNG

    And how it appears in the game: (red is the play tint)
    hellp2.PNG
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
  3. mikeymike

    mikeymike

    Joined:
    Oct 21, 2014
    Posts:
    35
    Code (csharp):
    1.  
    2. GameObject beam = .... as GameObject;
    3.  
    4. beam.transform.parent = myCanvas;
    5.  
    obviously youll need a reference to your canvas.
     
  4. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148