← Back to unity
Unity Info Dump
01 Feb 26 (3mo 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.