Skip to content

Instantly share code, notes, and snippets.

View nicloay's full-sized avatar
✌️

Nikolay nicloay

✌️
View GitHub Profile
@nicloay
nicloay / ArmadiloFsm.cs
Last active June 1, 2023 19:35
Unity ECS stateMachine
using CyberSnake.ECS.AI.EnemyProperties;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Jobs;
namespace CyberSnake.ECS.AI.Armadillo.FSM
{
// --------states-------
public struct IdleState : IComponentData, IEnableableComponent {}
@nicloay
nicloay / GamePlayScope.cs
Created May 4, 2023 09:57
Waiting ecs singleton in the monobehaviour component.
// Finally, we need to connect all of this together with VContainer.
// We create and inject the taskCompletionSource and respective task.
// We register our system.
// Finally, we register our consumer component in the scene.
public class GamePlayScope : LifetimeScope
{
protected override void Configure(IContainerBuilder builder)
{
var singletonDataSource = new UniTaskCompletionSource<SingletonData>();
builder.RegisterInstance(singletonDataSource);
@nicloay
nicloay / DamageOnTriggerEnterSystem.cs
Last active April 22, 2023 16:52
trigger enter monitor system
using CyberSnake.ECS.Authoring;
using CyberSnake.ECS.ComponentData;
using Unity.Burst;
using Unity.Collections;
using Unity.Entities;
using Unity.Physics;
namespace CyberSnake.ECS.Systems
{
[UpdateInGroup(typeof(FixedStepSimulationSystemGroup))]
@nicloay
nicloay / GizmoText.cs
Last active March 28, 2023 22:01
Print text at OnDrawGizmos() and OnDrawGizmosSelected() small utiltiy
using System;
using UnityEngine;
namespace Utils
{
public class GizmoText : IDisposable
{
private Rect rect = new Rect(5, 5, 120, 20);
private const int VERTICAL_STEP = 25;
using UnityEngine;
using UnityEngine.EventSystems;
namespace SceneTransition.Demo
{
/// <summary>
/// Custom Input module:
/// If cursor is locked, send mouse events from center of the screen.
///
/// Found this hack here https://forum.unity.com/threads/fake-mouse-position-in-4-6-ui-answered.283748/#post-3600421
namespace PaintCraft.Controllers{
[RequireComponent(typeof(Camera))]
public class ScreenCameraController : InputController, IPointerDownHandler, IPointerUpHandler, IPointerClickHandler {
...
void Update()
{
UpdateDragIfNeeded();
...
}
...
/*
MIT License
Copyright (c) 2017 Jiulong Wang
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
using System;
namespace Utils.Ease
{
[Serializable]
public class EaseConfig
{
public EaseType EaseType;
public float Time;
}
@nicloay
nicloay / SecondCameraCtrl.cs
Last active November 19, 2018 13:13
Add this component to the same gameobject as paintcraft CanvasController
using PaintCraft.Canvas.Configs;
using PaintCraft.Controllers;
using UnityEngine;
using UnityEngine.Assertions;
[RequireComponent(typeof(CanvasController))]
public class SecondCameraCtrl : MonoBehaviour
{
using System.Collections;
using System.Collections.Generic;
using DigitalRubyShared;
using PaintCraft.Controllers;
using UnityEngine;
public class CamControllGesture : ScreenCameraController
{
[SerializeField]
private Camera _camera;