Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

SOLVED: Visual Studio: What's going on with this weird auto-filling behavior?

Discussion in 'Scripting' started by asperatology, Jan 23, 2017.

  1. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    Here's what's going on when I typed in a function:


    The moment I type in the left parenthesis '(', the VS Editor will automatically fill them up, while also adding an extra pair of parentheses at the very end.

    I never had this issue if I'm coding in a typical Windows Console Application in Visual C#.

    It's annoying. What's going on?
     
  2. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    Are you typing inside a function?
     
  3. Pengocat

    Pengocat

    Joined:
    Dec 7, 2016
    Posts:
    140
    IntelliSense is simply trying to help you type faster and avoid spelling mistakes. There is no need to type in things literally when using VS.
    p TAB SPACE v TAB SPACE f TAB
    That is all you need to make a private Fixed Update.method (no need to make it public is there?), and it even moves the text-cursor into the method ready to fill it in.
    It works as intended and completes the method because there is only one thing in the list. You could disable IntelliSense but then you are one step closer to use a simple text editor I guess. Another option is to press CTRL+Z whenever IntelliSense made something you didn't want.

    Edit: like others have mentioned since this is part of a Unity plugin you should also be able to press the right mouse button and select "Quick Unity Messages" I belive the shortcut is CTRL+SHIFT+Q or M and search for the Monobehavior method you need.
     
    Last edited: Jan 23, 2017
  4. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    Sometimes auto complete goes nuts. Check to make sure there are no errors in the script. Restart visual studio. See what happens.

    Note that you shouldn't get a suggestion for FixedUpdate. Which means you've got something weird going on. Do you have a Unity specific extension installed?
     
  5. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    Not exactly. It's only after I finish typing the full method name of the derived MonoBehaviour virtual methods, then pressing the left parenthesis, do the weird behavior starts happening.


    I understand that by pressing the TAB key, it will autocomplete, as shown above when doing it the fourth time. However, the problem is focused on situations where you completely typed out the full method name, then hit the left parenthesis, the left bracket, the semi-colon, and other symbols that trigger IntelliSense.

    That's the part where I'm confused as to what's going on.

    I'm not supposed to have that? I don't have any Unity specific extensions installed, other than the VSTU.
     
  6. cranky

    cranky

    Joined:
    Jun 11, 2014
    Posts:
    180
    I'm getting this too. It's related to Unity Tools, as ONLY Unity message functions do this.

    Also, if I go to insert a function above another, it will insert curly braces a way below the actual function I just typed....

    Very strange.
     
  7. Polymorphik

    Polymorphik

    Joined:
    Jul 25, 2014
    Posts:
    599
    What version of VS are you using? I am using 2013 community version with 5.5 or 5.4 and I dont get these issue .
     
  8. cranky

    cranky

    Joined:
    Jun 11, 2014
    Posts:
    180
  9. Brathnann

    Brathnann

    Joined:
    Aug 12, 2014
    Posts:
    7,146
    This is not an error. When you try to use standard mono methods, it tries to fill them in for you. Stuff like awake, start, update, ontriggerenter, etc. I noticed this in 2017.

    I can type void Awake and then hit enter and it will add private, add () and add {} for me for example. It took a little getting use to, but since it's only on the mono ones and not my own methods, it just didn't bother me any.

    There is probably a setting somewhere to turn it off if it bugs you.

    Note also that 2017 of VS actually lets you install only what you need for Unity if you want. It does have autocomplete stuff for Unity built in. So it wouldn't surprise me if you got these updates in 2015.
     
  10. HelloMeow

    HelloMeow

    Joined:
    May 11, 2014
    Posts:
    279
    Yes. It's called Unity Messages code completion and it's under the Tools for Unity options.
     
  11. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,184
    Bugs me too, because the auto-complete for the Unity Messages behaves differently than for all other methods. I can't test it right now, but I remember turning it off, because I constantly ended up with additional parenthesis. I'll do a test later and if it really works differently, I'd report it as a bug. In general it's a cool feature.
     
  12. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,199
    That's a bug.

    I'm note sure if Unity takes VSTU bugs, but it's worth a shot. File a bug report with [VSTU] in the subject line.

    There's someone from the VSTU team that comes by the forums regularly, but I can't remember their name.
     
    Kiwasi likes this.
  13. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981
    I'm reporting the bug too.

    People seemed to use the review posts for bug reports on the UserVoice. Going to try that out.
     
  14. asperatology

    asperatology

    Joined:
    Mar 10, 2015
    Posts:
    981


    Confirmed it's a bug. Problem solved!
     
  15. sotirosn

    sotirosn

    Joined:
    Jan 5, 2013
    Posts:
    24
    Yes the auto complete is triggered when you type the parentheses, (), for the parameter list, which in my opinion is a mistake. It really should only auto complete if you press tab because for all it knows you could be typing a brand new method. For example if you create a new component type and want to add lets say 20 new methods to it, you have to deal with fixing this auto complete 20 times. So the best thing to do is disable it completely via Tools > Options > Tools For Unity > Unity Messages code completion = False. It still has syntax highlighting so you can see if your method name matches a Unity Message, but stops the editor from constantly code completing unnecessarily.
     
  16. luislodosm

    luislodosm

    Joined:
    Apr 26, 2016
    Posts:
    26
    Where is "Tools for Unity" in Mac?