Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

suggestions by devin #6

Open
KoleckOLP opened this issue May 23, 2022 · 0 comments
Open

suggestions by devin #6

KoleckOLP opened this issue May 23, 2022 · 0 comments

Comments

@KoleckOLP
Copy link
Owner

https://github.com/KoleckOLP/RPScore/blob/master/Assets/MainScript.cs

some tips:

  1. If you want an editor exposed variable but slightly faster, use [SerializeField] private GameObject example;
  2. Consider using public const string over public string if it's going to be used every time your game is active
  3. (Preference) Use the new Input System over the old one, as it offers better performance by skipping Update loops
  4. Avoid adding strings together like $"{stg}_5_win.mp4" as it generates memory garbage, instead import ZString and use ZString.Concat(stg, "_5_win.mp4")
  5. (New C#) You can replace stg != 5 with stg is not 5, stg == 5 with stg is 5 and same with strings etc. Note that this only works with constant values, so no dynamic ones
  6. Create a new System.Random instance as a global variable, rather than a method one. private readonly Random rand = new();
  7. Avoid using boxing like (int) as it is often extremely expensive to do and can generate memory garbage
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant