Unity Info Dump
01 Feb 26 (4mo ago)
Just a place to dump info before I categorize them.
- Unity Compiling/Reloading Domain/Scene Takes a Ridicilous amount of time. Okay, this can actually be lessed by disabling it in the settings. Under
Project Settings>Editor - Better to use the sorting layer in the tile map later rather than adjusting per position
- using gridblockers with the help of the layer but not the sorting layer
- Cannot use fonts directly. Like drag it. Need to Create > TextMeshPro > Font Asset > SDF.
- Not imported. Need to use FindObject byType. Otherwise use singleton again in unity. haha. So easy to refer.
- for some reason the spritses are automatically cut in unity (how?)
- Ha! You can drop in the default ProBuilder shapes by using
Shift+LMB. I can finally create a perfect sphere immediately. - rigibody 2d freeze rotation to prevent the infinite spinning.
- Shift+Spacebar to Fullscreen a Panel
- Reduce Gizmo Icons.
- Time.deltaTime is always in input controllers unless using rigidbody which relies on linear velocity
- Need to hit record for the animator timeline to work.
- You can double click the timeline(after stopping the record) and you go to the animator view. And this is actually the timeline I am familiar of with other DCC
- File>Build Profile. Needed for the switch scene.
- 2d stuff
- window>2d>tilepallete
- game object>tile map >rectangular rather than manually adding component.
- for 2D sprite: in the animation tab. you can just drag the sprite immediate. no need for the property. unless you want to animate the propetery itself.
- point (no filter): filter mode diay for sprites.
- animation panel sample rate. samples. usually hidden by default in newer version
- some packages that can be remove: timelines, visual scripting, multiplayer scripting, jetbains rider editor, test framework
- using System.Collections.Generic; to use the List
- cinemachine. cinemachine follow. cinemachine hard look at
- OnTriggerEnter2D. on CollissionEnter
- Rule of Thumb:
- Use
Update: For user input (keystrokes), simple timers, and non-physics movement (changing transform.position directly). - Use
FixedUpdate: For anything involving a Rigidbody (velocity, forces, gravity).
- Use
- getMouseButton(0). equivalent to LMB and Mouse.
- greyboxing. prototype ProBuilder
- unity tagsystem
- unity animation event for mecanim system where you can trigger a script based on the time within the animation.
- Need the Animator Window to have the player move condition: Its not in the code: the just handle the variable to be set in the condition in the animator
- Need to click the arrow to show the connection:
- Unity do not have a built-in UV editor but it has UV viewer (which is okay for me for checking problem).
- Unity Prefab is something like a Packed Primitives in Houdini where it is optimized to be instanstiated many times
- And super easy to create where you drag the FBX model project window to Viewport Hierarchy. Then from Viewport Hierarchy drag back to Project Window
- But can do more since you can add script to prefab and each instanstiated prefab can have its own unique parameters from the script.
- the light cant be save on playmode like the noml game obejcts unlike hthe overide in the globalvolume
- you can memorize the files. or just copy/paste in game mode to the scene/offline mode.
- Particle. Cast Shadow. Needed. Play on Awake Disable.
- properties are like in between of a field and a method.
- if its RPA or rendering asset you can modify it and it won't actually reset.
- GPU Instancing. On the Material. By default is it off. Prefab Grass
- scriptable object are like prefabs but for scripts/data. (prefabs is for objects)
- Create>Prefab Variant. Soooo good!
- For Prefab. Have an empty object a parent so you can freely update your other object
Scriptable Objects
That is a great way to visualize it! If a **Prefab** is a "template for a GameObject," a **ScriptableObject** is a **"template for data."**
However, there is one major distinction to keep in mind to avoid confusion:
### The Key Distinction
- **Prefabs are "Blueprints":** When you drag a Prefab into a scene, you create a **clone** (instance). Each clone can have its own position and unique state.
- **ScriptableObjects are "Shared Sources":** When you reference a ScriptableObject in a script, you aren't making a clone. Everyone is looking at the **exact same file**.
---
### A Real-World Comparison
Imagine you are making an RPG:
- **The Prefab** is the physical "Sword" model. You can have 10 swords on the ground; each has its own position in the world.
- **The ScriptableObject** is the "Sharpness Data." If you decide that "Iron Swords" should do **15 damage** instead of **10**, you change it once in the ScriptableObject file. Every single sword in the game—past, present, and future—now does 15 damage instantly.
---
### Why this is better than "Scripts only"
If you tried to do this with just scripts (MonoBehaviours), you would have to:
1. Open your Sword Prefab.
2. Change the "Damage" variable on the script.
3. Apply the override to all instances.
With a **ScriptableObject**, you don't even have to open the Prefab. You just click the data file in your Project folder, change the number, and you're done.
### When should you use which?
| Use a **Prefab** when... | Use a **ScriptableObject** when... |
| :---------------------------------------------------------------- | :----------------------------------------------------- |
| You need something to appear in the **Scene** (Visuals, Physics). | You need to store **Settings** or **Stats**. |
| The object has a **Position** or **Rotation**. | The data is **Shared** across many objects. |
| You want to spawn something (like a bullet). | You want to create a **Database** (like an Item Shop). |
You are exactly right. A **ScriptableObject** is essentially a way to create your own **custom Unity asset** that stores data.
Think of it as a "Data Container." While a regular script (MonoBehaviour) has to be attached to a GameObject in your scene to exist, a ScriptableObject lives in your **Project Folder** as a physical `.asset` file, just like a Texture, Material, or Audio Clip.
### Why use them?
The biggest advantage is **memory efficiency**. If you have 1,000 enemies and each has a MonoBehaviour script containing their "Base Stats" (Health, Speed, Strength), Unity creates 1,000 copies of that data.
If you use a **ScriptableObject**, all 1,000 enemies simply point to **one single asset file** in your project.
---
### How to create one
It’s a two-step process:
**1. Define the Data (The Script)**
Instead of inheriting from `MonoBehaviour`, you inherit from `ScriptableObject`.
```csharp
using UnityEngine;
[CreateAssetMenu(fileName = "NewEnemyData", menuName = "GameData/Enemy")]
public class EnemyData : ScriptableObject
{
public string enemyName;
public int maxHealth;
public float moveSpeed;
}
```
2. Create the Asset (The File)
Because of the [CreateAssetMenu] line, you can now right-click in your Project Window and go to Create > GameData > Enemy. This creates a physical file you can name "OrcData" or "SlimeData" and fill in the values in the Inspector.
Key Characteristics
- Lives Outside the Scene: It doesn't get destroyed when you change scenes.
- Persistent during Editor Sessions: If you change a value in a ScriptableObject while the game is running in the Unity Editor, that change stays even after you stop the game. (Note: This does not happen in a final built game).
- Perfect for Global Settings: Great for holding game configurations, item databases, or dialogue trees.
Comparison at a glance
| Feature | MonoBehaviour | ScriptableObject |
|---|---|---|
| Needs a GameObject? | Yes | No |
| Saved as a File? | No (saved in scene/prefab) | Yes (.asset file) |
| Best For... | Behavior and logic in the scene. | Shared data and configurations. |
| Memory | Multiple copies per instance. | One shared instance. |
Are you planning to use these for your "Beat Tamer" project or perhaps for your website's database of small open-world games?
## cinemachine
- cinemachine impulse listener and impulse source
## Shading
- There is no mix node in the shader graph. Use LERP instead.
- Video Brackeys. Grass Sway in Unity.
- Fur Texturing: https://www.youtube.com/watch?v=mZELRHOnxI8
- Same with that terrain texturing so if muddy ang ground, muddy pud ang texture
- Triplanar https://www.youtube.com/shorts/3CacZ5KJfhs
- In Unity’s URP Shader Graph, the logic is additive rather than a "mix."
- For 2D pixelated texture:
- The reason this tricks work for the curious among you is because of Bilinear interpolation when upsampling the image, which still perfectly preserves the linear gradient textures.
- Detail patch. 32 x 32 innn foliaage in coverage mode.
- dragging the shader graph to material? haha. so its not a separate material?
## VFX
- Okay. Cloth in Unity is to be deprecated (Announced in 2024), since its mostly single threaded. There is a paid plugin that is pretty much the standard now, Magica Cloth 2
- Jiggle Physics
- vertex deformation or jiggle physics using bone:
- https://www.youtube.com/watch?v=KabFTkm_TxI
- https://www.youtube.com/watch?v=Kwh4TkQqqf8
- https://www.youtube.com/watch?v=LHtGs66lui8
## Hair
- https://www.youtube.com/watch?v=CrQXqu4wQTM
## Shortcuts
- Ctrl+P Play
- Shift+Space to Fullscreen A Panel
## Demo
- https://psychokd152.itch.io/merge-cuisine
- https://kaylousberg.itch.io/kaykit-forest
## Game Jams
- Ludum Dare
## Visual studio
- Hold Alt to move keys
- Contrl +D to duplicate line in visual studio
## Dev Log
- 20260305. Okay. Haha. I thought setting up a third person controller is a done deal but it's somewhat complicated than I thought
- For example, I had a character that jumps as he walks. so its not a separate action. I have a front and when he walks and run, he also jump!
- I checked some Unity project and it seems like I have separate the root motion of jumpign with the animation. This is so when I jump, the collider jump, and the jump animation too.
- Currently, jump/run animation triggered but the collider is still on the ground lol
- Also there is another feature control not only for the character but the camera following the character.
- Okay you can just use the Standard Assets Character Controllers. Replace the Mesh and the Avatar config. Works. For standard characters. I have redone it but as to recreating the animation based on the characters own animation. STill lost.
General
perline noise is from tron? haha
- https://chicounity3d.wordpress.com/2014/05/23/how-to-lerp-like-a-pro/
- 3 render pipelines in unity. pink materials
built in hdrb (PC and console) and urp ( nintendo)
===
FindFirstObjectByType<UIController>().SwitchTool((int)currentTool); a bit inefficient. Use the Controller.
"[System.Serializable]"
UI > Canvas. Probably the rarest thing that doesn't need game object
in unity when drag an empty object to a slot in a script where it requires a specific class. it gets the class immediately. noooice
unity does not natively work with gltf files?
Script sample:
editor scripts? nice: using UnityEngine;
using System.Collections;
using UnityEditor;
[CustomEditor(typeof(RandomMapTester))]
public class RandomMapTesterEditor : Editor {
public override void OnInspectorGUI(){
DrawDefaultInspector ();
var script = (RandomMapTester)target;
if (GUILayout.Button ("Generate Island")) {
if (Application.isPlaying) {
script.MakeMap ();
}
}
if (GUILayout.Button("Create Player"))
{
if (Application.isPlaying)
{
script.CreatePlayer();
}
}
}
}
===
In Godot, using a GameManager (specifically via a feature called Autoloads) is very common and is considered standard practice, but the "best" way to do it is slightly different from how you might do it in Unity.
Here is how Godot handles the "Universal Script" concept:
1. Autoloads (The "Official" Singletons)
In Godot, you don't have to write the code for a singleton pattern (the if (instance == null) stuff you have in your Unity scripts). Instead:
- You write a normal script (e.g.,
GameManager.gd). - You go to Project Settings > Autoload.
- You add that script to the list.
Godot will now automatically create that node when the game starts and keep it alive across every scene. It acts exactly like a Python import that is available everywhere.
2. Is it "Good Practice"?
Yes, but with a warning. Godot developers follow a rule: "Signals Up, Function Calls Down."
- Good use of GameManager: Storing global data (Player XP, Gold, current Day) and managing scene transitions.
- Bad use (The "God Object"): Putting all the logic for the player, the crops, and the UI into one giant
GameManager.gd.
3. Godot vs. Unity: The "Tree" vs. "Components"
The reason a GameManager is so popular in Godot is that Godot is Node-based:
- Unity: You have a "Player" object and you stick 5 scripts on it.
- Godot: You have a "Player" Scene, which is a tree of nodes (a Sprite node, a Physics node, a Sound node).
Because Godot projects are "Trees of Trees," having a GameManager sitting at the very top (the root) of the entire game tree makes it very easy to coordinate everything.
The "Godot Way" vs. Your Unity Project
If you were to port your farming game to Godot:
- GridInfo, TimeController, and CropController would definitely be Autoloads. They are "Data Services."
- PlayerController and GrowBlock would remain as scripts attached to their specific nodes (local logic).
- You would use Signals (Godot’s version of events) to tell the UI to update.
Summary:
In Godot, the GameManager pattern is more encouraged and cleaner to implement than in Unity because the engine handles the "Singleton" setup for you. However, you still want to keep your logic separated so your GameManager doesn't become a 5,000-line nightmare!