Search Unity

Highlighter Examples

Discussion in 'Documentation' started by jdean300, Feb 7, 2017.

  1. jdean300

    jdean300

    Joined:
    Feb 17, 2014
    Posts:
    3
    I recently came across the Highlighter API. It seemed like the golden solution to something I wanted to do in a custom editor. However, after banging my head against it for quite some time, I am fairly certain that the documentation is either lacking in explanation or just downright incorrect.

    Specifically I am talking about the Highlight method. Walking through the examples shown:


    1)
    Code (CSharp):
    1. Highlighter.Highlight ("Inspector", "Scale");
    This example seems to work fine. Using Highlighter.Highlight ("Transform", "Scale");, which seems like it should work based on the next example fails silently however.


    2)
    Code (CSharp):
    1. Highlighter.Highlight ("Inspector", "m_LocalScale.x");
    2. Highlighter.Highlight ("MyBehaviour", "myFloat");
    This example has a few problems.
    First off, the text above the example speaks about using SerializedProperty.propertyPath to find controls, and yet the following example code is completely unrelated. Trying to use propertyPath logs a statement saying control could not be found and no amount of fiddling was able to make propertyPath work.
    Additionally, using the behaviour name does not seem to work as shown here. For a script called MyBehaviour it would not work unless I used "My Behaviour (Script)" - the text actually shown in the inspector. I understand the Highlighter API is searching by the actual GUI content (also not perfectly explained in the docs), so this isn't super surprising, but the example seems incorrect and will log errors saying the window "MyBehaviour" could not be found. On another note, having to parse the script name and split by camel case is simply annoying and unfriendly to use. But this is mainly a gripe about documentation so I will ignore that ;)
    Now, even when it could find the 'window' using "My Behaviour (Script)", it was never able to find the given property, no matter how I enter the property's name (name in code, name in inspector, split by came case, etc.).
    Copying the convention from the first example, calling Highlighter.Highlight("Inspector", "myFloat") should work, but it also seems to fail (regardless of myFloat is parsed - camel case split, etc.).


    3)
    Code (CSharp):
    1. Highlighter.Highlight ("Inspector", "Add Component");
    2. Highlighter.Highlight ("Hierarchy", "Create");
    This seems to be fine.


    The other minor point I'll bring up is regarding the windowTitle parameter. The examples seem to suggest this is not strictly a window title and that it may be the name of a script. This does not match with the parameters description/name. Either the examples are wrong, or the description isn't ideal


    Now perhaps these problems are all caused by me - using them at the wrong time, wrong parameters, etc. But after about two hours of trying to get it to work right I am fairly certain that the code is either bugged or the documentation is severely lacking.
     
    Xarbrough likes this.
  2. Graham-Dunnett

    Graham-Dunnett

    Administrator

    Joined:
    Jun 2, 2009
    Posts:
    4,287
    I agree that the second example is 100% unrelated to the "Any control that uses the..." line above. I'll get submit a bug for the doc team to know about this.
     
  3. androshchuk-vladyslav

    androshchuk-vladyslav

    Joined:
    Dec 13, 2015
    Posts:
    127
    It is a nice feature but it doesn't work at all ((
     
  4. col000r

    col000r

    Joined:
    Mar 27, 2008
    Posts:
    699
    Yeah, I can't make it highlight any of the fields on my components in the inspector either. Has anyone managed to do this?