This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ExecuteInEditMode] | |
[RequireComponent(typeof(ParticleSystem))] | |
public sealed class ParticlesOrbitalMovement : MonoBehaviour | |
{ | |
public float MinSpeed; | |
public float MaxSpeed; | |
private ParticleSystem _particleSystem; | |
private ParticleSystem.Particle[] _particles; | |
private Dictionary<int, OrbitalParticleData> _orbitalParticleDatas; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Mattatz/TextureAnimation" | |
{ | |
Properties | |
{ | |
_MainTex ("Texture", 2D) = "white" {} | |
_Color ("Color", Color) = (1, 1, 1, 1) | |
_Cols ("Cols Count", Int) = 5 | |
_Rows ("Rows Count", Int) = 3 | |
_Frame ("Per Frame Length", Float) = 0.5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn get_images_paths(directoryPath: &String) -> Vec<String> { | |
let mut res_paths = vec!(); | |
let paths = fs::read_dir(directoryPath).unwrap(); | |
for img_path in paths { | |
let path = img_path.unwrap().path(); | |
let extension = { | |
let extension = path.extension(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pub fn clone_into_array<A, T>(slice: &[T]) -> A | |
where A: Sized + Default + AsMut<[T]>, | |
T: Clone | |
{ | |
let mut arr = Default::default(); | |
<A as AsMut<[T]>>::as_mut(&mut arr).clone_from_slice(slice); | |
arr | |
} | |
pub fn shuffle_create_new<T: Clone>(vec: &[T]) -> Vec<T> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool TryGetAvailablePort(out int availableUdpPort) | |
{ | |
var activeUdpListeners = IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners(); | |
var range = Enumerable.Range(5000, 6000); | |
availableUdpPort = range.First(p => activeUdpListeners.All(l => l.Port != p)); | |
return availableUdpPort != -1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Repeater | |
{ | |
public static async Task DoInfinityAsync(Action action, TimeSpan interval, CancellationToken cancellationToken) | |
{ | |
while (!cancellationToken.IsCancellationRequested) | |
{ | |
try | |
{ | |
action(); | |
await Task.Delay(interval, cancellationToken); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<IPAddress> GetIpAddressesFromNetworkAdapters(AddressFamily addressFamily) | |
{ | |
var networkInterfaces = from networkInterface in NetworkInterface.GetAllNetworkInterfaces() | |
where networkInterface.OperationalStatus == OperationalStatus.Up && | |
networkInterface.SupportsMulticast && | |
(networkInterface.NetworkInterfaceType == NetworkInterfaceType.Ethernet || | |
networkInterface.NetworkInterfaceType == NetworkInterfaceType.Wireless80211) | |
select new | |
{ | |
name = networkInterface.Name, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public bool TryGetFirstAvailableUdpPort(out int port) | |
{ | |
var startingAtPort = 5678; | |
var maxNumberOfPortsToCheck = 500; | |
var range = Enumerable.Range(startingAtPort, maxNumberOfPortsToCheck).ToList(); | |
var portsInUse = | |
from p in range | |
join used in System.Net.NetworkInformation.IPGlobalProperties.GetIPGlobalProperties().GetActiveUdpListeners() | |
on p equals used.Port |