Skip to content

Instantly share code, notes, and snippets.

@yasirkula
yasirkula / SlicedFilledImage.cs
Last active June 27, 2024 09:31
Combining UI Image's Sliced+Filled features together in Unity
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
#if UNITY_2017_4 || UNITY_2018_2_OR_NEWER
using UnityEngine.U2D;
#endif
using Sprites = UnityEngine.Sprites;
#if UNITY_EDITOR
@phi-lira
phi-lira / UniversalPipelineTemplateShader.shader
Last active June 15, 2024 02:13
Template shader to use as guide to create Universal Pipeline ready shaders. This shader works with Universal Render Pipeline 7.1.x and above.
// When creating shaders for Universal Render Pipeline you can you the ShaderGraph which is super AWESOME!
// However, if you want to author shaders in shading language you can use this teamplate as a base.
// Please note, this shader does not necessarily match perfomance of the built-in URP Lit shader.
// This shader works with URP 7.1.x and above
Shader "Universal Render Pipeline/Custom/Physically Based Example"
{
Properties
{
// Specular vs Metallic workflow
[HideInInspector] _WorkflowMode("WorkflowMode", Float) = 1.0
@QXSoftware
QXSoftware / Underline.cs
Last active March 21, 2023 03:08
Simple UGUI Underline
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
/// <summary>
///
/// Unity 引擎的 mesh 顶点顺序如下:
///
/// (0)-------(1)(4)-------(5)
/// | | | |
@QXSoftware
QXSoftware / dependency_test.md
Last active March 25, 2024 14:59
资源依赖正确性测试

资源依赖正确性测试

本次测试包含对AssetDatabase.GetDependenciesEditorUtility.CollectDependencies这两个获取资源的依赖资源的 API 的测试,以及对于meta残留对打AssetBundle的影响。

AssetDatabase.GetDependencies

输入资源路径,例如Assets/Material/demo.mat,以路径形式返回该资源依赖的资源列表,例如Assets/Texture/demo.jpg

这个 API 返回的结果是“错误”的,也就是带残留的。比如某个材质,原本的shader引用了4个纹理,然后切换其shader为新的shader使之只引用一个纹理,这时AssetDatabase.GetDependencies返回的结果还是4个纹理。

@mattatz
mattatz / TextureAnimation.shader
Last active March 28, 2024 22:37
Texture animation shader for Unity.
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
@onevcat
onevcat / xcodeproj_build.rb
Last active May 12, 2023 02:03
Example of using xcodeproj
require_relative "../config.rb"
gem 'xcodeproj', '>=0.19.4'
require 'xcodeproj'
PROJECT = 'Unity-iPhone'
TARGET = 'Unity-iPhone'
LIBRARY = 'Libraries'
### Export
def exportUnityProject
@mutoo
mutoo / LayerBlur.js
Last active June 21, 2021 21:10
blurred-modal-background-in-cocos2d-js
var LayerBlur = cc.Layer.extend({
ctor: function (blurRadius, maskColor) {
this._super();
// create shader program
var program = cc.GLProgram.create(res.blur_vsh, res.blur_fsh);
program.addAttribute(cc.ATTRIBUTE_NAME_POSITION, cc.VERTEX_ATTRIB_POSITION);
program.addAttribute(cc.ATTRIBUTE_NAME_COLOR, cc.VERTEX_ATTRIB_COLOR);
program.addAttribute(cc.ATTRIBUTE_NAME_TEX_COORD, cc.VERTEX_ATTRIB_TEX_COORDS);
program.link();
@gmccreight
gmccreight / master.vim
Last active June 19, 2024 15:30
A script that gives you a playground for mastering vim
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@blork
blork / StackIntentService.java
Last active December 15, 2015 19:29 — forked from SeanPONeil/BlockingIntentService.java
Works as IntentService, based on code from AOSP. Adds intents to a LIFO stack, executes most recently added first. onHandleIntent returns boolean indicating whether the intent has already been added.
package com.threesquared.axawellbeing.web.services;
import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.HandlerThread;
import android.os.IBinder;
import android.os.Looper;
import android.os.Message;
@drewolson
drewolson / reflection.go
Last active November 20, 2023 09:39
Golang Reflection Example
package main
import (
"fmt"
"reflect"
)
type Foo struct {
FirstName string `tag_name:"tag 1"`
LastName string `tag_name:"tag 2"`