Skip to content

Conversation

@marc-antoine-girard
Copy link
Contributor

Definition

Adds Prefabs to the Dropdown menu in Asset Location.

Note

I did the issue, but it's hard to find value in it since having a reference to a prefab is usually only useful to instantiate it. Unless the goal is to edit prefabs in the editor, letting users see prefab might simply cluster the Dropdown for no reason.

But then, I also found this pretty useful use case, so it might still be worth considering:

public interface IComponent
{
    public GameObject gameObject { get; } // Value will auto-hook in any MonoBehaviour
}

public interface IEat : IComponent { }
public interface ISleep : IComponent { }
public interface IDie : IComponent { }

public class Dog : MonoBehaviour, IEat, ISleep, IDie { }

// ------------------------------------------------------------------
public class EaterGenerator : MonoBehaviour
{
    public SerializableInterface<IEat> prefab;

    private void Awake() => Instantiate(prefab.Value.gameObject);
}

// ------------------------------------------------------------------
public class KillableGenerator : MonoBehaviour
{
    public SerializableInterface<IDie> prefab;

    private void Awake() => Instantiate(prefab.Value.gameObject);
}

// ------------------------------------------------------------------
public class DogGenerator : MonoBehaviour
{
    public Dog prefab;

    private void Awake() => Instantiate(prefab.gameObject);
}

Copy link
Owner

@Thundernerd Thundernerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest you pull/merge the latest changes into this branch after I've merged the other open PR from you. Then I'll go over this one :)

@Thundernerd
Copy link
Owner

Thundernerd commented Jul 22, 2022

Merging the other PR caused some merge conflicts again :D

@marc-antoine-girard
Copy link
Contributor Author

:D

}
else if (assetType == typeof(GameObject))
{
GameObject gameObject = AssetDatabase.LoadAssetAtPath<GameObject>(assetPath);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm. I have a feeling that this might become very slow for larger projects

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, so much so that I ended up making this: #57
If this is to remain I think it would be very nice with a setting to exclude this behaviour, as it is very painful for me to wait like 5 seconds for the dropdown to open haha

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof yeah that is pretty bad! I'll have a look at your PR!

Copy link
Contributor Author

@marc-antoine-girard marc-antoine-girard Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, sorry about that! It became so slow in our project that we had to comment it out. We were looking in a way to stream the assets instead of loading them. I believe the new Search package in Unity does that, but I'm not sure how to use their API yet.

Edit: Had we had the Preference window, I think it would've made sense to have Prefab lookup disabled by default. In small project, I'm sure it can have value, but it sure doesn't scale well.

@Thundernerd Thundernerd merged commit 229a645 into Thundernerd:main Jul 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants