Skip to content

Instantly share code, notes, and snippets.

View Demkeys's full-sized avatar
💭
Always learning and sharing knowledge

Abhinav a.k.a Demkeys Demkeys

💭
Always learning and sharing knowledge
View GitHub Profile
@Demkeys
Demkeys / 94-ECS__ECS System C# Script-ECSNewSystemScript.cs.txt
Created March 13, 2019 03:34
Template file2 for ECS boilerplate code in Unity. Name this file '94-ECS__ECS System C# Script-ECSNewSystemScript.cs.txt'.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Transforms;
@Demkeys
Demkeys / GUIStylesExample.cs
Created December 4, 2018 16:31
Example code showing how to use the GUIStyles provided in UnityEditor.EditorStyles class.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public class GUIStylesExample : EditorWindow {
string textFieldString = "This is a textbox that looks like a bold Label.";
[MenuItem("My Tools/GUI Styles Example")]
@Demkeys
Demkeys / BoolArrayToBitString.cs
Last active October 17, 2018 02:42
Example code for Unity, demonstrating how to pack a bool array into a string and unpack a string in a bool array.
/// <summary>
/// This script demonstrates how to convert a bool array to a string of bits and convert a string of bits to a bool array.
/// Usage:
/// - Attach this script to an empty gameobject. From the Inspector set the values of the items in the bool array.
/// - Enter Play Mode.
/// - Hit 'a' key, the values of the bool array will be converted to a bit string.
/// - Hit 's' key, bit string will be converted into a bool array.
/// </summary>
using UnityEngine;
@Demkeys
Demkeys / JsonExample02.cs
Created October 2, 2018 07:51
Example showing how to serialize and deserialize arrays of data in Unty
// Attach this script to a gameobject in the scene. objectDetails01 is serialized into JSON and stored
// in a string. Then the JSON string is deserialized and cast to ObjectDetails type, and stored into
// objectDetails02. The data of objectDetails02 can be seen in the Inspector.
using UnityEngine;
public class JsonExample02 : MonoBehaviour {
public ObjectDetails objectDetails01;
public ObjectDetails objectDetails02;
@Demkeys
Demkeys / JsonExample01.cs
Last active October 2, 2018 07:50
Examples showing how to serialize and deserialize data in Unity
// Attach this script to a gameobject in the scene. myChar01 is serialized into JSON and stored
// in a string. Then the JSON is deserialized and cast to Character type, and stored into myChar02.
// The data of myChar02 can be seen in the Inspector.
using UnityEngine;
public class JsonExample01 : MonoBehaviour {
public Character myChar01;
public Character myChar02;
@Demkeys
Demkeys / KeyEventComparer.cs
Created August 30, 2018 07:51
KeyEventComparer for GOTO Logic
using System;
using UnityEngine;
namespace GOTO.Logic.Comparers
{
[Serializable]
[ComparerCategory("Comparer")]
public class KeyEventComparer : Comparer
{
public enum KeyEventType { KeyDown, KeyUp, KeyPress };
@Demkeys
Demkeys / ScreencapScript.cs
Last active August 5, 2018 23:59
Simple example showing how to use the Screencapture class.
/// <summary>
/// Attach this script to any gameobject in the scene, enter Play Mode, then hit Space on your keyboard to capture a screenshot.
/// Exit Play Mode, refresh the Project panel, and the scenecap image should be in the Assets folder.
/// </summary>
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ScreencapScript : MonoBehaviour {
@Demkeys
Demkeys / MuteTimelineTracksScript.cs
Created June 29, 2018 13:59
Example code showing how to mute Tracks in a Timeline asset.
/// <summary>
/// Instructions
/// - Create a Timeline asset. Add 3 tracks to it.
/// - Create empty GameObject in scene. Attach this script to the GameObject. Then attach a PlayableDirector component to it.
/// Drag and drop the Timeline asset you created into the Playable field of the PlayableDirector.
/// - Hit Play. The 1, 2 and 3 keys on your keyboard mute the first, second and third tracks respectively.
/// </summary>
using System.Collections;
using System.Collections.Generic;
@Demkeys
Demkeys / GridSnapper.cs
Last active October 24, 2018 11:33
Simple Grid Snapper script to show how the Grid component can be used to align GameObjects along the cells of a Grid.
/// <summary>
/// - Make sure you have a Grid GameObject (any GameObject with a Grid component attached to it) in the scene.
/// - Attach this script to the GameObject you wanna snap to the Grid. Then drag and drop the Grid
/// GameObject into the AttachedGrid field to create a reference to the Grid component attached to it.
/// - Enter Play Mode, and then every time you hit the Space key, this GameObject will move 1 unit
/// down along the Y axis, while remaining snapped to the Grid.
/// </summary>
using System.Collections;
using System.Collections.Generic;
@Demkeys
Demkeys / CircleGenScript01.cs
Created April 16, 2018 11:48
Simple script that procedurally generates a circle of spheres, and then updates the position of those spheres every frame to form patterns.
// Just something fun I came up with when learning Trigonometry.
// Attach this script to an empty gameobject and enter Play Mode. A circle of spheres will be created. All the spheres will be
// children of the gameobject that this script is attached to. When you hit the Spacebar key, the position of each sphere will
// start updating and from that point on, every frame the positions will be updated to form patterns.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CircleGenScript01 : MonoBehaviour {