Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Event on instantiated prefab in a grid

Discussion in 'Editor & General Support' started by Arutanu, Jan 28, 2020.

  1. Arutanu

    Arutanu

    Joined:
    Jan 27, 2018
    Posts:
    1
    Hi, I don't have much experience with Unity so I often get stuck, but it's been over 24h now and nothing I found on google works.
    Basically, I have a GameCardPrefab that I dynamically instantiate in a Grid Layout that is the player's card hand. Said Grid Layout is located inside an UI Canvas. So far nothing too hard.
    Where I've been stuck and can't manage to make work in any way, is that I want to be able to zoom on a card when I hover it, click on it for X or Y reason. I tried putting event triggers on the prefab for OnMouseEnter and OnMouseExit through the unity editor, didn't do anything. Some posts said it's because it's a prefab and can't be referenced, so I dynamically set both event triggers when I instantiate each card of the hand. Didn't change a thing. I tried adding a collider. Event systems to send datas to my objects. I have a raycaster on my canvas. I tried adding a button.
    Nothing still, every time I try to print in the Debug.Log to check if the callback is called, but it never is. This is starting to become really infuriating and confusing 'cause I don't know at all what am I doing wrong.
    I really hope you guys could lend me a hand 'cause I'm at rock bottom here. Thank you.


    EDIT: Finally found someone that got me out of trouble. I apparently needed to create a stand alone EventSystem object
     
    Last edited: Jan 28, 2020
  2. Jasbir

    Jasbir

    Joined:
    Sep 28, 2020
    Posts:
    1
    hi, could you please share your solution. I am getting same kind of issue with dynamically instantiate Gridlayout and with its child button click event.