Skip to content

Instantly share code, notes, and snippets.

using TMPro;
using UnityEngine;
using UnityEngine.UI;
public class AnimatorPanel : MonoBehaviour
{
[SerializeField] Animator _animator;
[SerializeField] Button _button;
void Start()
@unity3dcollege
unity3dcollege / InputExample.cs
Last active October 10, 2021 17:23
InputExample.cs
//Using the new Unity input system,
// a simple code that takes the player animation from a walk to a run if the _axisInput.x is held for 2 seconds.
// Something like this non working code where speed > 3 is run and less than 3 is walk and 2f is time the input key is held down:
// YES, we are very new at this lol
if (_axisInput.x >= Time.deltaTime * 2f)
_animator.SetFloat("Speed", 3);
else
else _animator.SetFloat("Speed", -.02f);
using UnityEngine;
public class BladeTrap : MonoBehaviour
{
private void OnCollisionEnter(Collision collision)
{
var enemy = collision.collider.GetComponentInParent<Enemy>();
if (enemy == null)
return;
using UnityEngine;
public class Perf : MonoBehaviour
{
[SerializeField] int _callsPerFrame = 10000;
void Update()
{
for (int i = 0; i < _callsPerFrame; i++)
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bomb : MonoBehaviour
{
[SerializeField] float _countdownTime = 5f;
[SerializeField] float _radius = 5f;
[SerializeField] int _damage = 5;
int nextY = 0;
int direction = 1;
private void Update()
{
if (nextY == 90 || nextY == 0)
direction *= -1;
nextY += direction;
var nextRotation = new Vector3(transform.rotation.eulerAngles.x, nextY, transform.rotation.eulerAngles.z);
transform.rotation = Quaternion.Euler(nextRotation);
using System;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceManagement.AsyncOperations;
public class ParticleSpawner : MonoBehaviour
{
[SerializeField] private List<AssetReference> _particleReferences;
private void StickToMovingObjects()
{
if(groundedObj != null){
if(groundedObjLastPosition.HasValue &&
groundedObjLastPosition.Value != groundedObj.position){
//Determines the delta of the last position to the new position.
Vector3 delta = groundedObj.position - groundedObjLastPosition.Value;
//Moves the grounded object at the same rate as the groundedObj.
GetComponent<Rigidbody2D>().position += (Vector2)delta;
}
using System.IO;
namespace binarywritertest
{
class Program
{
static void Main(string[] args)
{
byte[] data = new byte[100];
for (byte i = 0; i < 100; i++)
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
public class GameDataController : MonoBehaviour
{
public static SaveData saveData;
private void Awake()
{