Search Unity

How to start renaming inspector gameobject by code

Discussion in 'Editor & General Support' started by FeastSC2, Jan 5, 2020.

  1. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    I woud like to call in code the "Start Renaming" function on a gameobject in the inspector (the exact same behaviour as when you press F2 in Windows on a gameobject).

    https://i.imgur.com/icm04L6.gifv

    How can I do that in code?
     
  2. Deleted User

    Deleted User

    Guest

    Example:
    Code (CSharp):
    1.     private GameObject player;
    2.  
    3.     private void Start()
    4.     {
    5.           player = GameObject.FindGameObjectWithTag("Player");
    6.           player.gameObject.name = "NewName";
    7.     }
    Result in game:

    Capture.JPG
     
  3. FeastSC2

    FeastSC2

    Joined:
    Sep 30, 2016
    Posts:
    978
    I mean specifically the START renaming process, I want to type in the inspector what the name will be. I don't know the name in code yet.