Skip to content

Instantly share code, notes, and snippets.

@thelebaron
thelebaron / SearchInspector.cs
Last active March 13, 2024 20:32
search for unity's inspector
using System.Collections.Generic;
using System.Linq;
using UnityEditor;
using UnityEngine;
namespace Junk.Utilities
{
/// <summary>
/// Thanks to Ryiah and the collective stolen knowledge of the internet via chatgpt
/// https://forum.unity.com/threads/still-no-search-field-in-the-inspector.1555850/#post-9697247
@thelebaron
thelebaron / stupidstudiomax.md
Last active February 9, 2024 21:52
Unity Entities Gotchas!

is a gist the right place where I store dumb tips that future self will forget?

Baking

1. Prefabs from code - Add the Prefab component to it!

If you are creating an entity Prefab, remember to actually add its Prefab component to it, when you assign it to its' Component. This is done automatically if you simply use GetEntity(authoring.GameObject) but you are responsible for it when doing things manually(duh).

2. If you created a Prefab from Code, remember to remove it from the LinkedEntityGroup inside of a baking system(UpdateInGroup PostBakingSystemGroup).

Why future Chris? Because by default any entity created via CreateAdditionalEntity is auto added to a LinkedEntityGroup(if one exists). Subsequently the original entity, if instantiated will also have all entities inside its buffer instantiated(Prefab entity included), and their Prefab component will be removed. In my situation removing the Prefab allowed the LifeTime to tick down, and the entity was destroyed and in

@thelebaron
thelebaron / gist:f51c88d65f9239ae1a961fc37408051c
Created May 27, 2022 17:05
"Old" CreateConfigurableJoint conversion code
//replace old method CreateConfigurableJoint in LegacyJointConversionSystem.cs with this
private PhysicsJoint CreateConfigurableJoint(
//GameObjectConversionSystem system, Entity connectedEntity,
quaternion jointFrameOrientation,
LegacyJoint joint, bool3 linearLocks, bool3 linearLimited, SoftJointLimit linearLimit, SoftJointLimitSpring linearSpring, bool3 angularFree, bool3 angularLocks,
bool3 angularLimited, SoftJointLimit lowAngularXLimit, SoftJointLimit highAngularXLimit, SoftJointLimitSpring angularXLimitSpring, SoftJointLimit angularYLimit,
SoftJointLimit angularZLimit, SoftJointLimitSpring angularYZLimitSpring)
{
//var constraints = new NativeList<Constraint>(Allocator.Temp);
using System.Runtime.CompilerServices;
using Unity.Collections;
using Unity.Entities;
using Unity.Mathematics;
using Unity.Physics;
using UnityEngine;
using FloatRange = Unity.Physics.Math.FloatRange;
using LegacyCharacter = UnityEngine.CharacterJoint;
using LegacyConfigurable = UnityEngine.ConfigurableJoint;
using LegacyFixed = UnityEngine.FixedJoint;
using UnityEngine;
using UnityEngine.Experimental.Rendering;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
namespace RenderPasses
{
/// <summary>
///
/// </summary>
@thelebaron
thelebaron / MyFirstAnimationClip.cs
Last active May 15, 2020 21:04
dots animation root motion experiment
using Unity.Animation;
using Unity.DataFlowGraph;
using Unity.Entities;
using Unity.Jobs;
using UnityEngine;
using UnityEngine.Serialization;
using Debug = UnityEngine.Debug;
namespace MyFirstAnimationClip
{
@thelebaron
thelebaron / LightConversion.cs
Last active February 20, 2020 17:33
Convert lights automatically without adding convert to entity to each light. Also has some extra systems as examples of use and extending behaviour.
using System;
using Unity.Entities;
using UnityEngine;
namespace DefaultNamespace
{
// just adds an empty tag to each light entity
// its just an example of how to add another component to an entity without going through the inspector for every gameobject you want to convert
public class LightConverter : GameObjectConversionSystem
using Animancer;
using UnityEngine;
public class Dude : MonoBehaviour
{
[SerializeField] private LinearMixerState.Transition GroundedMixerTransitionBase;
private LinearMixerState GroundedMixerState;
[SerializeField] private LinearMixerState.Transition PainMixerTransitionBase;
private LinearMixerState PainMixerState;
using Game.Components;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
using Unity.Mathematics;
using Unity.Physics;
using Unity.Physics.Authoring;
using Unity.Physics.Systems;
using Unity.Transforms;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Rendering.Universal;
public class PixelPassFeature : ScriptableRendererFeature
{
class PixelRenderPass : ScriptableRenderPass
{
const string m_ProfilerTag = "DrawPixelPass";
Color m_ClearColor = new Color(0.0f, 0.5f, 0.5f, 0.5f);