Skip to content

Instantly share code, notes, and snippets.

View SleeplessOwl0102's full-sized avatar

Lyx SleeplessOwl0102

View GitHub Profile
@SleeplessOwl0102
SleeplessOwl0102 / Loader.cs
Last active July 5, 2023 08:25 — forked from tsubaki/Loader.cs
ExclusiveEntityTransaction 使用案例
using System.Collections;
using UnityEngine;
using Unity.Entities;
using Unity.Jobs;
using Unity.Collections;
public class Loader : MonoBehaviour
{
World myWorld;
EntityManager myEntityManager;
@SleeplessOwl0102
SleeplessOwl0102 / CameraTracking.cs
Created July 4, 2023 11:56
同步Sceneview和Gameview相机的Transform
using UnityEditor;
using UnityEditor.ShortcutManagement;
using UnityEngine;
using UnityEngine.Assertions;
namespace RenLibEditor
{
[ExecuteInEditMode]
public class CameraTracking
{
@SleeplessOwl0102
SleeplessOwl0102 / FreeCameraController.cs
Last active July 4, 2023 12:01
A free camera that allows you to fly around the scene freely, similar to Unity's scene view camera.
using UnityEngine;
/// <summary>
/// A free camera that allows you to fly around the scene freely, similar to Unity's scene view camera.
/// </summary>
public class FreeCameraController : MonoBehaviour
{
public float m_LookSpeedMouse = 10.0f;
public float m_MoveSpeed = 50.0f;
Shader "TextMeshPro/TextMesh Billboard" {
Properties {
[HDR]_FaceColor ("Face Color", Color) = (1,1,1,1)
_FaceDilate ("Face Dilate", Range(-1,1)) = 0
[HDR]_OutlineColor ("Outline Color", Color) = (0,0,0,1)
_OutlineWidth ("Outline Thickness", Range(0,1)) = 0
_OutlineSoftness ("Outline Softness", Range(0,1)) = 0
@SleeplessOwl0102
SleeplessOwl0102 / CommonUtils.cs
Last active July 4, 2023 12:00
计算屏幕点击处,和3D空间中的线段,在屏幕空间中的最短距离
//计算屏幕点击处,和3D空间中的线段,在屏幕空间中的最短距离
public static float DetectClickOnLine(Camera camera,Vector3 p1, Vector3 p2)
{
var v1 = camera.WorldToScreenPoint(p1);
var v2 =camera.WorldToScreenPoint(p2);
Vector2 point = Input.mousePosition;
//计算点到直线的距离
var xDis = v2.x - v1.x;
using System.IO;
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
namespace UnityDocTool
{
public class ScreenShotHelper
{
//https://stackoverflow.com/questions/48663073/editor-window-screenshot
@SleeplessOwl0102
SleeplessOwl0102 / RotationMatrixFromEuler.hlsl
Last active December 20, 2022 16:19
RotationMatrixFromEuler
// Euler angles rotation matrix
float3x3 RotationMatrixFromEuler(float3 v)
{
float sx, cx;
float sy, cy;
float sz, cz;
sincos(v.x, sx, cx);
sincos(v.y, sy, cy);
sincos(v.z, sz, cz);