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. Voting for the Unity Awards are OPEN! We’re looking to celebrate creators across games, industry, film, and many more categories. Cast your vote now for all categories
    Dismiss Notice
  3. Dismiss Notice

Dropping ScriptableObjects into scene

Discussion in 'Scripting' started by joshcamas, Mar 24, 2018.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,268
    Hello friends!

    I have some scriptableobjects called ItemData. I am wanting to make it so when you drag and drop the object onto the scene, it creates a spawner (which is a monobehavior of mine)

    Any thoughts?

    Josh
     
  2. Sun-Dog

    Sun-Dog

    Joined:
    Mar 23, 2009
    Posts:
    144
    ScriptableObjects can contain code, but they don't get most of the usual Unity callbacks and they can't be attached to GameObjects. They can be instantiated into a scene, as they are merely code instances...

    Am I understanding that your SO contains all the data you need to create your spawner?

    Also, is this at runtime? or during edit time?
     
  3. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,268
    Edit time. And what I'm envisioning is some sort of editor code that detects a certain scriptable object has been dropped onto the scene window, and then creating a gameobject and adding some different monobehaviors and such :)
     
  4. Sun-Dog

    Sun-Dog

    Joined:
    Mar 23, 2009
    Posts:
    144
    I've never created "droppable" editor code, but I assume it's possible.

    If I were making a window, I'd have a variable that I could plug in an SO into and use that as the data...

    Not sure if that helps.

    I suppose the question is less the SO, but the *droppable* part.
     
    joshcamas likes this.
  5. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    1,268
    Right, I'm trying to figure out how to detect when I drop a UnityEngine.Object onto the scene window pretty much.
    It would be even cooler if I could detect when I drag it over it, but just drop works as well