Skip to content

Instantly share code, notes, and snippets.

Sprite tempSprite;
SpriteRenderer changeSprite;
void Update(){
changeSprite = gameObject.GetComponent<SpriteRenderer>();
switch(type){
case 0:
void putToFloor(){
RaycastHit2D hit = Physics2D.Raycast(transform.position, -Vector3.up);
if (hit.collider != null)
{
transform.position = hit.point;
Debug.Log ("Putting here: "+transform.position);
}
Debug.Log ("Found nothing to hit: " + hit.point);
}
@antonkudin
antonkudin / logoAssembler.cs
Last active May 2, 2019 10:34
MegaSphere logo assembler
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class logoAssembler : MonoBehaviour {
[SerializeField] bool debugMe;
[SerializeField] bool remakePixels;
[SerializeField] bool autoPlay;
[SerializeField][Range(0,10)] float autoDur = 10;
{"lastUpload":"2021-03-02T02:37:26.635Z","extensionVersion":"v3.4.3"}
// threshold for mask can be controlled using vertex color alpha (useful for spriteRenderers or particle systems)
// _MainTex: alpha of this texture is used as a mask
// _EmissionTex: usually rgb noise texture, adjust it's scaling if needed
// color remap and oscilation for each channel of emission can be modified in _EmStrobeBFALR, _EmStrobeBFALG, _EmStrobeBFALB
// Base: base amplitude of brightness oscilation
// Freq: frequency of oscilation
// Ampl: amplitude of oscilation
// L: how much _EmissionTex affects this color
Shader "StandardWMask" {
class treeThing {
// tree design: all the changable variables in one place!
struct treeStyle {
// skipping stuff like how many branches per tree, sticks per branch..
// sticks
Vector2 stickAngleJagMM; // how jaggy the branches are (min-max)
Vector2 stickLengthMM; // how long the sticks are (min-max)
@antonkudin
antonkudin / Mathfx.cs
Created December 14, 2022 16:22
Adjust path so segments of path are more or less the same length
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Mathfx
{
public static void normalizePoints(ref List<Vector2> path) {
float length = 0;
List<float> lengths = UnityEngine.Pool.GenericPool<List<float>>.Get();
// c# companion script
// SpriteUVToShader.cs -------------------------------------------------------------------------------------------------------------------------------- //
// Save you your project, add to your SpriteRenderer gameObject
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
[ExecuteInEditMode]
@antonkudin
antonkudin / pipeGenerator.cs
Created September 26, 2023 13:48
Generates pipe mesh from mesh segments
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pipeGenerator : MonoBehaviour
{
[SerializeField] Mesh straightMesh;
[SerializeField] Mesh elbowMesh;
[Space]
[SerializeField] Vector3[] pathPoints;
@antonkudin
antonkudin / RenameAttribute.cs
Created November 21, 2023 02:49
Rename variable names inside your properties
using UnityEngine;
#if UNITY_EDITOR
[System.AttributeUsage(System.AttributeTargets.Field)]
public class RenameAttribute : PropertyAttribute
{
public string[] renamePairs;
public RenameAttribute(params string[] renamePairs)
{