Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Gizmos in package.

Discussion in 'Package Manager' started by wang37921, Aug 9, 2019.

  1. wang37921

    wang37921

    Joined:
    Aug 1, 2014
    Posts:
    84
    While I making a custom package. I found if i can let the generated ScriptableObject asset has its own icon, will be cool.
    In general develop, it can be done by adding the namespace/to/Scriptable icon.png to Assets/Gizmos.
    So, I thought the custom package folder could include the Gizmos?
    And i found the office package include the Gizmos folder!
    But it has no effect, in my custom package...
    Any thing wrong, or it is no support now?
    upload_2019-8-9_14-49-53.png
     
    Rallix likes this.
  2. Adrian

    Adrian

    Joined:
    Apr 5, 2008
    Posts:
    485
    If you just want to assign an icon to a ScriptableObject, there's an easier way that works with packages:
    Just select the ScriptableObject script in the editor and click on its icon in the top left of the inspector to assign any Texture2D as its icon. Any instance of the ScriptableObject will then use that icon, too.
     
  3. Rallix

    Rallix

    Joined:
    Mar 17, 2016
    Posts:
    97
    I was looking for this as well.
    Looking at the Cinemachine's changelog, it looks like they used to copy the gizmos automatically to Assets/Gizmos after import (see here). You could use the same approach. I didn't check if it works yet, but I don't see why it shouldn't.
     
    wang37921 likes this.
  4. wang37921

    wang37921

    Joined:
    Aug 1, 2014
    Posts:
    84
    cool!
    the package build-in support merge behaviour will be better.
    But dont know whether be accepted.
    the Gizmos and othe special folder and files(like link.xml)
    https://forum.unity.com/threads/while-custom-package-need-a-link-xml.727460/
     
  5. KarolStolaDD

    KarolStolaDD

    Joined:
    Sep 10, 2019
    Posts:
    5
    There is a better way. You can specify the Full path to the gizmo with package qualifier:

    Code (CSharp):
    1. var assembly = Assembly.GetExecutingAssembly();
    2. var packagePath = PackagePath.FindForAssembly(assembly).assetPath;
    3. Gizmos.DrawIcon(transform.position, packagePath+"/Path/In/Package/Gizmo.png", true);
    This code will work from the inside of package. If you want to Reference a gizmo in package from the outside of it (other package or code in project), you have to provide the packagePath on your own. It goes like this:
    Code (CSharp):
    1. "Packages/com.yourcompany.packagename"
    where com.yourcompany.packagename is name from package.json.
     
  6. Rallix

    Rallix

    Joined:
    Mar 17, 2016
    Posts:
    97
    Yes, but this would only display the gizmo in Scene View, not in Inspector (to replace the default script icon).
    I mainly want a custom icon for a ScriptableObject or a MonoBehaviour – and for that, the icons currently need to be in the ‘proper’ Gizmos folder.
     
unityunity