Author Topic: Disabling look focus un-highlight handling?  (Read 141 times)

Philipp

  • Newbie
  • *
  • Posts: 8
    • View Profile
Disabling look focus un-highlight handling?
« on: June 04, 2019, 12:00:06 PM »
I've implemented my own tap-to-highlight-country functionality in VR, which works fine. However, when I look away from the country (my own functionality doesn't need looking direction), the country becomes un-highlighted again. How can I disable all looking-direction logic and associated un-highlighting?

I've already outcommented the CheckUserInteractionNormalMode() call, as well as disabled "Enabled Country Highlighting" in the inspector for my prefab, but the issue prevails. Thanks!

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4662
    • View Profile
Re: Disabling look focus un-highlight handling?
« Reply #1 on: June 04, 2019, 12:05:58 PM »
Hi,

Possibly it's easier to completely disable country highlighting so you can color / uncolor countries on demand using code. Example:

Code
// color in blue
map.ToggleCountrySurface(countryIndex, true, Color.blue);

// remove color
map.ToggleCountrySurface(countryIndex, false, Color.blue);

Does this help?



Philipp

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Disabling look focus un-highlight handling?
« Reply #2 on: June 05, 2019, 01:58:15 AM »
Thanks, but how do I disable it? As mentioned, I already unticked the "Enable Country Highlighting" box, yet the issue prevails. At times the country stays highlighted (after my initial custom map.HighlightCountryRegion() call), at other times, it becomes un-highlighted after a while/ when I look away.

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4662
    • View Profile
Re: Disabling look focus un-highlight handling?
« Reply #3 on: June 05, 2019, 05:35:28 AM »
Once you have "Enable Country Highlighting" disabled, don't call map.HighlightCountryRegion. Use map.ToggleCountrySurface instead.

Philipp

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Disabling look focus un-highlight handling?
« Reply #4 on: June 05, 2019, 06:52:28 AM »
Gotcha, thanks, that works!

Hmm, now it looks like my Alpha value is ignored, and it renders the passed highlight color at 1f (255) alpha, even when it should be a lower, half-transparent alpha? Anything I can do about this?

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4662
    • View Profile
Re: Disabling look focus un-highlight handling?
« Reply #5 on: June 05, 2019, 08:06:10 AM »
Globe Lite edition is simpler than the full version and the shader used only supports opaque colors.
However you can improve that editing the UnlitSurfacesColor.shader file and adding:

Code
    	Blend SrcAlpha OneMinusSrcAlpha

Just inside the Pass { ... } block, like this:

Code
...
    ZWrite Off
    Pass {
    Blend SrcAlpha OneMinusSrcAlpha
    SetTexture [_MainTex] {
            Combine Texture * Primary, Texture * Primary
        }
    }

Philipp

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Disabling look focus un-highlight handling?
« Reply #6 on: June 06, 2019, 12:45:04 AM »
Thank you. Strange, now when I try, no matter which color/ alpha I provide, it always only shows the vaguest, faintest color -- ignoring my alpha and hue. (Note I've tried with "(1,1,1,1)" as well as "(1,1,1)" in the shader code.)

Is there something wrong with my shader code?

Code
Shader "World Political Map/Unlit Surface Single Color" {
 
Properties {
    _Color ("Color", Color) = (1,1,1,1)
}
 
SubShader {
    Color [_Color]
        Tags {
        "Queue"="Geometry+1"
        "RenderType"="Opaque"
    }
    Pass {
   
        ZWrite Off

        Blend SrcAlpha OneMinusSrcAlpha
        SetTexture [_MainTex] {
            Combine Texture * Primary, Texture * Primary
        }

    }
}
 
}

My C# call:

Code
Color highlightColor = new Color32(131, 235, 255, 178);
map.ToggleCountrySurface(currentCountry, false, highlightColor);

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4662
    • View Profile
Re: Disabling look focus un-highlight handling?
« Reply #7 on: June 06, 2019, 01:56:16 AM »
The shader looks correct. Two things to note:

1) Your call:
ToggleCountrySurface(currentCountry, false, highlightColor);
is passing "false" as second argument which means "uncolor" or "invisible". Try passing "true" to color the country instead.

2) The (1,1,1,1) color value in the shader code is a default value in case no _Color property is assigned to the material. It doesn't matter which color value you set in the properties section of the shader as the asset always pass your color to the material.

Philipp

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Disabling look focus un-highlight handling?
« Reply #8 on: June 06, 2019, 02:31:36 AM »
Sorry, I do call "true" when doing the highlight, the "false" I only pass to disable it for the old country. I had pasted the wrong part of my code. Here's the code:

Code
Color highlightColor = new Color32(131, 235, 255, 178);

if (currentCountry != -1)
{
    map.ToggleCountrySurface(currentCountry, false, highlightColor);
}

currentCountry = countryIndex;
map.ToggleCountrySurface(currentCountry, true, highlightColor);

Help please, why isn't it working? Thanks!

Kronnect

  • Administrator
  • Hero Member
  • *****
  • Posts: 4662
    • View Profile
Re: Disabling look focus un-highlight handling?
« Reply #9 on: June 06, 2019, 02:45:30 AM »
I'll need a repro to check it. Can you please zip your project and send it to me by email to "contact (at) kronnect (dot) me"? Thank you.

Philipp

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Disabling look focus un-highlight handling?
« Reply #10 on: June 06, 2019, 04:31:24 AM »
Thanks. It's a very big project I'm working on, so I'll see if I can set up a more minimal sample project (or further drill down into the shader/ highlight handling myself now).