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

how to initialize a function

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

  1. VeTK85

    VeTK85

    Joined:
    Jun 26, 2016
    Posts:
    54
    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:
    36,970
    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. }