Skip to content

Instantly share code, notes, and snippets.

using UnityEngine;
public class RangedExample : MonoBehaviour
{
[Header("Numeric Attributes")]
[Tooltip("A float using the Range attribute")]
[Range(-5f, 5f)]
[SerializeField]
private float rangedFloat;
public class TextAreaExample : MonoBehaviour
{
[TextArea]
[Tooltip("A string using the TextArea attribute")]
[SerializeField]
private string descriptionTextArea;
[Multiline]
[Tooltip("A string using the MultiLine attribute")]
[SerializeField]
using UnityEngine;
[HelpURL("http://unity3d.college")]
[SelectionBase]
public class MyClass : MonoBehaviour
{
[Header("Text Attributes")]
[TextArea]
[Tooltip("A string using the TextArea attribute")]
[SerializeField]
[Header("Numeric Attributes")]
[Tooltip("A float using the Range attribute")]
[Range(-5f, 5f)]
[SerializeField]
private float rangedFloat;
[Space]
[Tooltip("An integer using the Range attribute")]
[Range(-5, 5)]
[SerializeField]
[Header("Context Menu Items")]
[ContextMenuItem("RandomValue", "RandomizeValueFromRightClick")]
[SerializeField]
private float randomValue;
private void RandomizeValueFromRightClick()
{
randomValue = Random.Range(-5f, 5f);
}
[ContextMenu("Choose Random Values")]
private void ChooseRandomValues()
{
rangedFloat = Random.Range(-5f, 5f);
rangedInt = Random.Range(-5, 5);
}
using UnityEngine;
public class PoolTestingExample : MonoBehaviour
{
[SerializeField]
private Projectile prefab;
private void OnEnable()
{
var projectile = prefab.Get<Projectile>();
using System.Collections.Generic;
using UnityEngine;
public class Pool : MonoBehaviour
{
private static Dictionary<PooledMonobehaviour, Pool> pools = new Dictionary<PooledMonobehaviour, Pool>();
private Queue<PooledMonobehaviour> objects = new Queue<PooledMonobehaviour>();
private List<PooledMonobehaviour> disabledObjects = new List<PooledMonobehaviour>();
using System;
using UnityEngine;
public class PooledMonobehaviour : MonoBehaviour
{
[SerializeField]
private int initialPoolSize = 100;
public int InitialPoolSize { get { return initialPoolSize; } }
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
public class PoolPreparer : MonoBehaviour
{
[SerializeField]
PooledMonobehaviour[] prefabs;