Skip to content

Instantly share code, notes, and snippets.

// note - requires asmref trick to get internal access for using the DeformedEntity
using System;
using System.Linq;
using System.Reflection;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Entities.Serialization;
using Unity.Rendering;
using System.Linq;
using System.Reflection;
using UnityEditor;
using UnityEditor.ShortcutManagement;
using UnityEngine;
using UnityEngine.UIElements;
namespace Junk.Entities.Editor
{
[InitializeOnLoad]
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Rendering;
using UnityEngine;
namespace Junk.Rendering.Hybrid
{
//Short notes: requires internal access asmref trick
public class GetSkinnedEntityAuthoring : MonoBehaviour
#if UNITY_EDITOR
using UnityEngine;
using UnityEditor;
using UnityEngine.SceneManagement;
using System.IO;
using System.Linq;
using System.Text.RegularExpressions;
namespace Junk.Hotfixes
{
using System;
using System.Linq;
using Unity.Collections;
using Unity.Entities;
using Unity.Entities.Hybrid.Baking;
using Unity.Transforms;
using UnityEngine;
// ReSharper disable Unity.Entities.MustBeSurroundedWithRefRwRo
namespace Junk.Rendering.Hybrid
@thelebaron
thelebaron / SearchInspector.cs
Last active September 19, 2024 00:06
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>