Skip to content

Instantly share code, notes, and snippets.

View PrashantUnity's full-sized avatar
🎯
Focusing

Prashant Priyadarshi PrashantUnity

🎯
Focusing
View GitHub Profile
View UnityCodingCheatSheet.txt
// 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
@PrashantUnity
PrashantUnity / SieveOfEratosthenes.cs
Created January 8, 2022 18:21 — forked from SuprDewd/SieveOfEratosthenes.cs
Sieve Of Eratosthenes
View SieveOfEratosthenes.cs
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;
@PrashantUnity
PrashantUnity / SiveOfEratosthenes.cs
Created May 6, 2022 21:50
Print Prime Value Upto N Prime Number
View SiveOfEratosthenes.cs
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 Explosion.cs
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
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;
@PrashantUnity
PrashantUnity / ChangingMaterials.cs
Last active August 13, 2022 05:18
Dynamically Change Materials
View ChangingMaterials.cs
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;
@PrashantUnity
PrashantUnity / PrefabInstantiate.cs
Last active August 21, 2022 10:44
Generate Prefab on Spherical Object
View PrefabInstantiate.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MapGenerator : MonoBehaviour
{
public GameObject objectToGenerated;
public float theta;
public float radius;
@PrashantUnity
PrashantUnity / Edit.cs
Created August 27, 2022 15:05
Mesh Generation basic
View Edit.cs
using UnityEditor;
[CustomEditor(typeof(MapGenerator))]
public class Edit : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
MapGenerator mapGenerator = (MapGenerator)target;
mapGenerator.Function();
}
@PrashantUnity
PrashantUnity / ShapesData.cs
Created August 28, 2022 16:10
Creating Shapes points in 3d Space
View ShapesData.cs
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;
View Editor.cs
// MapGenerator is class on which this custom editor will be called
using UnityEditor;
[CustomEditor(typeof(MapGenerator))]
public class Edit : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
// if you remove |^|(base.OnInspectorGUI(); )
// variable in inspector may not show up properly