Search Unity

Displaying a function when it is called

Discussion in 'Scripting' started by deCalle, Mar 10, 2016.

  1. deCalle

    deCalle

    Joined:
    Feb 16, 2016
    Posts:
    2
    Hello there folks!

    I couldn't find this feature anywhere around, so i just toss it in.

    It would be quite nice, if there was code showing up when I call a function like

    Code (CSharp):
    1. int apples = 5;
    2. float appleJuice = MakeAppleJuice(apples);
    the code would expand as followed:

    Code (CSharp):
    1. int apples = 5;
    2. float appleJuice = MakeAppleJuice(apples) [public float (int amount)] {
    3.      return amount / 1.5f;
    4. }
    in the meantime a/the corresponding function within the class is created/altered.

    Actually It would be great if there was a dropdown icon that opens the call like a container to show the function so i don't have to rush from one function to another and get confused on the way, which I already am with the stuff I'm doing...^^

    Well... either this is a great idea or I've just gotten too rusty on programming. Either way I do hope you have a wonderful time with whatever you're doing, contributing to an established cultural being together, at best.

    Sincerely,
    A wannabe landlord struck with poverty ;-)
     
    Last edited: Mar 10, 2016
  2. Darholm

    Darholm

    Joined:
    Mar 1, 2016
    Posts:
    63
    Hello,
    Why do you want to display the content of a function each time you call it?
    If your goal is to know what the function does, just add correct comments on it, for example :

    Code (CSharp):
    1. /// <summary>
    2. /// This function does some stuff.
    3. /// </summary>
    4. /// <param name="root">My first param.</param>
    5. /// <param name="child">A second param</param>
    6. public void DoStuff(int root, int child){}
    Then, each time you will type the name of the function, Intellisense will display the comments.
     
  3. mathiasj

    mathiasj

    Joined:
    Nov 3, 2015
    Posts:
    64
    I think in Visual Studio there is a "preview function" thing which does something similar to what you ask. I don't know how it's called exactly though but if you right click your function you should find it.
     
    lordofduct likes this.
  4. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,539
    Peek Definition

    @OP - if you use Visual Studio (Community edition is free), and you highlight the method call, you can right click and select 'Peek Definition' to get exactly what you want.

    You can also hit Alt+F12 as a keyboard shortcut

    There's other options in there like 'goto definition', find references and more.

    MonoDevelop also has various features, I'm not sure if MonoDevelop has a 'Peek Definition' equivalent though... I don't really like MonoDevelop so I don't use it much.
     
    aer0ace likes this.