Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Cannot drag and drop scene objects into Custom Inspector GUI

Discussion in 'Editor & General Support' started by vickyyy0221, Oct 24, 2023.

  1. vickyyy0221

    vickyyy0221

    Joined:
    Oct 24, 2023
    Posts:
    8
    Hi, I am editing a Dialogue Editor for my case. I added an end trigger object as "trigger next button" for each dialogue item. When I tried to drag object from scene to Inspector, it won't let me drag it in, but it works if I drag the same type of object already save in folder.
    Dragging scene object to "End Trigger" field:
    upload_2023-10-24_11-22-4.png
    Dragging same saved prefab from folder:
    upload_2023-10-24_11-23-53.png
    Can anyone explain why and how to fix it?

    TheRopeCurse (1) - TestInteraction - Android - Unity 2022.3.9f1_ _DX11_ 2023-10-24 11-01-20.gif

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. [System.Serializable] //needed to make ScriptableObject out of this class
    4. public class DialogueElement
    5. {
    6.     // CharacterID is an index to the according character
    7.     public int CharacterID;
    8.  
    9.     //public enum Characters { CharacterA, CharacterB}; //no longer needed
    10.     public enum AvatarPos { left, right };
    11.  
    12.     [Header("CHARACTER")]
    13.     //public Characters Character;
    14.     public AvatarPos CharacterPosition;
    15.     public Sprite CharacterPic;
    16.     public GameObject EndTrigger;
    17.  
    18.     [Header("DIALOGUE")]
    19.     [Tooltip("What the character is saying")]
    20.     [TextArea]
    21.     public string DialogueText;
    22.     public GUIStyle DialogueTextStyle;
    23.     [Tooltip("How many letters per second")]
    24.     public float TextPlayBackSpeed;
    25.  
    26.     public AudioClip PlayBackSoundFile;
    27. }
     
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    8,391
    Long story short is assets cannot reference scene objects. It's an inherent Unity limitation due to a number of reasons.

    You generally need to devise some kind of ID registration system to cross this bridge from assets to scenes.