Forum rules - please read before posting.

Highlight script is not working on 2D sprites

Hi all,

Can you help with the following issue?

The Highlight script is not working on 2D objects (sprites) in a 3D game.

Screenshot:
image
I experience the above issue under the following version under 64bit Windows 10:
  • Unity 5.6.0b5 with Adventure Creator v1.55c
Thank you for all of your assistance in advance!

Feel free to let me know if you need any further info, screenshot and or video about the mentioned issue I experience!

Comments

  • Sprites must be given the Sprites Diffuse material in order to work with the Highlight script.  The sprite in the screenshot is given the Sprites Default material.
  • In the 2D Demo Sprites Default material is used and the highlight script works there. My sprite becomes dark if I set it to the Sprites Diffuse material.
  • edited February 2017
    Apologies - I wasn't aware it works with Sprites Default.  That may be a new feature of Unity, as I'm sure that wasn't previously the case.

    Perhaps it's to do with the way your scene is lit, or some quirk of Unity that I'm not aware of.  The Highlight script merely increases the brightness of the material's "_Color" property - the official Unity forums may be a more appropriate place to ask this question.

    Are you certain you need to be using a sprite for this object?  A quad with this graphic set to it's Material texture would have a similar appearance.
  • edited February 2017
    No problem!

    Yes, I am. I have tried that too. Actually I currently have one sprite which is using a quad mesh and a mesh renderer and not a sprite renderer. Also the default shader settings doesn't work, because the image is not shown.
  • When using a Quad, have you tried using the Standard shader or Legacy Unlit one?  I'm not sure using a sprite shader won't work on a 3D mesh.
  • Now I have tried the Unlit/Transparent shader on a Quad. (Sprites/Default works as well) It looks perfect, but highlighting still doesn't work at all.
  • Apologies again - that was bad advice.  An unlit shader has no "_Color" property - it's just a Texture - so its brightness cannot be changed.

    Try using the Standard shader but with an Emission value - that should make it work with the Highlight script but also make it brighter than other materials.

    If need be, a custom script can be written to affect your chosen material.  The Highlight script, as I said, will brighten a Material's "_Color" property - so if it doesn't exist, the script won't have any effect.  The intended brightness, as set by the Highlight script, can be read, however - meaning you can use it however you want - whether it be to change a material's colour, transparency, or whatever.
  • No problem!

    It doesn't work. The image is not displayed properly with the Standard shader.

    I think it should be working without any custom script as it is working in a 2D game.
  • edited February 2017
    "Not displayed properly" in what way?  You'll probaby need to change the Texture's import type in the Inspector to Texture, rather than Sprite, in order for it to work with Standard Shader.

    I agree that it should be working without need for a custom script, but again, this is an issue with the way your scene is lit, or some setting due to Unity - not an AC one.  AC is working correctly, which you've seen for yourself in the 2D demo, and it also works on sprites in the 3D Demo.

    That this is not 3D does not prevent the Highlight script from working - instead, it is due to some unidentified setting in your scene.  It may be a lighting setting, a "static" option on your object, or some rendering / quality setting.
  • The Quad is totally black, even with Texture Type set to Default.
  • Set it up in a new, empty scene just for testing this one thing.  Leave the Highlight script out of it until you're happy with the way it looks on its own.  You can use the Emission value to make it brighter than the surrounding it should make it, but it being black is a Unity issue.
  • Well, now in one of the builds it started to working on a Quad with a Sprites/Default shader. However, I reverted the asset which somehow fixed the issue because GitHub Desktop showed that the asset is empty which usually occurs when the contents of the file aren't really changed (metadata change only). So I usually revert these kind of changes before I commit the real ones. So I think the Assets\AdventureCreator\Resources\References.asset fixed the issue somehow. Unfortunately I couldn't reproduce the "magic" fix. Actually, I worked on other parts of the game (Speech Manager, MenuManager and one of the Action List). Do you have any idea how to reproduce this? I think it got fixed during saving using the Ctrl+S command.
  • Reproduce what, exactly - the highlighting issue?  It was always working for me, I'm afraid.
  • No, the issue currently exists in my project. I mean reproduce the accidental fix that I have achieved somehow. I have described the situation above.
  • edited February 2017
    The asset that was being seen as empty being the References file?  That simply stores which Managers are assigned to your game, no data about the files themselves.  If changing that file changed anything, it would only have been which Managers were assigned - though this won't generally change over the course of your project, unless you e.g. assigned the Demo managers for testing purposes.

    You can try assigning the Demo managers again to see if that changes anything.

    I don't understand how you got a Quad working with the Sprites/Default shader, though.  There's no sprite slot on a Mesh Renderer, and the sprite shader itself doesn't come with a Texture field.  I'd need to see screenshots to see how that's achieved.
  • Yes, exactly. I know that.

    Here are the requested screenshots:
    image
  • edited February 2017
    It's a wierd trick, but it seems you can do that by assigning an Abedo Texture to Unity's Standard shader, and then changing the shader's type to Sprites Diffuse.

    Works for me in the 3D Demo game on a quad with the 2D Demo game's "Lunch" sprite.  Giving it the Highlight script and changing one of the Hotspots so that it highlights that instead has it brightening up.  See if the same thing works for you.
  • Yes, this is how my setup looks except I am using the Sprites Default shader because it displays the image better.

    Yes, it works for me too in the 3D Demo game (in a separate project used for testing purposes only) even with the Sprites Default shader. However, in my own project, it doesn't work currently. It started to working as I described before, but unfortunately, I reverted the change(s) that somehow fixed the issue in my project.
  • edited February 2017
    Your post about reverting the References asset suggested there was something related to your Managers.  Did you try my suggestion of assigning the 3D Demo's Managers in your own project to see if that makes a difference?

    You could also test the opposite, i.e. assigning your own Managers in the 3D Demo, and see if you can still highlight the mesh.

    I'm still inclined to believe this is a Unity issue, however.  Likely a lighting or graphics setting as I've been saying.  You should try comparing your Project / Quality / Graphics settings between the two projects, as well as the Lighting windows between the two scenes.  If it works in one project but not the other, it does suggest that there is a project or lighting setting causing this issue.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.