View UnityCodingCheatSheet.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Unity C# Cheat Sheet | |
// I made these examples for students with prior exerience working with C# and Unity. | |
// Too much? Try Unity's very good tutorials to get up to speed: https://unity3d.com/learn/tutorials/topics/scripting |
View SieveOfEratosthenes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace Primes | |
{ | |
public static IEnumerable<int> SieveOfEratosthenes(int upperLimit) | |
{ | |
int sieveBound = (upperLimit - 1) / 2, | |
upperSqrt = ((int)Math.Sqrt(upperLimit) - 1) / 2; |
View SiveOfEratosthenes.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class Program | |
{ | |
public static void Main() | |
{ | |
var n = 53; | |
var prime = SieveOfEratosthenes(n); | |
for (int i = 2; i <= n; i++) | |
{ | |
if(prime[i] == 0) | |
{ |
View MoveFiles.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.IO; | |
using System; | |
namespace ForGeneral | |
{ | |
internal class MoveFiles | |
{ | |
public static void Move() | |
{ | |
try |
View Explosion.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class ExploderForceRange : MonoBehaviour | |
{ | |
public float radius = 5f; | |
public float force = 70f; | |
private void OnTriggerEnter(Collider other) | |
{ |
View Countdown.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using TMPro; | |
public class CountDown : MonoBehaviour | |
{ | |
public float InstantiationTimer = 2f; | |
public float interval = 2f; |
View ChangingMaterials.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class DeerScript : MonoBehaviour | |
{ | |
// this is gameobject whose material will be changed | |
public GameObject target; | |
View PrefabInstantiate.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class MapGenerator : MonoBehaviour | |
{ | |
public GameObject objectToGenerated; | |
public float theta; | |
public float radius; | |
View Edit.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEditor; | |
[CustomEditor(typeof(MapGenerator))] | |
public class Edit : Editor | |
{ | |
public override void OnInspectorGUI() | |
{ | |
base.OnInspectorGUI(); | |
MapGenerator mapGenerator = (MapGenerator)target; | |
mapGenerator.Function(); | |
} |
View ShapesData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using System.Drawing; | |
using UnityEngine; | |
using static TMPro.SpriteAssetUtilities.TexturePacker_JsonArray; | |
public class ShapesData | |
{ | |
public float circleRadius; | |
public Vector2 rectangle; |
OlderNewer