Skip to content

Instantly share code, notes, and snippets.

@4mirul
Last active March 7, 2024 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 4mirul/70edeb5545b080a83e35c9267e699ca4 to your computer and use it in GitHub Desktop.
Save 4mirul/70edeb5545b080a83e35c9267e699ca4 to your computer and use it in GitHub Desktop.
UnityScriptTemplates

[WIP] Unity Script Templates

2D

Parallax Effect

ParallaxEffect.cs

Notes

  • use FixedUpdate()
  • movement right left, use Rigidbody2D

Directory Structure

Common Directory Structure

  • Assets
    • Animations
      • Player
        • player_idle.anim
        • player_walk.anim
        • ...
      • Enemies
        • enemy_idle.anim
        • enemy_attack.anim
        • ...
      • ...
    • AnimationControllers
      • PlayerController.controller
      • EnemyController.controller
      • ...
    • Art
      • Sprites
        • Player
          • player_idle.png
          • player_walk.png
          • ...
        • Enemies
          • enemy_idle.png
          • enemy_attack.png
          • ...
        • ...
      • Palettes
        • Level1Palette.png
        • Level2Palette.png
        • ...
      • Tilesets
        • Forest
          • tileset_forest.png
          • ...
        • Sand
          • tileset_sand.png
          • ...
        • ...
      • ...
    • Audio
      • Music
        • level1_music.mp3
        • level2_music.mp3
        • ...
      • SFX
        • jump_sfx.wav
        • shoot_sfx.wav
        • ...
      • ...
    • Prefabs
      • Player.prefab
      • Enemy.prefab
      • ...
    • Scenes
      • MainMenu.unity
      • Level1.unity
      • Level2.unity
      • ...
    • Scripts
      • PlayerController.cs
      • EnemyAI.cs
      • ...
    • ...

Sorting Layers

Common Sorting Layers

  1. Background: This layer typically contains background elements, such as scenery, sky, or other non-interactive elements that appear farthest in the background.

  2. Ground: The ground layer is often used for tiles or terrain that the player and other game objects interact with. It serves as the base layer for the game world.

  3. Obstacles: This layer is used for objects or obstacles that the player or other game objects need to navigate around, such as walls, rocks, or platforms.

  4. Characters: The characters layer is typically used for player characters, NPCs, enemies, or any other interactive characters in the game.

  5. Effects: This layer is used for visual effects, particles, or other special effects that are rendered on top of the game world.

  6. UI: The UI layer is reserved for user interface elements, such as menus, buttons, health bars, or any other on-screen UI components.1

Unity Shortcut Cheatsheet

Scene View Navigation

  • WASD or Middle Mouse Button: Pan the view
  • Scroll Wheel: Zoom in/out
  • Q or E: Rotate the view
  • F: Frame selected object(s)

Hierarchy View

  • Ctrl + D: Duplicate selected object(s)
  • Ctrl + Shift + D: Duplicate selected object(s) and all children
  • Ctrl + H: Hide selected object(s)
  • Delete: Delete selected object(s)

Inspector View

  • Ctrl + D: Duplicate selected component(s)

Game View

  • Alt + Shift + F: Maximize Game view
  • Ctrl + P: Pause/Play the game

Editor Navigation

  • Ctrl + 1: Game view
  • Ctrl + 2: Scene view
  • Ctrl + 3: Game view maximized
  • Ctrl + 9: Console view
  • Ctrl + 0: Collab view
  • Ctrl + Shift + N: Create new scene
  • Ctrl + O: Open scene
  • Ctrl + S: Save scene
  • Ctrl + Shift + S: Save scene as

Play Mode Controls

  • Ctrl + Shift + P: Pause/Play
  • Ctrl + Shift + Space: Step

Code Editing

  • Ctrl + Space: Autocomplete
  • Ctrl + /: Toggle line comment
  • Ctrl + Shift + /: Toggle block comment

General

  • Ctrl + Z: Undo
  • Ctrl + Y: Redo
  • Ctrl + C: Copy selected object(s) or text
  • Ctrl + X: Cut selected object(s) or text
  • Ctrl + V: Paste copied/cut object(s) or text
  • Ctrl + A: Select all
  • Ctrl + B: Build the project
  • Ctrl + Shift + B: Build and run the project

2D Shortcuts

Scene View

  • Q: Switch to the Pan tool
  • W: Switch to the Move tool
  • E: Switch to the Rotate tool
  • R: Switch to the Scale tool
  • T: Switch to the Rect tool (for sprite slicing)
  • Y: Switch to the Hand tool (for panning the view)

Sprite Editor

  • Ctrl + T: Open Sprite Editor
  • Ctrl + G: Grid snapping on/off
  • Ctrl + P: Pivot snapping on/off
  • Alt + Shift + P: Reset pivot to center

Animation Window

  • Alt + Scroll Wheel: Zoom in/out horizontally
  • Alt + Click: Create or remove animation keyframe
  • Shift + Click: Add or remove animation keyframe (in Dopesheet or Curve Editor)
  • Ctrl + D: Duplicate selected animation clip or keyframes
  • Alt + Shift + Left/Right Arrow: Move keyframes left or right

2D Physics

  • Ctrl + Shift + C: Create or remove a Collider component on the selected object
  • Ctrl + Shift + R: Create or remove a Rigidbody2D component on the selected object
@nameswayne
Copy link

Hi is there any way for you to private or hide this page? I was using a similar tutorial to your work, and now it looks like I've plagiarised. Could we talk on discord? My username on discord is: names_wayne
It'd mean the world if you could just hide this page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment