Skip to content

Instantly share code, notes, and snippets.

Avatar

pharan pharan

View GitHub Profile
@pharan
pharan / ArraysMeshGenerator.cs
Created Jun 17, 2016
A version of Spine-Unity ArraysMeshGenerator.cs that can disallow degenerate triangles and extra verts.
View ArraysMeshGenerator.cs
/******************************************************************************
* Spine Runtimes Software License
* Version 2.3
*
* Copyright (c) 2013-2015, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable and
* non-transferable license to use, install, execute and perform the Spine
* Runtimes Software (the "Software") and derivative works solely for personal
@pharan
pharan / ParallaxFaker2D.cs
Created Aug 26, 2016
Simplified (derived) formula for faking the parallax of an object given a camera position, in the form of a Unity component. This may not work for VR??
View ParallaxFaker2D.cs
using UnityEngine;
public class ParallaxFaker2D : MonoBehaviour {
// The Transform of the camera to fake the parallax for.
public Transform cameraTransform;
// The world position to mimick the parallax of.
public Vector3 fakePosition;
// The Transform's target (actual) distance from the camera.
@pharan
pharan / DistanceApplier.cs
Created Aug 26, 2016
Formula for scaling an object according to how far it moves from an original point and viewpoint, in order to maintain its perceived size. In the form of a Unity MonoBehaviour. This is to achieve VR-friendly parallax for 2D games.
View DistanceApplier.cs
using UnityEngine;
/// <summary>
/// This script will push an object back to a target Z position and maintain its size to a given editor camera distance. This is to achieve parallax that is compatible with VR.</summary>
public class DistanceApplier : MonoBehaviour {
public float targetZ = 20;
// The applied scale will try to maintain the scale of the object assuming the original scale was defined when viewed with the camera at this z position.
const float BaseCameraZ = -10;
@pharan
pharan / RuntimeAssets.cs
Last active Mar 30, 2019
Sample code for creating runtime Spine ScriptableObjects.
View RuntimeAssets.cs
using UnityEngine;
using System.Collections.Generic;
namespace Spine.Unity {
public static class RuntimeAssets {
public static AtlasAsset CreateAtlasAsset (TextAsset atlasText, Material[] materials, bool initialize) {
AtlasAsset atlasAsset = ScriptableObject.CreateInstance<AtlasAsset>();
atlasAsset.Reset();
atlasAsset.atlasFile = atlasText;
@pharan
pharan / SpineRootMotion.cs
Last active Oct 12, 2018
Experimental Spine.Unity.Modules.SpineRootMotion for SkeletonAnimation
View SpineRootMotion.cs
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
@pharan
pharan / AnimationState.cs
Last active Apr 4, 2017
Alternate Spine 3.5 AnimationState.cs that disables multiple mixing from in favor of eliminating the setup pose dip.
View AnimationState.cs
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
@pharan
pharan / DEBUG_AnimationStateSceneView.cs
Last active Dec 15, 2016
Quick and dirty Spine.AnimationState SceneView debug. This logs the current state of the AnimationState tracks.
View DEBUG_AnimationStateSceneView.cs
using UnityEngine;
using System.Text;
public class DEBUG_AnimationStateSceneView : MonoBehaviour {
public bool follow = true;
}
#if UNITY_EDITOR
namespace Spine.Unity.Debugger {
[UnityEditor.CustomEditor(typeof(DEBUG_AnimationStateSceneView))]
@pharan
pharan / ThreadedSkeletonDataAssetLoader.cs
Created Dec 17, 2016
Test code for spine-unity threaded loading of Spine Skeleton json and binary data.
View ThreadedSkeletonDataAssetLoader.cs
/******************************************************************************
* Spine Runtimes Software License v2.5
*
* Copyright (c) 2013-2016, Esoteric Software
* All rights reserved.
*
* You are granted a perpetual, non-exclusive, non-sublicensable, and
* non-transferable license to use, install, execute, and perform the Spine
* Runtimes software and derivative works solely for personal or internal
* use. Without the written permission of Esoteric Software (see Section 2 of
@pharan
pharan / SampleManualUpdate.cs
Created Jan 9, 2017
A sample MonoBehaviour for Spine-Unity that holds a collection of SkeletonAnimation components and updates their animation at a certain limited rate.
View SampleManualUpdate.cs
using UnityEngine;
using System.Collections.Generic;
namespace Spine.Unity.Examples {
public class SampleManualUpdate : MonoBehaviour {
[Range(0f, 1/8f)]
[Tooltip("To specify a framerate, type 1/framerate in the inspector text box.")]
public float timeBetweenFrames = 1f/24f; //24 fps
public List<SkeletonAnimation> components;
@pharan
pharan / Skeleton PMAMultiply.shader
Created Mar 3, 2017
Multiply blend mode shader for Spine.
View Skeleton PMAMultiply.shader
// Spine/Skeleton PMA Multiply
// - single color multiply tint
// - unlit
// - Premultiplied alpha Multiply blending
// - No depth, no backface culling, no fog.
// - ShadowCaster pass
Shader "Spine/Skeleton PMA Multiply" {
Properties {
_Color ("Tint Color", Color) = (1,1,1,1)
You can’t perform that action at this time.