Search Unity

how to initialize a function

Discussion in 'Scripting' started by VeTK85, Dec 24, 2019.

  1. VeTK85

    VeTK85

    Joined:
    Jun 26, 2016
    Posts:
    41
    How do you start a void that contains parameters inside?
    Code (CSharp):
    1.     void Start()
    2.     {
    3.     myvoid();//this does not work, only with void without parameter
    4.     }
    5.     void myvoid(int parameter)
    6.     {
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    5,023
    What exactly is your question?

    If you don't want
    myvoid
    to accept a parameter, remove the parameter from its declaration.

    If you want it to accept a default argument, specify the default value in the function declaration.

    Otherwise, give it a parameter when you call it.
     
  3. AlexN2805

    AlexN2805

    Joined:
    Nov 27, 2019
    Posts:
    33
    Code (CSharp):
    1. void Start()
    2. {
    3.    myVoid(3);
    4. }
     
unityunity