12

Debug.Log(GetComponent<Greetings>().language = "English");

-> Hello there!

Comments
  • 3
    Hi there! Welcome to devRant :)
    (Also yes, Unity is love)
  • 3
    I hate to be that guy but surely this just outputs "English" :P
  • 0
    @Jamoyjamie
    /* Nah, I'm not sure. You could use a Property with a nice and shiny setter method! */

    private string hello = "";
    public string language { get (
    return hello;
    )
    set (
    switch (value) {
    case "English":
    hello = "Hello World";
    break;
    case default:
    hello = "No language selected";
    break;
    });
    }
  • 2
    @DrAddicted But in C# the value returned from the equals operator will be the value assigned, it's the same way the weird assigning while loop thingys work in C#, e.g.

    while ((i = i - 1) != 0) { }
Add Comment