- Macro: nameof(functionName) returns a string, which is the same for just doing “functionName”, but it is safer.
- It is safer because we can change our function name in future. If we are using a normal string, it will compile and lose the ability to know that it needs to change. On the other hand, nameof() method will fail as the parameter is no longer valid.
- Often used specifiers:
- For member:
- [Header(“catagory”)]
- [Min(value)]
- [Max(value)]
- [Space]
- [SerializeField]
- [Tooltip(“tool tip”)]
- [HideInInspector]
- For class:
- [RequireComponent(typeof(class))]
- [System.Serializable]
- Make sure you have this if you want to have this class editable in Unity editor
- For function:
- [SettingsProvider]
- For member:
- To create a custom project setting, make a class from ScriptableObject with the target variable with [SerializeField]
- In your class, create a const string with the path of the asset for you setting
- Create functions to create/save setting
- Create another class from SettingsProvider, with a SerializedObject as member
- Override the OnGUI function and use EditorGUILayout.PropertyField and call FindProperty on your SerializedObject to make the property on the project setting UI, followed by ApplyModifiedPropertiesWithoutUndo
- EditorGUILayout.PropertyField(CustomSettings.FindProperty(“SettingName”));
- Create a function that returns your SettingsProvider and use [SettingsProvider] on the function
- When you have C++ DLL for unity project, Unity won’t be able to recover from critical errors like how it handles it in C#
- The crash log and dump will be stored at this location: C:\Users\<username>\AppData\Local\Temp\Unity\Editor\Crashes\
- In the situation where there are static data for the scene and you are loading scene asynchronously. The game might have issue as the static data will be polluted.
- The solution for this is create a buffer map, something like loading map to load between the 2 scenes. To make sure the new map will be loaded after the old map unloaded
- OnValidate is called when member got modified in editor, and when entering play/editor mode against default value. The latter might need to be avoid
- you can have a bool to mark if OnValidate is called or not
- use EditorApplication.isPlaying and EditorApplication.isPlayingOrWillChangePlaymode to prevent the logic being called during play mode
- LineRenderer can only do 1 line, but it can do a lot of nodes
- When want to render more than 1 line, you can use multiple game object with LineRenderer component or have the 1 LineRenderer component render a long line like embroidery
- When doing singleton, don’t do it in constructor (That is what you should do in C++, but not Unity)
- Do it in Awake function
Tag: technology
-
Unity notes
-
[May 2025]short note
- This might be something you learn sooner or later as you are coding…..even if your space complexity is the same, some methods are still better than the other ones and there is a reason why some method is preferred more than others
- For example, array is always going to be better then hash map. As hash map are likely built with a larger size array as a base to make sure they got space for all the potential inputs
- You can write all the code you want to integrate ChatGPT to your project, and it seems like free tier also has some capacity to use. However, it will not work until you put money in.
- I wonder if it used to be ok, then the pricing chanced without all the documents updated
- When making a project with LLM in mind, make sure you think about business model since every query costs
- Suck up! does a pretty good job about it
- It might be better to use LLM for something more lengthy and fancy, or rewrite lines into different flavor/personality
- By putting your definition of relationship between variables into code makes things faster as you skip the conversion of A->B (if applicable), but it also limits the possibility of extending the function. Pick whichever that fits the need.
- Edge AI looks pretty interesting, it should provide a better distribution of LLM model to games without needing to be always online
- It probably will be with embedded system first
- Before being part of the game, it is likely to go through a few generations
- Probably still need a few year done the line for it to be part of PC…but console might be able to have it in the next generation? If this happens, PC game and console game will separate til PC catches up, vise versa
- If it really is used in game, that means we can no longer have the same-same experience for everyone, but it should be fine as long as it is used for not-lore important elements, just like LLM.
- This might be something you learn sooner or later as you are coding…..even if your space complexity is the same, some methods are still better than the other ones and there is a reason why some method is preferred more than others