Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Contribution Debug System

Discussion in 'Open Projects' started by Harsh-NJ, Aug 5, 2021.

  1. Harsh-NJ

    Harsh-NJ

    Joined:
    May 1, 2020
    Posts:
    315
    Hey there all, I am back with a new system, The Debug System.
    Suppose you are in the Beach, and want to go to the Forest and with all the things with you have with you, which is not persistent inbetween plays. The first way is to just unplay, open the forest and play again (if you don't want to persist thing with you). The second way is to walk all along to the forest.

    Both ways are somewhat time wasting.

    So I programmed a new System called Debug System. It allows you to open up a DebugMenu, in which there is a list of all the locations (currently 10, I guess), and if you click on one, you will be quickly spawned to that location.
    Thanks.
     
  2. Harsh-NJ

    Harsh-NJ

    Joined:
    May 1, 2020
    Posts:
    315
    @cirocontinisio, Now I will explain the working behind it. If you press the backquote key (the key just below escape and just above tab), the script UIManager.cs listens on the input reader for that input. It then activates the DebugMenu Gameobject. (i just duplicates the settingsMenu prefab as an starting point).
    Then in the UIDebug script, I have a reference to DebugConfigSO, which is a SO containing list of all the locations and a bool to check if it is debug mode.
    UIDebug loops over the array of locations, and Instantiates a Prefab called Location Item. It is a button with textmeshpro setup. Then I add an OnClick listener to each button with an extra parameter, the index of the location. The I just raise an sceneLoadEvent with that LocationSO, showLoadingScreen false, fade true.

    And this works as expected.

    Now this will also work in the build, i.e, the released game, and we don't want that. To tackle this, I set the isDebugMode bool to true in the EditorColdStartup, if it is. And discard any input in the InputReader, if isDebugMode is false.

    Thanks.
     
  3. Harsh-NJ

    Harsh-NJ

    Joined:
    May 1, 2020
    Posts:
    315
    Now to prevent isDebugMode to be checked accidentally and ruin the builded game, I have used this.
    Screenshot_20210805-072729_Chrome.jpg

    Note that I have exposed the bool to inspector to just allow is to see it in play mode.
    Thanks
     
  4. Harsh-NJ

    Harsh-NJ

    Joined:
    May 1, 2020
    Posts:
    315
  5. Harsh-NJ

    Harsh-NJ

    Joined:
    May 1, 2020
    Posts:
    315
  6. Harsh-NJ

    Harsh-NJ

    Joined:
    May 1, 2020
    Posts:
    315
    Hey Ciro, no need to fix conflicts. I fixed all of them when I realized that I am able to do so on the Github's Web UI.
     
  7. Harsh-NJ

    Harsh-NJ

    Joined:
    May 1, 2020
    Posts:
    315
    Debug loading locations done. Now working on debug walk / run. Will push it as soon as it's done.
     
  8. Harsh-NJ

    Harsh-NJ

    Joined:
    May 1, 2020
    Posts:
    315
    Hey @cirocontinisio , consider evaluating and merging my pull request. Debug Walk/Run will be on next pull request due to being on a new branch.

    Thanks.