Skip to content

Instantly share code, notes, and snippets.

View samsheffield's full-sized avatar
🏠
Homing from work

Sam Sheffield samsheffield

🏠
Homing from work
View GitHub Profile
@samsheffield
samsheffield / JustOnce.cs
Created September 27, 2021 00:40
How to do something just once in Update
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class JustOnce : MonoBehaviour
{
// Has the thing already been done?
private bool alreadyDone = false;
@samsheffield
samsheffield / SwitchScene.cs
Created September 28, 2021 08:36
Load a scene with a keypress
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement; // Add Scene Management
public class SwitchScene : MonoBehaviour
{
// Important: Don't forget to add the next scene to your project's Build Settings
@samsheffield
samsheffield / DeActivatingGameObjects.txt
Created October 3, 2021 20:53
(De)Activating GameObjects
Here is a bonus Unity example for 2D Game Design F21. Let me know what else you need!
======================================================================================
(DE) ACTIVATING GAMEOBJECTS
Activate another GameObject on Start example: ShowOnStart.cs
Deactivate this GameObject on action (press space) example: HideOnAction.cs
Example Unity Project: https://drive.google.com/file/d/1qhtZZOpn83fH7DKXjtUJ8WmbGrK62By2/view?usp=sharing
Important:
1. ShowOnStart requires the GameObject you want to activate deactivated in your scene (uncheck the top-left box in its Inspector)
@samsheffield
samsheffield / InkInteraction.cs
Created December 5, 2023 23:09
Ink + Unity demo files (Narrative Design F23)
using System;
using System.Collections;
using UnityEngine;
public class InkInteraction : MonoBehaviour
{
// This is the ink JSON asset
[SerializeField] private TextAsset inkJSON;
// This is a reference to the Ink Manager script designed to run the story