Search Unity

Is it possible to import UI source code into project?

Discussion in 'UGUI & TextMesh Pro' started by User340, May 18, 2019.

  1. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    I'm currently working on a project and relying on the built-in UI system. Is there a way to transition my project and import the source code of Unity UI and use that instead? I often find it frustrating not having access to the source code, it would be so nice if I could modify the Button script, for instance.

    I know that the recommended way of doing this is to download and compile the Unity UI source code and place the DLLs in the Unity installation directory, but that will effect all projects. I would like to do it only to one project.
     
  2. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    I've figured it out! If anyone needs help with this just post here and let me know.
     
  3. Chezzman

    Chezzman

    Joined:
    Oct 19, 2019
    Posts:
    1
    I need help. Where did you find out?
     
  4. Antistone

    Antistone

    Joined:
    Feb 22, 2014
    Posts:
    2,836
    I'm not sure what HonorableDaniel did, but you should consider the option of subclassing the Unity UI classes rather than modifying them. This requires no special configuration--just define your own subclass, add whatever functionality you need, and attach your class (instead of the standard one) to objects in your scene.
     
  5. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    You have to place all of the classes into custom namespaces. Like this:
    1) Replace all namespace UnityEngine.UI with namespace MyCompany.UI
    2) Replace all using UnityEngine.UI with using MyCompany.UI

    Once this is done, copy/paste all of the scripts into your Assets folder. It takes some effort but it does work. Using a powerful IDE such as Visual Studio will help.

    Also, you can always do Antistone's suggestion, it's quicker and easier but slightly more limited.