/FYP-MusicRhythmGame

Music Rhythm Game using Spectral Flux Analyzer

Primary LanguageC#


Project Setup: Install UnityHub and Unity (https://unity3d.com/get-unity/download)

Step 1: Install UnityHub

Step 2: Install Unity

  1. Open UnityHub and click "安裝". Then, click "新增"
  2. Choose Unity version 2019.2.5f1
  3. Choose to install "WebGL", "Documentation", "繁體中文"

Project Setup: How to use git with Unity

Step 1. Clone the project

  1. Open cmd

  2. The default directory should be C:\Users\"Your name"\

  3. You may clone the project in any directory. I suggest to clone in C:\Users\"Your name"\Documents. So, run "cd Documents". And you will be proceed to C:\Users\"Your name"\Documents

  4. Press the green "Clone or download " button above. The copy the project url in SSH mode or HTTPS mode. I use Clone with HTTPS since I don't have SSH keys in my github account. If you wish to use SSH, please reference to this article https://help.github.com/en/enterprise/2.15/user/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

  5. Back to the cmd, run "git clone https://github.com/johnnyn2/MusicRhythmGame.git "

  6. Run "cd MusicRhythmGame "

  7. Current directory should be "C:\Users\"Your name"\Documents\MusicRhythmGame". Run "git status " and it should state "Your branch is up to date with 'origin/master'". "git status" command would state what is the current branch you are in and whether there changes in the current branch made by you or not.


Step 2. Checkout a new branch

  1. You should be in master branch now. If you are not sure, run "git status" to check it. If you are not in master branch, run "git checkout master". If you are in master branch, run "git checkout -b dev_YOURNAME". E.g. I would run "git checkout -b dev_sam". I suggest to use "dev_YOURNAME" as branch name. It is more clear that can indicate the current branch belongs to whom. Command "git checkout -b" let you fork a new branch from the current branch you are currently locating at and then check out to that newly created branch.

  2. Run "git status". It should indicates that you are in "dev_YOURNAME".

  3. Run "git branch --set-upstream-to=origin/master BRANCHNAME". E.g. I would run "git branch --set-upstream-to=origin/master dev_sam". This command let the newly created branch keeps track of the changes in master branch. In future, if there is any change in master, simply run "git pull" would do the work.

  4. Then, run "git pull" to make sure the branch is up-to-date with master.

  5. Then, run "git push origin BRANCHNAME".E.g. I would run "git push origin dev_sam". After pushing the branch, you will see your branch under the master branch in this github repository webpage.


Step 3. Work on a branch

  1. Now, you are ready to work on the new branch. You can open the project folder by UnityHub. The location of the project should be "C:\Users\"Your name"\Documents\MusicRhythmGame\MusicRhythmGame". Once you have made any changes and want to commit and push those changes to the origin. You should first run "git status". It would shows all the changed files. Then, run "git add -A". This is to add the changes to stage. Then, run "git commit -m "YOUR_COMMIT_MESSAGE"". This is to add a commit message to the changes(tell what you have done in this commit). Then, run "git pull" to ensure your code piece is up-to-date with the code in master. Then, run "git push origin BRANCHNAME". E.g. I would run "git push origin dev_sam". Then, you should be able to see the changes in the github repository.

  2. Every important!!! Remember to pull code before push code. Otherwise, the branch may be fast-forwarded !!! And no longer be able to keep track of the upstream branch(master). In this case, you have to run another set of commands to fix the fast-forward problem.


Step 4. Create pull request when some feature is ready

  1. Create pull request in the repository webpage once you have completed some feature(s). Pull request would compare the changes between the base branch and compare branch. E.g. base: master, compare: dev_sam. Once the pull request is accepted. The changes in your branch would be merged to master branch.

Reamrks:

  1. For more git command, please visit https://github.com/joshnh/Git-Commands

How to set Visual Studio Code as prefered text editor in Unity?

  1. Open the project via Unity Hub
  2. Click "Edit" -> "Preferences..." -> "External Script Editer" -> "Visual Studio Code"
  3. Close the Window
  4. Click "Assets" -> "Open C# Project"
  5. VS Code should open your project

Visual Studio Code Intellisense and Recommended Extensions

  1. VS Code is the best editor for editing Unity scripts as it provides a lot of extensions that help us for development. Some recommended extensions are:
  • C#
  • Unity Code Snippets
  • Unity Tools
  1. In order to setup intellisense for coding Unity Scripts in VS Code, please download all the extension above.
  2. After downloading C# extension, it should prompt you to install .Net core sdk if you havn not installed it yet. Just install the latest .Net core sdk (https://dotnet.microsoft.com/download/dotnet-core) will do the work.
  3. Then, OmniSharp server will start for our project and it will fail in loading Assembly-CSharp.csproj file (in the "Ouput" section of VS Code terminal).
  4. Then, you need to install .Net Framework developer pack version 4.7.1 (https://dotnet.microsoft.com/download/dotnet-framework)
  5. OmniSharp server should be able to load Assembly-CSharp.csproj now. Open any .cs file and try whether there is intellisense or not. For example, type "gameO" and it should suggest you "gameObject" variable

Reference

  1. Algorithmic Beat Mapping in Unity: Preprocessed Audio Analysis (https://medium.com/giant-scam/algorithmic-beat-mapping-in-unity-preprocessed-audio-analysis-d41c339c135a)