1
This commit is contained in:
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30918bcaadaaecc42bc215ff52f75b21
|
||||
folderAsset: yes
|
||||
timeCreated: 1488288531
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"name": "spine-unity-editor",
|
||||
"references": [
|
||||
"spine-unity"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 173464ddf4cdb6640a4dfa8a9281ad69
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 83fbec88df35fe34bab43a5dde6788af
|
||||
folderAsset: yes
|
||||
timeCreated: 1527569675
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,383 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
//#define BAKE_ALL_BUTTON
|
||||
//#define REGION_BAKING_MESH
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Spine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using Event = UnityEngine.Event;
|
||||
|
||||
[CustomEditor(typeof(SpineAtlasAsset)), CanEditMultipleObjects]
|
||||
public class SpineAtlasAssetInspector : UnityEditor.Editor {
|
||||
SerializedProperty atlasFile, materials;
|
||||
SpineAtlasAsset atlasAsset;
|
||||
|
||||
GUIContent spriteSlicesLabel;
|
||||
GUIContent SpriteSlicesLabel {
|
||||
get {
|
||||
if (spriteSlicesLabel == null) {
|
||||
spriteSlicesLabel = new GUIContent(
|
||||
"Apply Regions as Texture Sprite Slices",
|
||||
SpineEditorUtilities.Icons.unity,
|
||||
"Adds Sprite slices to atlas texture(s). " +
|
||||
"Updates existing slices if ones with matching names exist. \n\n" +
|
||||
"If your atlas was exported with Premultiply Alpha, " +
|
||||
"your SpriteRenderer should use the generated Spine _Material asset (or any Material with a PMA shader) instead of Sprites-Default.");
|
||||
}
|
||||
return spriteSlicesLabel;
|
||||
}
|
||||
}
|
||||
|
||||
static List<AtlasRegion> GetRegions (Atlas atlas) {
|
||||
FieldInfo regionsField = SpineInspectorUtility.GetNonPublicField(typeof(Atlas), "regions");
|
||||
return (List<AtlasRegion>)regionsField.GetValue(atlas);
|
||||
}
|
||||
|
||||
void OnEnable () {
|
||||
SpineEditorUtilities.ConfirmInitialization();
|
||||
atlasFile = serializedObject.FindProperty("atlasFile");
|
||||
materials = serializedObject.FindProperty("materials");
|
||||
materials.isExpanded = true;
|
||||
atlasAsset = (SpineAtlasAsset)target;
|
||||
#if REGION_BAKING_MESH
|
||||
UpdateBakedList();
|
||||
#endif
|
||||
}
|
||||
|
||||
#if REGION_BAKING_MESH
|
||||
private List<bool> baked;
|
||||
private List<GameObject> bakedObjects;
|
||||
|
||||
void UpdateBakedList () {
|
||||
AtlasAsset asset = (AtlasAsset)target;
|
||||
baked = new List<bool>();
|
||||
bakedObjects = new List<GameObject>();
|
||||
if (atlasFile.objectReferenceValue != null) {
|
||||
List<AtlasRegion> regions = this.Regions;
|
||||
string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset);
|
||||
string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath);
|
||||
string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name);
|
||||
for (int i = 0; i < regions.Count; i++) {
|
||||
AtlasRegion region = regions[i];
|
||||
string bakedPrefabPath = Path.Combine(bakedDirPath, AssetUtility.GetPathSafeRegionName(region) + ".prefab").Replace("\\", "/");
|
||||
GameObject prefab = (GameObject)AssetDatabase.LoadAssetAtPath(bakedPrefabPath, typeof(GameObject));
|
||||
baked.Add(prefab != null);
|
||||
bakedObjects.Add(prefab);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
override public void OnInspectorGUI () {
|
||||
if (serializedObject.isEditingMultipleObjects) {
|
||||
DrawDefaultInspector();
|
||||
return;
|
||||
}
|
||||
|
||||
serializedObject.Update();
|
||||
atlasAsset = (atlasAsset == null) ? (SpineAtlasAsset)target : atlasAsset;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(atlasFile);
|
||||
EditorGUILayout.PropertyField(materials, true);
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
atlasAsset.Clear();
|
||||
atlasAsset.GetAtlas();
|
||||
}
|
||||
|
||||
if (materials.arraySize == 0) {
|
||||
EditorGUILayout.HelpBox("No materials", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < materials.arraySize; i++) {
|
||||
SerializedProperty prop = materials.GetArrayElementAtIndex(i);
|
||||
var material = (Material)prop.objectReferenceValue;
|
||||
if (material == null) {
|
||||
EditorGUILayout.HelpBox("Materials cannot be null.", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
if (SpineInspectorUtility.LargeCenteredButton(SpineInspectorUtility.TempContent("Set Mipmap Bias to " + SpinePreferences.DEFAULT_MIPMAPBIAS, tooltip: "This may help textures with mipmaps be less blurry when used for 2D sprites."))) {
|
||||
foreach (var m in atlasAsset.materials) {
|
||||
var texture = m.mainTexture;
|
||||
string texturePath = AssetDatabase.GetAssetPath(texture.GetInstanceID());
|
||||
var importer = (TextureImporter)TextureImporter.GetAtPath(texturePath);
|
||||
importer.mipMapBias = SpinePreferences.DEFAULT_MIPMAPBIAS;
|
||||
EditorUtility.SetDirty(texture);
|
||||
}
|
||||
Debug.Log("Texture mipmap bias set to " + SpinePreferences.DEFAULT_MIPMAPBIAS);
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
if (atlasFile.objectReferenceValue != null) {
|
||||
if (SpineInspectorUtility.LargeCenteredButton(SpriteSlicesLabel)) {
|
||||
var atlas = atlasAsset.GetAtlas();
|
||||
foreach (var m in atlasAsset.materials)
|
||||
UpdateSpriteSlices(m.mainTexture, atlas);
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
#if REGION_BAKING_MESH
|
||||
if (atlasFile.objectReferenceValue != null) {
|
||||
Atlas atlas = asset.GetAtlas();
|
||||
FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.NonPublic);
|
||||
List<AtlasRegion> regions = (List<AtlasRegion>)field.GetValue(atlas);
|
||||
EditorGUILayout.LabelField(new GUIContent("Region Baking", SpineEditorUtilities.Icons.unityIcon));
|
||||
EditorGUI.indentLevel++;
|
||||
AtlasPage lastPage = null;
|
||||
for (int i = 0; i < regions.Count; i++) {
|
||||
if (lastPage != regions[i].page) {
|
||||
if (lastPage != null) {
|
||||
EditorGUILayout.Separator();
|
||||
EditorGUILayout.Separator();
|
||||
}
|
||||
lastPage = regions[i].page;
|
||||
Material mat = ((Material)lastPage.rendererObject);
|
||||
if (mat != null) {
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
EditorGUI.BeginDisabledGroup(true);
|
||||
EditorGUILayout.ObjectField(mat, typeof(Material), false, GUILayout.Width(250));
|
||||
EditorGUI.EndDisabledGroup();
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
|
||||
} else {
|
||||
EditorGUILayout.LabelField(new GUIContent("Page missing material!", SpineEditorUtilities.Icons.warning));
|
||||
}
|
||||
}
|
||||
GUILayout.BeginHorizontal();
|
||||
{
|
||||
//EditorGUILayout.ToggleLeft(baked[i] ? "" : regions[i].name, baked[i]);
|
||||
bool result = baked[i] ? EditorGUILayout.ToggleLeft("", baked[i], GUILayout.Width(24)) : EditorGUILayout.ToggleLeft(" " + regions[i].name, baked[i]);
|
||||
if(baked[i]){
|
||||
EditorGUILayout.ObjectField(bakedObjects[i], typeof(GameObject), false, GUILayout.Width(250));
|
||||
}
|
||||
if (result && !baked[i]) {
|
||||
//bake
|
||||
baked[i] = true;
|
||||
bakedObjects[i] = SpineEditorUtilities.BakeRegion(atlasAsset, regions[i]);
|
||||
EditorGUIUtility.PingObject(bakedObjects[i]);
|
||||
} else if (!result && baked[i]) {
|
||||
//unbake
|
||||
bool unbakeResult = EditorUtility.DisplayDialog("Delete Baked Region", "Do you want to delete the prefab for " + regions[i].name, "Yes", "Cancel");
|
||||
switch (unbakeResult) {
|
||||
case true:
|
||||
//delete
|
||||
string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset);
|
||||
string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath);
|
||||
string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name);
|
||||
string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.GetPathSafeRegionName(regions[i]) + ".prefab").Replace("\\", "/");
|
||||
AssetDatabase.DeleteAsset(bakedPrefabPath);
|
||||
baked[i] = false;
|
||||
break;
|
||||
case false:
|
||||
//do nothing
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
EditorGUI.indentLevel--;
|
||||
|
||||
#if BAKE_ALL_BUTTON
|
||||
// Check state
|
||||
bool allBaked = true;
|
||||
bool allUnbaked = true;
|
||||
for (int i = 0; i < regions.Count; i++) {
|
||||
allBaked &= baked[i];
|
||||
allUnbaked &= !baked[i];
|
||||
}
|
||||
|
||||
if (!allBaked && GUILayout.Button("Bake All")) {
|
||||
for (int i = 0; i < regions.Count; i++) {
|
||||
if (!baked[i]) {
|
||||
baked[i] = true;
|
||||
bakedObjects[i] = SpineEditorUtilities.BakeRegion(atlasAsset, regions[i]);
|
||||
}
|
||||
}
|
||||
|
||||
} else if (!allUnbaked && GUILayout.Button("Unbake All")) {
|
||||
bool unbakeResult = EditorUtility.DisplayDialog("Delete All Baked Regions", "Are you sure you want to unbake all region prefabs? This cannot be undone.", "Yes", "Cancel");
|
||||
switch (unbakeResult) {
|
||||
case true:
|
||||
//delete
|
||||
for (int i = 0; i < regions.Count; i++) {
|
||||
if (baked[i]) {
|
||||
string atlasAssetPath = AssetDatabase.GetAssetPath(atlasAsset);
|
||||
string atlasAssetDirPath = Path.GetDirectoryName(atlasAssetPath);
|
||||
string bakedDirPath = Path.Combine(atlasAssetDirPath, atlasAsset.name);
|
||||
string bakedPrefabPath = Path.Combine(bakedDirPath, SpineEditorUtilities.GetPathSafeRegionName(regions[i]) + ".prefab").Replace("\\", "/");
|
||||
AssetDatabase.DeleteAsset(bakedPrefabPath);
|
||||
baked[i] = false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case false:
|
||||
//do nothing
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
#else
|
||||
if (atlasFile.objectReferenceValue != null) {
|
||||
|
||||
|
||||
int baseIndent = EditorGUI.indentLevel;
|
||||
|
||||
var regions = SpineAtlasAssetInspector.GetRegions(atlasAsset.GetAtlas());
|
||||
int regionsCount = regions.Count;
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
EditorGUILayout.LabelField("Atlas Regions", EditorStyles.boldLabel);
|
||||
EditorGUILayout.LabelField(string.Format("{0} regions total", regionsCount));
|
||||
}
|
||||
AtlasPage lastPage = null;
|
||||
for (int i = 0; i < regionsCount; i++) {
|
||||
if (lastPage != regions[i].page) {
|
||||
if (lastPage != null) {
|
||||
EditorGUILayout.Separator();
|
||||
EditorGUILayout.Separator();
|
||||
}
|
||||
lastPage = regions[i].page;
|
||||
Material mat = ((Material)lastPage.rendererObject);
|
||||
if (mat != null) {
|
||||
EditorGUI.indentLevel = baseIndent;
|
||||
using (new GUILayout.HorizontalScope())
|
||||
using (new EditorGUI.DisabledGroupScope(true))
|
||||
EditorGUILayout.ObjectField(mat, typeof(Material), false, GUILayout.Width(250));
|
||||
EditorGUI.indentLevel = baseIndent + 1;
|
||||
} else {
|
||||
EditorGUILayout.HelpBox("Page missing material!", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
string regionName = regions[i].name;
|
||||
Texture2D icon = SpineEditorUtilities.Icons.image;
|
||||
if (regionName.EndsWith(" ")) {
|
||||
regionName = string.Format("'{0}'", regions[i].name);
|
||||
icon = SpineEditorUtilities.Icons.warning;
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent(regionName, icon, "Region name ends with whitespace. This may cause errors. Please check your source image filenames."));
|
||||
} else {
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent(regionName, icon));
|
||||
}
|
||||
|
||||
}
|
||||
EditorGUI.indentLevel = baseIndent;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (serializedObject.ApplyModifiedProperties() || SpineInspectorUtility.UndoRedoPerformed(Event.current))
|
||||
atlasAsset.Clear();
|
||||
}
|
||||
|
||||
static public void UpdateSpriteSlices (Texture texture, Atlas atlas) {
|
||||
string texturePath = AssetDatabase.GetAssetPath(texture.GetInstanceID());
|
||||
var t = (TextureImporter)TextureImporter.GetAtPath(texturePath);
|
||||
t.spriteImportMode = SpriteImportMode.Multiple;
|
||||
var spriteSheet = t.spritesheet;
|
||||
var sprites = new List<SpriteMetaData>(spriteSheet);
|
||||
|
||||
var regions = SpineAtlasAssetInspector.GetRegions(atlas);
|
||||
char[] FilenameDelimiter = {'.'};
|
||||
int updatedCount = 0;
|
||||
int addedCount = 0;
|
||||
|
||||
foreach (var r in regions) {
|
||||
string pageName = r.page.name.Split(FilenameDelimiter, StringSplitOptions.RemoveEmptyEntries)[0];
|
||||
string textureName = texture.name;
|
||||
bool pageMatch = string.Equals(pageName, textureName, StringComparison.Ordinal);
|
||||
|
||||
// if (pageMatch) {
|
||||
// int pw = r.page.width;
|
||||
// int ph = r.page.height;
|
||||
// bool mismatchSize = pw != texture.width || pw > t.maxTextureSize || ph != texture.height || ph > t.maxTextureSize;
|
||||
// if (mismatchSize)
|
||||
// Debug.LogWarningFormat("Size mismatch found.\nExpected atlas size is {0}x{1}. Texture Import Max Size of texture '{2}'({4}x{5}) is currently set to {3}.", pw, ph, texture.name, t.maxTextureSize, texture.width, texture.height);
|
||||
// }
|
||||
|
||||
int spriteIndex = pageMatch ? sprites.FindIndex(
|
||||
(s) => string.Equals(s.name, r.name, StringComparison.Ordinal)
|
||||
) : -1;
|
||||
bool spriteNameMatchExists = spriteIndex >= 0;
|
||||
|
||||
if (pageMatch) {
|
||||
Rect spriteRect = new Rect();
|
||||
|
||||
if (r.rotate) {
|
||||
spriteRect.width = r.height;
|
||||
spriteRect.height = r.width;
|
||||
} else {
|
||||
spriteRect.width = r.width;
|
||||
spriteRect.height = r.height;
|
||||
}
|
||||
spriteRect.x = r.x;
|
||||
spriteRect.y = r.page.height - spriteRect.height - r.y;
|
||||
|
||||
if (spriteNameMatchExists) {
|
||||
var s = sprites[spriteIndex];
|
||||
s.rect = spriteRect;
|
||||
sprites[spriteIndex] = s;
|
||||
updatedCount++;
|
||||
} else {
|
||||
sprites.Add(new SpriteMetaData {
|
||||
name = r.name,
|
||||
pivot = new Vector2(0.5f, 0.5f),
|
||||
rect = spriteRect
|
||||
});
|
||||
addedCount++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
t.spritesheet = sprites.ToArray();
|
||||
EditorUtility.SetDirty(t);
|
||||
AssetDatabase.ImportAsset(texturePath, ImportAssetOptions.ForceUpdate);
|
||||
EditorGUIUtility.PingObject(texture);
|
||||
Debug.Log(string.Format("Applied sprite slices to {2}. {0} added. {1} updated.", addedCount, updatedCount, texture.name));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ca9b3ce36d70a05408e3bdd5e92c7f64
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,153 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using Spine;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using Event = UnityEngine.Event;
|
||||
|
||||
[CustomEditor(typeof(SpineSpriteAtlasAsset)), CanEditMultipleObjects]
|
||||
public class SpineSpriteAtlasAssetInspector : UnityEditor.Editor {
|
||||
SerializedProperty atlasFile, materials;
|
||||
SpineSpriteAtlasAsset atlasAsset;
|
||||
|
||||
static List<AtlasRegion> GetRegions (Atlas atlas) {
|
||||
FieldInfo regionsField = SpineInspectorUtility.GetNonPublicField(typeof(Atlas), "regions");
|
||||
return (List<AtlasRegion>)regionsField.GetValue(atlas);
|
||||
}
|
||||
|
||||
void OnEnable () {
|
||||
SpineEditorUtilities.ConfirmInitialization();
|
||||
atlasFile = serializedObject.FindProperty("spriteAtlasFile");
|
||||
materials = serializedObject.FindProperty("materials");
|
||||
materials.isExpanded = true;
|
||||
atlasAsset = (SpineSpriteAtlasAsset)target;
|
||||
|
||||
if (!SpineSpriteAtlasAsset.AnySpriteAtlasNeedsRegionsLoaded())
|
||||
return;
|
||||
EditorApplication.update -= SpineSpriteAtlasAsset.UpdateWhenEditorPlayModeStarted;
|
||||
EditorApplication.update += SpineSpriteAtlasAsset.UpdateWhenEditorPlayModeStarted;
|
||||
}
|
||||
|
||||
void OnDisable () {
|
||||
EditorApplication.update -= SpineSpriteAtlasAsset.UpdateWhenEditorPlayModeStarted;
|
||||
}
|
||||
|
||||
override public void OnInspectorGUI () {
|
||||
if (serializedObject.isEditingMultipleObjects) {
|
||||
DrawDefaultInspector();
|
||||
return;
|
||||
}
|
||||
|
||||
serializedObject.Update();
|
||||
atlasAsset = (atlasAsset == null) ? (SpineSpriteAtlasAsset)target : atlasAsset;
|
||||
|
||||
if (atlasAsset.RegionsNeedLoading) {
|
||||
if (GUILayout.Button(SpineInspectorUtility.TempContent("Load regions by entering Play mode"), GUILayout.Height(20))) {
|
||||
EditorApplication.isPlaying = true;
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(atlasFile);
|
||||
EditorGUILayout.PropertyField(materials, true);
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
atlasAsset.Clear();
|
||||
atlasAsset.GetAtlas();
|
||||
atlasAsset.updateRegionsInPlayMode = true;
|
||||
}
|
||||
|
||||
if (materials.arraySize == 0) {
|
||||
EditorGUILayout.HelpBox("No materials", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < materials.arraySize; i++) {
|
||||
SerializedProperty prop = materials.GetArrayElementAtIndex(i);
|
||||
var material = (Material)prop.objectReferenceValue;
|
||||
if (material == null) {
|
||||
EditorGUILayout.HelpBox("Materials cannot be null.", MessageType.Error);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (atlasFile.objectReferenceValue != null) {
|
||||
int baseIndent = EditorGUI.indentLevel;
|
||||
|
||||
var regions = SpineSpriteAtlasAssetInspector.GetRegions(atlasAsset.GetAtlas());
|
||||
int regionsCount = regions.Count;
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
EditorGUILayout.LabelField("Atlas Regions", EditorStyles.boldLabel);
|
||||
EditorGUILayout.LabelField(string.Format("{0} regions total", regionsCount));
|
||||
}
|
||||
AtlasPage lastPage = null;
|
||||
for (int i = 0; i < regionsCount; i++) {
|
||||
if (lastPage != regions[i].page) {
|
||||
if (lastPage != null) {
|
||||
EditorGUILayout.Separator();
|
||||
EditorGUILayout.Separator();
|
||||
}
|
||||
lastPage = regions[i].page;
|
||||
Material mat = ((Material)lastPage.rendererObject);
|
||||
if (mat != null) {
|
||||
EditorGUI.indentLevel = baseIndent;
|
||||
using (new GUILayout.HorizontalScope())
|
||||
using (new EditorGUI.DisabledGroupScope(true))
|
||||
EditorGUILayout.ObjectField(mat, typeof(Material), false, GUILayout.Width(250));
|
||||
EditorGUI.indentLevel = baseIndent + 1;
|
||||
} else {
|
||||
EditorGUILayout.HelpBox("Page missing material!", MessageType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
string regionName = regions[i].name;
|
||||
Texture2D icon = SpineEditorUtilities.Icons.image;
|
||||
if (regionName.EndsWith(" ")) {
|
||||
regionName = string.Format("'{0}'", regions[i].name);
|
||||
icon = SpineEditorUtilities.Icons.warning;
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent(regionName, icon, "Region name ends with whitespace. This may cause errors. Please check your source image filenames."));
|
||||
} else {
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent(regionName, icon));
|
||||
}
|
||||
}
|
||||
EditorGUI.indentLevel = baseIndent;
|
||||
}
|
||||
|
||||
if (serializedObject.ApplyModifiedProperties() || SpineInspectorUtility.UndoRedoPerformed(Event.current))
|
||||
atlasAsset.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f063dc5ff6881db4a9ee2e059812cba2
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,390 +0,0 @@
|
||||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!181963792 &2655988077585873504
|
||||
Preset:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: StraightAlphaPreset
|
||||
m_TargetType:
|
||||
m_NativeTypeID: 1006
|
||||
m_ManagedTypePPtr: {fileID: 0}
|
||||
m_ManagedTypeFallback:
|
||||
m_Properties:
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_ExternalObjects.Array.size
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_MipMapMode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_EnableMipMap
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_sRGBTexture
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_LinearTexture
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_FadeOut
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_BorderMipMap
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_MipMapsPreserveCoverage
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_AlphaTestReferenceValue
|
||||
value: 0.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_MipMapFadeDistanceStart
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_MipMapFadeDistanceEnd
|
||||
value: 3
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_ConvertToNormalMap
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_ExternalNormalMap
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_HeightScale
|
||||
value: 0.25
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_NormalMapFilter
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_IsReadable
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_StreamingMipmaps
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_StreamingMipmapsPriority
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_GrayScaleToAlpha
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_GenerateCubemap
|
||||
value: 6
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_CubemapConvolution
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SeamlessCubemap
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_TextureFormat
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_MaxTextureSize
|
||||
value: 2048
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_TextureSettings.m_FilterMode
|
||||
value: -1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_TextureSettings.m_Aniso
|
||||
value: -1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_TextureSettings.m_MipBias
|
||||
value: -100
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_TextureSettings.m_WrapU
|
||||
value: -1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_TextureSettings.m_WrapV
|
||||
value: -1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_TextureSettings.m_WrapW
|
||||
value: -1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_NPOTScale
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_Lightmap
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_CompressionQuality
|
||||
value: 50
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteMode
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteExtrude
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteMeshType
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_Alignment
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpritePivot.x
|
||||
value: 0.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpritePivot.y
|
||||
value: 0.5
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpritePixelsToUnits
|
||||
value: 100
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteBorder.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteBorder.y
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteBorder.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteBorder.w
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteGenerateFallbackPhysicsShape
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_AlphaUsage
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_AlphaIsTransparency
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteTessellationDetail
|
||||
value: -1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_TextureType
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_TextureShape
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SingleChannelComponent
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_MaxTextureSizeSet
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_CompressionQualitySet
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_TextureFormatSet
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.size
|
||||
value: 2
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[0].m_BuildTarget
|
||||
value: DefaultTexturePlatform
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[0].m_MaxTextureSize
|
||||
value: 2048
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[0].m_ResizeAlgorithm
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[0].m_TextureFormat
|
||||
value: -1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[0].m_TextureCompression
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[0].m_CompressionQuality
|
||||
value: 50
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[0].m_CrunchedCompression
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[0].m_AllowsAlphaSplitting
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[0].m_Overridden
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[0].m_AndroidETC2FallbackOverride
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[0].m_ForceMaximumCompressionQuality_BC6H_BC7
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[1].m_BuildTarget
|
||||
value: Standalone
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[1].m_MaxTextureSize
|
||||
value: 2048
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[1].m_ResizeAlgorithm
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[1].m_TextureFormat
|
||||
value: -1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[1].m_TextureCompression
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[1].m_CompressionQuality
|
||||
value: 50
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[1].m_CrunchedCompression
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[1].m_AllowsAlphaSplitting
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[1].m_Overridden
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[1].m_AndroidETC2FallbackOverride
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PlatformSettings.Array.data[1].m_ForceMaximumCompressionQuality_BC6H_BC7
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteSheet.m_Sprites.Array.size
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteSheet.m_Outline.Array.size
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteSheet.m_PhysicsShape.Array.size
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteSheet.m_Bones.Array.size
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteSheet.m_SpriteID
|
||||
value:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteSheet.m_InternalID
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteSheet.m_Vertices.Array.size
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteSheet.m_Indices.Array.size
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteSheet.m_Edges.Array.size
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteSheet.m_Weights.Array.size
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpriteSheet.m_SecondaryTextures.Array.size
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_SpritePackingTag
|
||||
value:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PSDRemoveMatte
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_PSDShowRemoveMatteOption
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_UserData
|
||||
value:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_AssetBundleName
|
||||
value:
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 0}
|
||||
propertyPath: m_AssetBundleVariant
|
||||
value:
|
||||
objectReference: {fileID: 0}
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3fe5ce49a7c8c041a9d60e4f7f403de
|
||||
NativeFormatImporter:
|
||||
externalObjects: {}
|
||||
mainObjectFileID: 0
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 3.0 KiB |
@@ -1,82 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ade885c25e49d7740b5c00d4e10a6197
|
||||
timeCreated: 1580402818
|
||||
licenseType: Pro
|
||||
TextureImporter:
|
||||
fileIDToRecycleName: {}
|
||||
serializedVersion: 4
|
||||
mipmaps:
|
||||
mipMapMode: 0
|
||||
enableMipMap: 0
|
||||
sRGBTexture: 1
|
||||
linearTexture: 0
|
||||
fadeOut: 0
|
||||
borderMipMap: 0
|
||||
mipMapsPreserveCoverage: 0
|
||||
alphaTestReferenceValue: 0.5
|
||||
mipMapFadeDistanceStart: 1
|
||||
mipMapFadeDistanceEnd: 3
|
||||
bumpmap:
|
||||
convertToNormalMap: 0
|
||||
externalNormalMap: 0
|
||||
heightScale: 0.25
|
||||
normalMapFilter: 0
|
||||
isReadable: 0
|
||||
grayScaleToAlpha: 0
|
||||
generateCubemap: 6
|
||||
cubemapConvolution: 0
|
||||
seamlessCubemap: 0
|
||||
textureFormat: 1
|
||||
maxTextureSize: 2048
|
||||
textureSettings:
|
||||
serializedVersion: 2
|
||||
filterMode: -1
|
||||
aniso: -1
|
||||
mipBias: -1
|
||||
wrapU: -1
|
||||
wrapV: -1
|
||||
wrapW: -1
|
||||
nPOTScale: 1
|
||||
lightmap: 0
|
||||
compressionQuality: 50
|
||||
spriteMode: 0
|
||||
spriteExtrude: 1
|
||||
spriteMeshType: 1
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spritePixelsToUnits: 100
|
||||
alphaUsage: 1
|
||||
alphaIsTransparency: 1
|
||||
spriteTessellationDetail: -1
|
||||
textureType: 0
|
||||
textureShape: 1
|
||||
maxTextureSizeSet: 0
|
||||
compressionQualitySet: 0
|
||||
textureFormatSet: 0
|
||||
platformSettings:
|
||||
- buildTarget: DefaultTexturePlatform
|
||||
maxTextureSize: 2048
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
- buildTarget: Standalone
|
||||
maxTextureSize: 2048
|
||||
textureFormat: -1
|
||||
textureCompression: 0
|
||||
compressionQuality: 50
|
||||
crunchedCompression: 0
|
||||
allowsAlphaSplitting: 0
|
||||
overridden: 0
|
||||
spriteSheet:
|
||||
serializedVersion: 2
|
||||
sprites: []
|
||||
outline: []
|
||||
physicsShape: []
|
||||
spritePackingTag:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1 +0,0 @@
|
||||
DO NOT MOVE OR DELETE THIS FILE
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 57281c00bdd90ad4392f811f2b9f0da1
|
||||
timeCreated: 1444565392
|
||||
licenseType: Pro
|
||||
TextScriptImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,226 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using Spine.Unity;
|
||||
|
||||
using SpineInspectorUtility = Spine.Unity.Editor.SpineInspectorUtility;
|
||||
|
||||
public class SpineShaderWithOutlineGUI : ShaderGUI {
|
||||
|
||||
protected MaterialEditor _materialEditor;
|
||||
bool _showAdvancedOutlineSettings = false;
|
||||
bool _showStencilSettings = false;
|
||||
|
||||
MaterialProperty _OutlineWidth = null;
|
||||
MaterialProperty _OutlineColor = null;
|
||||
MaterialProperty _OutlineReferenceTexWidth = null;
|
||||
MaterialProperty _ThresholdEnd = null;
|
||||
MaterialProperty _OutlineSmoothness = null;
|
||||
MaterialProperty _Use8Neighbourhood = null;
|
||||
MaterialProperty _OutlineMipLevel = null;
|
||||
MaterialProperty _StencilComp = null;
|
||||
MaterialProperty _StencilRef = null;
|
||||
|
||||
static GUIContent _EnableOutlineText = new GUIContent("Outline", "Enable outline rendering. Draws an outline by sampling 4 or 8 neighbourhood pixels at a given distance specified via 'Outline Width'.");
|
||||
static GUIContent _OutlineWidthText = new GUIContent("Outline Width", "");
|
||||
static GUIContent _OutlineColorText = new GUIContent("Outline Color", "");
|
||||
static GUIContent _OutlineReferenceTexWidthText = new GUIContent("Reference Texture Width", "");
|
||||
static GUIContent _ThresholdEndText = new GUIContent("Outline Threshold", "");
|
||||
static GUIContent _OutlineSmoothnessText = new GUIContent("Outline Smoothness", "");
|
||||
static GUIContent _Use8NeighbourhoodText = new GUIContent("Sample 8 Neighbours", "");
|
||||
static GUIContent _OutlineMipLevelText = new GUIContent("Outline Mip Level", "");
|
||||
static GUIContent _StencilCompText = new GUIContent("Stencil Comparison", "");
|
||||
static GUIContent _StencilRefText = new GUIContent("Stencil Reference", "");
|
||||
|
||||
static GUIContent _OutlineAdvancedText = new GUIContent("Advanced", "");
|
||||
static GUIContent _ShowStencilText = new GUIContent("Stencil", "Stencil parameters for mask interaction.");
|
||||
|
||||
protected const string ShaderOutlineNamePrefix = "Spine/Outline/";
|
||||
protected const string ShaderNormalNamePrefix = "Spine/";
|
||||
protected const string ShaderWithoutStandardVariantSuffix = "OutlineOnly";
|
||||
|
||||
#region ShaderGUI
|
||||
|
||||
public override void OnGUI (MaterialEditor materialEditor, MaterialProperty[] properties) {
|
||||
FindProperties(properties); // MaterialProperties can be animated so we do not cache them but fetch them every event to ensure animated values are updated correctly
|
||||
_materialEditor = materialEditor;
|
||||
|
||||
base.OnGUI(materialEditor, properties);
|
||||
EditorGUILayout.Space();
|
||||
RenderStencilProperties();
|
||||
EditorGUILayout.Space();
|
||||
RenderOutlineProperties();
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Virtual Interface
|
||||
|
||||
protected virtual void FindProperties (MaterialProperty[] props) {
|
||||
|
||||
_OutlineWidth = FindProperty("_OutlineWidth", props, false);
|
||||
_OutlineReferenceTexWidth = FindProperty("_OutlineReferenceTexWidth", props, false);
|
||||
_OutlineColor = FindProperty("_OutlineColor", props, false);
|
||||
_ThresholdEnd = FindProperty("_ThresholdEnd", props, false);
|
||||
_OutlineSmoothness = FindProperty("_OutlineSmoothness", props, false);
|
||||
_Use8Neighbourhood = FindProperty("_Use8Neighbourhood", props, false);
|
||||
_OutlineMipLevel = FindProperty("_OutlineMipLevel", props, false);
|
||||
|
||||
_StencilComp = FindProperty("_StencilComp", props, false);
|
||||
_StencilRef = FindProperty("_StencilRef", props, false);
|
||||
if (_StencilRef == null)
|
||||
_StencilRef = FindProperty("_Stencil", props, false);
|
||||
}
|
||||
|
||||
protected virtual void RenderStencilProperties () {
|
||||
if (_StencilComp == null)
|
||||
return; // not a shader supporting custom stencil operations
|
||||
|
||||
// Use default labelWidth
|
||||
EditorGUIUtility.labelWidth = 0f;
|
||||
_showStencilSettings = EditorGUILayout.Foldout(_showStencilSettings, _ShowStencilText);
|
||||
if (_showStencilSettings) {
|
||||
using (new SpineInspectorUtility.IndentScope()) {
|
||||
_materialEditor.ShaderProperty(_StencilComp, _StencilCompText);
|
||||
_materialEditor.ShaderProperty(_StencilRef, _StencilRefText);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void RenderOutlineProperties () {
|
||||
|
||||
if (_OutlineWidth == null)
|
||||
return; // not an outline shader
|
||||
|
||||
// Use default labelWidth
|
||||
EditorGUIUtility.labelWidth = 0f;
|
||||
|
||||
bool mixedValue;
|
||||
bool hasOutlineVariant = !IsShaderWithoutStandardVariantShader(_materialEditor, out mixedValue);
|
||||
bool isOutlineEnabled = true;
|
||||
if (hasOutlineVariant) {
|
||||
isOutlineEnabled = IsOutlineEnabled(_materialEditor, out mixedValue);
|
||||
EditorGUI.showMixedValue = mixedValue;
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
var origFontStyle = EditorStyles.label.fontStyle;
|
||||
EditorStyles.label.fontStyle = FontStyle.Bold;
|
||||
isOutlineEnabled = EditorGUILayout.Toggle(_EnableOutlineText, isOutlineEnabled);
|
||||
EditorStyles.label.fontStyle = origFontStyle;
|
||||
EditorGUI.showMixedValue = false;
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
foreach (Material material in _materialEditor.targets) {
|
||||
SwitchShaderToOutlineSettings(material, isOutlineEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
var origFontStyle = EditorStyles.label.fontStyle;
|
||||
EditorStyles.label.fontStyle = FontStyle.Bold;
|
||||
EditorGUILayout.LabelField(_EnableOutlineText);
|
||||
EditorStyles.label.fontStyle = origFontStyle;
|
||||
}
|
||||
|
||||
if (isOutlineEnabled) {
|
||||
_materialEditor.ShaderProperty(_OutlineWidth, _OutlineWidthText);
|
||||
_materialEditor.ShaderProperty(_OutlineColor, _OutlineColorText);
|
||||
|
||||
_showAdvancedOutlineSettings = EditorGUILayout.Foldout(_showAdvancedOutlineSettings, _OutlineAdvancedText);
|
||||
if (_showAdvancedOutlineSettings) {
|
||||
using (new SpineInspectorUtility.IndentScope()) {
|
||||
_materialEditor.ShaderProperty(_OutlineReferenceTexWidth, _OutlineReferenceTexWidthText);
|
||||
_materialEditor.ShaderProperty(_ThresholdEnd, _ThresholdEndText);
|
||||
_materialEditor.ShaderProperty(_OutlineSmoothness, _OutlineSmoothnessText);
|
||||
_materialEditor.ShaderProperty(_Use8Neighbourhood, _Use8NeighbourhoodText);
|
||||
_materialEditor.ShaderProperty(_OutlineMipLevel, _OutlineMipLevelText);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Private Functions
|
||||
|
||||
void SwitchShaderToOutlineSettings (Material material, bool enableOutline) {
|
||||
|
||||
var shaderName = material.shader.name;
|
||||
bool isSetToOutlineShader = shaderName.Contains(ShaderOutlineNamePrefix);
|
||||
if (isSetToOutlineShader && !enableOutline) {
|
||||
shaderName = shaderName.Replace(ShaderOutlineNamePrefix, ShaderNormalNamePrefix);
|
||||
_materialEditor.SetShader(Shader.Find(shaderName), false);
|
||||
return;
|
||||
}
|
||||
else if (!isSetToOutlineShader && enableOutline) {
|
||||
shaderName = shaderName.Replace(ShaderNormalNamePrefix, ShaderOutlineNamePrefix);
|
||||
_materialEditor.SetShader(Shader.Find(shaderName), false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
static bool IsOutlineEnabled (MaterialEditor editor, out bool mixedValue) {
|
||||
mixedValue = false;
|
||||
bool isAnyEnabled = false;
|
||||
foreach (Material material in editor.targets) {
|
||||
if (material.shader.name.Contains(ShaderOutlineNamePrefix)) {
|
||||
isAnyEnabled = true;
|
||||
}
|
||||
else if (isAnyEnabled) {
|
||||
mixedValue = true;
|
||||
}
|
||||
}
|
||||
return isAnyEnabled;
|
||||
}
|
||||
|
||||
static bool IsShaderWithoutStandardVariantShader (MaterialEditor editor, out bool mixedValue) {
|
||||
mixedValue = false;
|
||||
bool isAnyShaderWithoutVariant = false;
|
||||
foreach (Material material in editor.targets) {
|
||||
if (material.shader.name.Contains(ShaderWithoutStandardVariantSuffix)) {
|
||||
isAnyShaderWithoutVariant = true;
|
||||
}
|
||||
else if (isAnyShaderWithoutVariant) {
|
||||
mixedValue = true;
|
||||
}
|
||||
}
|
||||
return isAnyShaderWithoutVariant;
|
||||
}
|
||||
|
||||
static bool BoldToggleField (GUIContent label, bool value) {
|
||||
FontStyle origFontStyle = EditorStyles.label.fontStyle;
|
||||
EditorStyles.label.fontStyle = FontStyle.Bold;
|
||||
value = EditorGUILayout.Toggle(label, value, EditorStyles.toggle);
|
||||
EditorStyles.label.fontStyle = origFontStyle;
|
||||
return value;
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: efbbf90926e217c40831926fce374905
|
||||
timeCreated: 1573666328
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: aef90b4c481362e42891bb46de344c1c
|
||||
timeCreated: 1479458475
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,602 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
// Contributed by: Mitch Thompson
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Spine;
|
||||
using System.Linq;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
public struct SpineDrawerValuePair {
|
||||
public string stringValue;
|
||||
public SerializedProperty property;
|
||||
|
||||
public SpineDrawerValuePair (string val, SerializedProperty property) {
|
||||
this.stringValue = val;
|
||||
this.property = property;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class SpineTreeItemDrawerBase<T> : PropertyDrawer where T:SpineAttributeBase {
|
||||
protected SkeletonDataAsset skeletonDataAsset;
|
||||
internal const string NoneStringConstant = "<None>";
|
||||
|
||||
internal virtual string NoneString { get { return NoneStringConstant; } }
|
||||
|
||||
GUIContent noneLabel;
|
||||
GUIContent NoneLabel (Texture2D image = null) {
|
||||
if (noneLabel == null) noneLabel = new GUIContent(NoneString);
|
||||
noneLabel.image = image;
|
||||
return noneLabel;
|
||||
}
|
||||
|
||||
protected T TargetAttribute { get { return (T)attribute; } }
|
||||
protected SerializedProperty SerializedProperty { get; private set; }
|
||||
|
||||
protected abstract Texture2D Icon { get; }
|
||||
|
||||
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) {
|
||||
SerializedProperty = property;
|
||||
|
||||
if (property.propertyType != SerializedPropertyType.String) {
|
||||
EditorGUI.LabelField(position, "ERROR:", "May only apply to type string");
|
||||
return;
|
||||
}
|
||||
|
||||
// Handle multi-editing when instances don't use the same SkeletonDataAsset.
|
||||
if (!SpineInspectorUtility.TargetsUseSameData(property.serializedObject)) {
|
||||
EditorGUI.DelayedTextField(position, property, label);
|
||||
return;
|
||||
}
|
||||
|
||||
SerializedProperty dataField = property.FindBaseOrSiblingProperty(TargetAttribute.dataField);
|
||||
|
||||
if (dataField != null) {
|
||||
var objectReferenceValue = dataField.objectReferenceValue;
|
||||
if (objectReferenceValue is SkeletonDataAsset) {
|
||||
skeletonDataAsset = (SkeletonDataAsset)objectReferenceValue;
|
||||
} else if (objectReferenceValue is IHasSkeletonDataAsset) {
|
||||
var hasSkeletonDataAsset = (IHasSkeletonDataAsset)objectReferenceValue;
|
||||
if (hasSkeletonDataAsset != null)
|
||||
skeletonDataAsset = hasSkeletonDataAsset.SkeletonDataAsset;
|
||||
} else if (objectReferenceValue != null) {
|
||||
EditorGUI.LabelField(position, "ERROR:", "Invalid reference type");
|
||||
return;
|
||||
}
|
||||
|
||||
} else {
|
||||
var targetObject = property.serializedObject.targetObject;
|
||||
|
||||
IHasSkeletonDataAsset hasSkeletonDataAsset = targetObject as IHasSkeletonDataAsset;
|
||||
if (hasSkeletonDataAsset == null) {
|
||||
var component = targetObject as Component;
|
||||
if (component != null)
|
||||
hasSkeletonDataAsset = component.GetComponentInChildren(typeof(IHasSkeletonDataAsset)) as IHasSkeletonDataAsset;
|
||||
}
|
||||
|
||||
if (hasSkeletonDataAsset != null)
|
||||
skeletonDataAsset = hasSkeletonDataAsset.SkeletonDataAsset;
|
||||
}
|
||||
|
||||
if (skeletonDataAsset == null) {
|
||||
if (TargetAttribute.fallbackToTextField) {
|
||||
EditorGUI.PropertyField(position, property); //EditorGUI.TextField(position, label, property.stringValue);
|
||||
} else {
|
||||
EditorGUI.LabelField(position, "ERROR:", "Must have reference to a SkeletonDataAsset");
|
||||
}
|
||||
|
||||
skeletonDataAsset = property.serializedObject.targetObject as SkeletonDataAsset;
|
||||
if (skeletonDataAsset == null) return;
|
||||
}
|
||||
|
||||
position = EditorGUI.PrefixLabel(position, label);
|
||||
|
||||
Texture2D image = Icon;
|
||||
string propertyStringValue = (property.hasMultipleDifferentValues) ? SpineInspectorUtility.EmDash : property.stringValue;
|
||||
if (GUI.Button(position, string.IsNullOrEmpty(propertyStringValue) ? NoneLabel(image) : SpineInspectorUtility.TempContent(propertyStringValue, image), EditorStyles.popup))
|
||||
Selector(property);
|
||||
}
|
||||
|
||||
public ISkeletonComponent GetTargetSkeletonComponent (SerializedProperty property) {
|
||||
var dataField = property.FindBaseOrSiblingProperty(TargetAttribute.dataField);
|
||||
|
||||
if (dataField != null) {
|
||||
var skeletonComponent = dataField.objectReferenceValue as ISkeletonComponent;
|
||||
if (dataField.objectReferenceValue != null && skeletonComponent != null) // note the overloaded UnityEngine.Object == null check. Do not simplify.
|
||||
return skeletonComponent;
|
||||
} else {
|
||||
var component = property.serializedObject.targetObject as Component;
|
||||
if (component != null)
|
||||
return component.GetComponentInChildren(typeof(ISkeletonComponent)) as ISkeletonComponent;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected virtual void Selector (SerializedProperty property) {
|
||||
SkeletonData data = skeletonDataAsset.GetSkeletonData(true);
|
||||
if (data == null) return;
|
||||
|
||||
var menu = new GenericMenu();
|
||||
PopulateMenu(menu, property, this.TargetAttribute, data);
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
|
||||
protected abstract void PopulateMenu (GenericMenu menu, SerializedProperty property, T targetAttribute, SkeletonData data);
|
||||
|
||||
protected virtual void HandleSelect (object menuItemObject) {
|
||||
var clickedItem = (SpineDrawerValuePair)menuItemObject;
|
||||
var serializedProperty = clickedItem.property;
|
||||
if (serializedProperty.serializedObject.isEditingMultipleObjects) serializedProperty.stringValue = "oaifnoiasf<73><66>123526"; // HACK: to trigger change on multi-editing.
|
||||
serializedProperty.stringValue = clickedItem.stringValue;
|
||||
serializedProperty.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight (SerializedProperty property, GUIContent label) {
|
||||
return 18;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(SpineSlot))]
|
||||
public class SpineSlotDrawer : SpineTreeItemDrawerBase<SpineSlot> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.slot; } }
|
||||
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineSlot targetAttribute, SkeletonData data) {
|
||||
if (TargetAttribute.includeNone)
|
||||
menu.AddItem(new GUIContent(NoneString), !property.hasMultipleDifferentValues && string.IsNullOrEmpty(property.stringValue), HandleSelect, new SpineDrawerValuePair(string.Empty, property));
|
||||
|
||||
IEnumerable<SlotData> orderedSlots = data.Slots.Items.OrderBy(slotData => slotData.Name);
|
||||
foreach (SlotData slotData in orderedSlots) {
|
||||
int slotIndex = slotData.Index;
|
||||
string name = slotData.Name;
|
||||
if (name.StartsWith(targetAttribute.startsWith, StringComparison.Ordinal)) {
|
||||
|
||||
if (targetAttribute.containsBoundingBoxes) {
|
||||
var skinEntries = new List<Skin.SkinEntry>();
|
||||
foreach (var skin in data.Skins) {
|
||||
skin.GetAttachments(slotIndex, skinEntries);
|
||||
}
|
||||
|
||||
bool hasBoundingBox = false;
|
||||
foreach (var entry in skinEntries) {
|
||||
var bbAttachment = entry.Attachment as BoundingBoxAttachment;
|
||||
if (bbAttachment != null) {
|
||||
string menuLabel = bbAttachment.IsWeighted() ? name + " (!)" : name;
|
||||
menu.AddItem(new GUIContent(menuLabel), !property.hasMultipleDifferentValues && name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
||||
hasBoundingBox = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasBoundingBox)
|
||||
menu.AddDisabledItem(new GUIContent(name));
|
||||
|
||||
} else {
|
||||
menu.AddItem(new GUIContent(name), !property.hasMultipleDifferentValues && name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(SpineSkin))]
|
||||
public class SpineSkinDrawer : SpineTreeItemDrawerBase<SpineSkin> {
|
||||
const string DefaultSkinName = "default";
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.skin; } }
|
||||
|
||||
internal override string NoneString { get { return TargetAttribute.defaultAsEmptyString ? DefaultSkinName : NoneStringConstant; } }
|
||||
|
||||
public static void GetSkinMenuItems (SkeletonData data, List<string> outputNames, List<GUIContent> outputMenuItems, bool includeNone = true) {
|
||||
if (data == null) return;
|
||||
if (outputNames == null) return;
|
||||
if (outputMenuItems == null) return;
|
||||
|
||||
var skins = data.Skins;
|
||||
|
||||
outputNames.Clear();
|
||||
outputMenuItems.Clear();
|
||||
|
||||
var icon = SpineEditorUtilities.Icons.skin;
|
||||
|
||||
if (includeNone) {
|
||||
outputNames.Add("");
|
||||
outputMenuItems.Add(new GUIContent(NoneStringConstant, icon));
|
||||
}
|
||||
|
||||
foreach (var s in skins) {
|
||||
string skinName = s.Name;
|
||||
outputNames.Add(skinName);
|
||||
outputMenuItems.Add(new GUIContent(skinName, icon));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineSkin targetAttribute, SkeletonData data) {
|
||||
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
||||
menu.AddSeparator("");
|
||||
|
||||
for (int i = 0; i < data.Skins.Count; i++) {
|
||||
string name = data.Skins.Items[i].Name;
|
||||
if (name.StartsWith(targetAttribute.startsWith, StringComparison.Ordinal)) {
|
||||
bool isDefault = string.Equals(name, DefaultSkinName, StringComparison.Ordinal);
|
||||
string choiceValue = TargetAttribute.defaultAsEmptyString && isDefault ? string.Empty : name;
|
||||
menu.AddItem(new GUIContent(name), !property.hasMultipleDifferentValues && choiceValue == property.stringValue, HandleSelect, new SpineDrawerValuePair(choiceValue, property));
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(SpineAnimation))]
|
||||
public class SpineAnimationDrawer : SpineTreeItemDrawerBase<SpineAnimation> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.animation; } }
|
||||
|
||||
public static void GetAnimationMenuItems (SkeletonData data, List<string> outputNames, List<GUIContent> outputMenuItems, bool includeNone = true) {
|
||||
if (data == null) return;
|
||||
if (outputNames == null) return;
|
||||
if (outputMenuItems == null) return;
|
||||
|
||||
var animations = data.Animations;
|
||||
|
||||
outputNames.Clear();
|
||||
outputMenuItems.Clear();
|
||||
|
||||
if (includeNone) {
|
||||
outputNames.Add("");
|
||||
outputMenuItems.Add(new GUIContent(NoneStringConstant, SpineEditorUtilities.Icons.animation));
|
||||
}
|
||||
|
||||
foreach (var a in animations) {
|
||||
string animationName = a.Name;
|
||||
outputNames.Add(animationName);
|
||||
outputMenuItems.Add(new GUIContent(animationName, SpineEditorUtilities.Icons.animation));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineAnimation targetAttribute, SkeletonData data) {
|
||||
var animations = skeletonDataAsset.GetAnimationStateData().SkeletonData.Animations;
|
||||
|
||||
if (TargetAttribute.includeNone)
|
||||
menu.AddItem(new GUIContent(NoneString), !property.hasMultipleDifferentValues && string.IsNullOrEmpty(property.stringValue), HandleSelect, new SpineDrawerValuePair(string.Empty, property));
|
||||
|
||||
for (int i = 0; i < animations.Count; i++) {
|
||||
string name = animations.Items[i].Name;
|
||||
if (name.StartsWith(targetAttribute.startsWith, StringComparison.Ordinal))
|
||||
menu.AddItem(new GUIContent(name), !property.hasMultipleDifferentValues && name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(SpineEvent))]
|
||||
public class SpineEventNameDrawer : SpineTreeItemDrawerBase<SpineEvent> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.userEvent; } }
|
||||
|
||||
public static void GetEventMenuItems (SkeletonData data, List<string> eventNames, List<GUIContent> menuItems, bool includeNone = true) {
|
||||
if (data == null) return;
|
||||
|
||||
var animations = data.Events;
|
||||
|
||||
eventNames.Clear();
|
||||
menuItems.Clear();
|
||||
|
||||
if (includeNone) {
|
||||
eventNames.Add("");
|
||||
menuItems.Add(new GUIContent(NoneStringConstant, SpineEditorUtilities.Icons.userEvent));
|
||||
}
|
||||
|
||||
foreach (var a in animations) {
|
||||
string animationName = a.Name;
|
||||
eventNames.Add(animationName);
|
||||
menuItems.Add(new GUIContent(animationName, SpineEditorUtilities.Icons.userEvent));
|
||||
}
|
||||
}
|
||||
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineEvent targetAttribute, SkeletonData data) {
|
||||
var events = skeletonDataAsset.GetSkeletonData(false).Events;
|
||||
|
||||
if (TargetAttribute.includeNone)
|
||||
menu.AddItem(new GUIContent(NoneString), !property.hasMultipleDifferentValues && string.IsNullOrEmpty(property.stringValue), HandleSelect, new SpineDrawerValuePair(string.Empty, property));
|
||||
|
||||
for (int i = 0; i < events.Count; i++) {
|
||||
var eventObject = events.Items[i];
|
||||
string name = eventObject.Name;
|
||||
if (name.StartsWith(targetAttribute.startsWith, StringComparison.Ordinal)) {
|
||||
if (!TargetAttribute.audioOnly || !string.IsNullOrEmpty(eventObject.AudioPath)) {
|
||||
menu.AddItem(new GUIContent(name), !property.hasMultipleDifferentValues && name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(SpineIkConstraint))]
|
||||
public class SpineIkConstraintDrawer : SpineTreeItemDrawerBase<SpineIkConstraint> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.constraintIK; } }
|
||||
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineIkConstraint targetAttribute, SkeletonData data) {
|
||||
var constraints = skeletonDataAsset.GetSkeletonData(false).IkConstraints;
|
||||
|
||||
if (TargetAttribute.includeNone)
|
||||
menu.AddItem(new GUIContent(NoneString), !property.hasMultipleDifferentValues && string.IsNullOrEmpty(property.stringValue), HandleSelect, new SpineDrawerValuePair(string.Empty, property));
|
||||
|
||||
for (int i = 0; i < constraints.Count; i++) {
|
||||
string name = constraints.Items[i].Name;
|
||||
if (name.StartsWith(targetAttribute.startsWith, StringComparison.Ordinal))
|
||||
menu.AddItem(new GUIContent(name), !property.hasMultipleDifferentValues && name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(SpineTransformConstraint))]
|
||||
public class SpineTransformConstraintDrawer : SpineTreeItemDrawerBase<SpineTransformConstraint> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.constraintTransform; } }
|
||||
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineTransformConstraint targetAttribute, SkeletonData data) {
|
||||
var constraints = skeletonDataAsset.GetSkeletonData(false).TransformConstraints;
|
||||
|
||||
if (TargetAttribute.includeNone)
|
||||
menu.AddItem(new GUIContent(NoneString), !property.hasMultipleDifferentValues && string.IsNullOrEmpty(property.stringValue), HandleSelect, new SpineDrawerValuePair(string.Empty, property));
|
||||
|
||||
for (int i = 0; i < constraints.Count; i++) {
|
||||
string name = constraints.Items[i].Name;
|
||||
if (name.StartsWith(targetAttribute.startsWith, StringComparison.Ordinal))
|
||||
menu.AddItem(new GUIContent(name), !property.hasMultipleDifferentValues && name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(SpinePathConstraint))]
|
||||
public class SpinePathConstraintDrawer : SpineTreeItemDrawerBase<SpinePathConstraint> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.constraintPath; } }
|
||||
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpinePathConstraint targetAttribute, SkeletonData data) {
|
||||
var constraints = skeletonDataAsset.GetSkeletonData(false).PathConstraints;
|
||||
|
||||
if (TargetAttribute.includeNone)
|
||||
menu.AddItem(new GUIContent(NoneString), !property.hasMultipleDifferentValues && string.IsNullOrEmpty(property.stringValue), HandleSelect, new SpineDrawerValuePair(string.Empty, property));
|
||||
|
||||
for (int i = 0; i < constraints.Count; i++) {
|
||||
string name = constraints.Items[i].Name;
|
||||
if (name.StartsWith(targetAttribute.startsWith, StringComparison.Ordinal))
|
||||
menu.AddItem(new GUIContent(name), !property.hasMultipleDifferentValues && name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(SpineAttachment))]
|
||||
public class SpineAttachmentDrawer : SpineTreeItemDrawerBase<SpineAttachment> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.genericAttachment; } }
|
||||
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineAttachment targetAttribute, SkeletonData data) {
|
||||
ISkeletonComponent skeletonComponent = GetTargetSkeletonComponent(property);
|
||||
var validSkins = new List<Skin>();
|
||||
|
||||
if (skeletonComponent != null && targetAttribute.currentSkinOnly) {
|
||||
Skin currentSkin = null;
|
||||
|
||||
var skinProperty = property.FindBaseOrSiblingProperty(targetAttribute.skinField);
|
||||
if (skinProperty != null) currentSkin = skeletonComponent.Skeleton.Data.FindSkin(skinProperty.stringValue);
|
||||
|
||||
currentSkin = currentSkin ?? skeletonComponent.Skeleton.Skin;
|
||||
if (currentSkin != null)
|
||||
validSkins.Add(currentSkin);
|
||||
else
|
||||
validSkins.Add(data.Skins.Items[0]);
|
||||
|
||||
} else {
|
||||
foreach (Skin skin in data.Skins)
|
||||
if (skin != null) validSkins.Add(skin);
|
||||
}
|
||||
|
||||
var attachmentNames = new List<string>();
|
||||
var placeholderNames = new List<string>();
|
||||
string prefix = "";
|
||||
|
||||
if (skeletonComponent != null && targetAttribute.currentSkinOnly)
|
||||
menu.AddDisabledItem(new GUIContent((skeletonComponent as Component).gameObject.name + " (Skeleton)"));
|
||||
else
|
||||
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
||||
|
||||
menu.AddSeparator("");
|
||||
if (TargetAttribute.includeNone) {
|
||||
const string NullAttachmentName = "";
|
||||
menu.AddItem(new GUIContent("Null"), !property.hasMultipleDifferentValues && property.stringValue == NullAttachmentName, HandleSelect, new SpineDrawerValuePair(NullAttachmentName, property));
|
||||
menu.AddSeparator("");
|
||||
}
|
||||
|
||||
Skin defaultSkin = data.Skins.Items[0];
|
||||
var slotProperty = property.FindBaseOrSiblingProperty(TargetAttribute.slotField);
|
||||
|
||||
string slotMatch = "";
|
||||
if (slotProperty != null) {
|
||||
if (slotProperty.propertyType == SerializedPropertyType.String)
|
||||
slotMatch = slotProperty.stringValue.ToLower();
|
||||
}
|
||||
|
||||
foreach (Skin skin in validSkins) {
|
||||
string skinPrefix = skin.Name + "/";
|
||||
|
||||
if (validSkins.Count > 1)
|
||||
prefix = skinPrefix;
|
||||
|
||||
for (int i = 0; i < data.Slots.Count; i++) {
|
||||
if (slotMatch.Length > 0 && !(data.Slots.Items[i].Name.Equals(slotMatch, StringComparison.OrdinalIgnoreCase)))
|
||||
continue;
|
||||
|
||||
attachmentNames.Clear();
|
||||
placeholderNames.Clear();
|
||||
|
||||
var skinEntries = new List<Skin.SkinEntry>();
|
||||
skin.GetAttachments(i, skinEntries);
|
||||
foreach (var entry in skinEntries) {
|
||||
attachmentNames.Add(entry.Name);
|
||||
}
|
||||
|
||||
if (skin != defaultSkin) {
|
||||
foreach (var entry in skinEntries) {
|
||||
placeholderNames.Add(entry.Name);
|
||||
}
|
||||
skinEntries.Clear();
|
||||
defaultSkin.GetAttachments(i, skinEntries);
|
||||
foreach (var entry in skinEntries) {
|
||||
attachmentNames.Add(entry.Name);
|
||||
}
|
||||
}
|
||||
|
||||
for (int a = 0; a < attachmentNames.Count; a++) {
|
||||
string attachmentPath = attachmentNames[a];
|
||||
string menuPath = prefix + data.Slots.Items[i].Name + "/" + attachmentPath;
|
||||
string name = attachmentNames[a];
|
||||
|
||||
if (targetAttribute.returnAttachmentPath)
|
||||
name = skin.Name + "/" + data.Slots.Items[i].Name + "/" + attachmentPath;
|
||||
|
||||
if (targetAttribute.placeholdersOnly && !placeholderNames.Contains(attachmentPath)) {
|
||||
menu.AddDisabledItem(new GUIContent(menuPath));
|
||||
} else {
|
||||
menu.AddItem(new GUIContent(menuPath), !property.hasMultipleDifferentValues && name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(SpineBone))]
|
||||
public class SpineBoneDrawer : SpineTreeItemDrawerBase<SpineBone> {
|
||||
|
||||
protected override Texture2D Icon { get { return SpineEditorUtilities.Icons.bone; } }
|
||||
|
||||
protected override void PopulateMenu (GenericMenu menu, SerializedProperty property, SpineBone targetAttribute, SkeletonData data) {
|
||||
menu.AddDisabledItem(new GUIContent(skeletonDataAsset.name));
|
||||
menu.AddSeparator("");
|
||||
|
||||
if (TargetAttribute.includeNone)
|
||||
menu.AddItem(new GUIContent(NoneString), !property.hasMultipleDifferentValues && string.IsNullOrEmpty(property.stringValue), HandleSelect, new SpineDrawerValuePair(string.Empty, property));
|
||||
|
||||
for (int i = 0; i < data.Bones.Count; i++) {
|
||||
var bone = data.Bones.Items[i];
|
||||
string name = bone.Name;
|
||||
if (name.StartsWith(targetAttribute.startsWith, StringComparison.Ordinal)) {
|
||||
// jointName = "root/hip/bone" to show a hierarchial tree.
|
||||
string jointName = name;
|
||||
var iterator = bone;
|
||||
while ((iterator = iterator.Parent) != null)
|
||||
jointName = string.Format("{0}/{1}", iterator.Name, jointName);
|
||||
|
||||
menu.AddItem(new GUIContent(jointName), !property.hasMultipleDifferentValues && name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[CustomPropertyDrawer(typeof(SpineAtlasRegion))]
|
||||
public class SpineAtlasRegionDrawer : PropertyDrawer {
|
||||
SerializedProperty atlasProp;
|
||||
|
||||
protected SpineAtlasRegion TargetAttribute { get { return (SpineAtlasRegion)attribute; } }
|
||||
|
||||
public override void OnGUI (Rect position, SerializedProperty property, GUIContent label) {
|
||||
if (property.propertyType != SerializedPropertyType.String) {
|
||||
EditorGUI.LabelField(position, "ERROR:", "May only apply to type string");
|
||||
return;
|
||||
}
|
||||
|
||||
string atlasAssetFieldName = TargetAttribute.atlasAssetField;
|
||||
if (string.IsNullOrEmpty(atlasAssetFieldName))
|
||||
atlasAssetFieldName = "atlasAsset";
|
||||
|
||||
atlasProp = property.FindBaseOrSiblingProperty(atlasAssetFieldName);
|
||||
|
||||
if (atlasProp == null) {
|
||||
EditorGUI.LabelField(position, "ERROR:", "Must have AtlasAsset variable!");
|
||||
return;
|
||||
} else if (atlasProp.objectReferenceValue == null) {
|
||||
EditorGUI.LabelField(position, "ERROR:", "Atlas variable must not be null!");
|
||||
return;
|
||||
} else if (!atlasProp.objectReferenceValue.GetType().IsSubclassOf(typeof(AtlasAssetBase)) &&
|
||||
atlasProp.objectReferenceValue.GetType() != typeof(AtlasAssetBase)) {
|
||||
EditorGUI.LabelField(position, "ERROR:", "Atlas variable must be of type AtlasAsset!");
|
||||
}
|
||||
|
||||
position = EditorGUI.PrefixLabel(position, label);
|
||||
|
||||
if (GUI.Button(position, property.stringValue, EditorStyles.popup))
|
||||
Selector(property);
|
||||
|
||||
}
|
||||
|
||||
void Selector (SerializedProperty property) {
|
||||
GenericMenu menu = new GenericMenu();
|
||||
AtlasAssetBase atlasAsset = (AtlasAssetBase)atlasProp.objectReferenceValue;
|
||||
Atlas atlas = atlasAsset.GetAtlas();
|
||||
FieldInfo field = typeof(Atlas).GetField("regions", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
|
||||
List<AtlasRegion> regions = (List<AtlasRegion>)field.GetValue(atlas);
|
||||
|
||||
for (int i = 0; i < regions.Count; i++) {
|
||||
string name = regions[i].name;
|
||||
menu.AddItem(new GUIContent(name), !property.hasMultipleDifferentValues && name == property.stringValue, HandleSelect, new SpineDrawerValuePair(name, property));
|
||||
}
|
||||
|
||||
menu.ShowAsContext();
|
||||
}
|
||||
|
||||
static void HandleSelect (object val) {
|
||||
var pair = (SpineDrawerValuePair)val;
|
||||
pair.property.stringValue = pair.stringValue;
|
||||
pair.property.serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f2de282d583d4a641bf1c349f0a3eef9
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,459 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma warning disable 0219
|
||||
#pragma warning disable 0618 // for 3.7 branch only. Avoids "PreferenceItem' is obsolete: '[PreferenceItem] is deprecated. Use [SettingsProvider] instead."
|
||||
|
||||
// Original contribution by: Mitch Thompson
|
||||
|
||||
#define SPINE_SKELETONMECANIM
|
||||
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
#define NEWPLAYMODECALLBACKS
|
||||
#endif
|
||||
|
||||
#if UNITY_2018 || UNITY_2019 || UNITY_2018_3_OR_NEWER
|
||||
#define NEWHIERARCHYWINDOWCALLBACKS
|
||||
#endif
|
||||
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
#define NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
#endif
|
||||
|
||||
#if UNITY_2017_1_OR_NEWER
|
||||
#define BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using EventType = UnityEngine.EventType;
|
||||
|
||||
// Analysis disable once ConvertToStaticType
|
||||
[InitializeOnLoad]
|
||||
public partial class SpineEditorUtilities : AssetPostprocessor {
|
||||
|
||||
public static string editorPath = "";
|
||||
public static string editorGUIPath = "";
|
||||
public static bool initialized;
|
||||
private static List<string> texturesWithoutMetaFile = new List<string>();
|
||||
|
||||
// Auto-import entry point for textures
|
||||
void OnPreprocessTexture () {
|
||||
#if UNITY_2018_1_OR_NEWER
|
||||
bool customTextureSettingsExist = !assetImporter.importSettingsMissing;
|
||||
#else
|
||||
bool customTextureSettingsExist = System.IO.File.Exists(assetImporter.assetPath + ".meta");
|
||||
#endif
|
||||
if (!customTextureSettingsExist) {
|
||||
texturesWithoutMetaFile.Add(assetImporter.assetPath);
|
||||
}
|
||||
}
|
||||
|
||||
// Auto-import post process entry point for all assets
|
||||
static void OnPostprocessAllAssets (string[] imported, string[] deleted, string[] moved, string[] movedFromAssetPaths) {
|
||||
if (imported.Length == 0)
|
||||
return;
|
||||
|
||||
// we copy the list here to prevent nested calls to OnPostprocessAllAssets() triggering a Clear() of the list
|
||||
// in the middle of execution.
|
||||
var texturesWithoutMetaFileCopy = new List<string>(texturesWithoutMetaFile);
|
||||
AssetUtility.HandleOnPostprocessAllAssets(imported, texturesWithoutMetaFileCopy);
|
||||
texturesWithoutMetaFile.Clear();
|
||||
}
|
||||
|
||||
#region Initialization
|
||||
static SpineEditorUtilities () {
|
||||
EditorApplication.delayCall += Initialize; // delayed so that AssetDatabase is ready.
|
||||
}
|
||||
|
||||
static void Initialize () {
|
||||
// Note: Preferences need to be loaded when changing play mode
|
||||
// to initialize handle scale correctly.
|
||||
#if !NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
Preferences.Load();
|
||||
#else
|
||||
SpinePreferences.Load();
|
||||
#endif
|
||||
|
||||
if (EditorApplication.isPlayingOrWillChangePlaymode) return;
|
||||
|
||||
string[] assets = AssetDatabase.FindAssets("t:script SpineEditorUtilities");
|
||||
string assetPath = AssetDatabase.GUIDToAssetPath(assets[0]);
|
||||
editorPath = Path.GetDirectoryName(assetPath).Replace('\\', '/');
|
||||
|
||||
assets = AssetDatabase.FindAssets("t:texture icon-subMeshRenderer");
|
||||
if (assets.Length > 0) {
|
||||
assetPath = AssetDatabase.GUIDToAssetPath(assets[0]);
|
||||
editorGUIPath = Path.GetDirectoryName(assetPath).Replace('\\', '/');
|
||||
}
|
||||
else {
|
||||
editorGUIPath = editorPath.Replace("/Utility", "/GUI");
|
||||
}
|
||||
Icons.Initialize();
|
||||
|
||||
// Drag and Drop
|
||||
#if UNITY_2019_1_OR_NEWER
|
||||
SceneView.duringSceneGui -= DragAndDropInstantiation.SceneViewDragAndDrop;
|
||||
SceneView.duringSceneGui += DragAndDropInstantiation.SceneViewDragAndDrop;
|
||||
#else
|
||||
SceneView.onSceneGUIDelegate -= DragAndDropInstantiation.SceneViewDragAndDrop;
|
||||
SceneView.onSceneGUIDelegate += DragAndDropInstantiation.SceneViewDragAndDrop;
|
||||
#endif
|
||||
|
||||
EditorApplication.hierarchyWindowItemOnGUI -= HierarchyHandler.HandleDragAndDrop;
|
||||
EditorApplication.hierarchyWindowItemOnGUI += HierarchyHandler.HandleDragAndDrop;
|
||||
|
||||
// Hierarchy Icons
|
||||
#if NEWPLAYMODECALLBACKS
|
||||
EditorApplication.playModeStateChanged -= HierarchyHandler.IconsOnPlaymodeStateChanged;
|
||||
EditorApplication.playModeStateChanged += HierarchyHandler.IconsOnPlaymodeStateChanged;
|
||||
HierarchyHandler.IconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode);
|
||||
#else
|
||||
EditorApplication.playmodeStateChanged -= HierarchyHandler.IconsOnPlaymodeStateChanged;
|
||||
EditorApplication.playmodeStateChanged += HierarchyHandler.IconsOnPlaymodeStateChanged;
|
||||
HierarchyHandler.IconsOnPlaymodeStateChanged();
|
||||
#endif
|
||||
|
||||
// Data Refresh Edit Mode.
|
||||
// This prevents deserialized SkeletonData from persisting from play mode to edit mode.
|
||||
#if NEWPLAYMODECALLBACKS
|
||||
EditorApplication.playModeStateChanged -= DataReloadHandler.OnPlaymodeStateChanged;
|
||||
EditorApplication.playModeStateChanged += DataReloadHandler.OnPlaymodeStateChanged;
|
||||
DataReloadHandler.OnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode);
|
||||
#else
|
||||
EditorApplication.playmodeStateChanged -= DataReloadHandler.OnPlaymodeStateChanged;
|
||||
EditorApplication.playmodeStateChanged += DataReloadHandler.OnPlaymodeStateChanged;
|
||||
DataReloadHandler.OnPlaymodeStateChanged();
|
||||
#endif
|
||||
|
||||
if (SpineEditorUtilities.Preferences.textureImporterWarning) {
|
||||
IssueWarningsForUnrecommendedTextureSettings();
|
||||
}
|
||||
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
public static void ConfirmInitialization () {
|
||||
if (!initialized || Icons.skeleton == null)
|
||||
Initialize();
|
||||
}
|
||||
|
||||
public static void IssueWarningsForUnrecommendedTextureSettings() {
|
||||
|
||||
string[] atlasDescriptionGUIDs = AssetDatabase.FindAssets("t:textasset .atlas"); // Note: finds ".atlas.txt" but also ".atlas 1.txt" files.
|
||||
for (int i = 0; i < atlasDescriptionGUIDs.Length; ++i) {
|
||||
string atlasDescriptionPath = AssetDatabase.GUIDToAssetPath(atlasDescriptionGUIDs[i]);
|
||||
if (!atlasDescriptionPath.EndsWith(".atlas.txt"))
|
||||
continue;
|
||||
|
||||
string texturePath = atlasDescriptionPath.Replace(".atlas.txt", ".png");
|
||||
|
||||
bool textureExists = IssueWarningsForUnrecommendedTextureSettings(texturePath);
|
||||
if (!textureExists) {
|
||||
texturePath = texturePath.Replace(".png", ".jpg");
|
||||
textureExists = IssueWarningsForUnrecommendedTextureSettings(texturePath);
|
||||
}
|
||||
if (!textureExists) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void ReloadSkeletonDataAssetAndComponent (SkeletonRenderer component) {
|
||||
if (component == null) return;
|
||||
ReloadSkeletonDataAsset(component.skeletonDataAsset);
|
||||
ReinitializeComponent(component);
|
||||
}
|
||||
|
||||
public static void ReloadSkeletonDataAssetAndComponent (SkeletonGraphic component) {
|
||||
if (component == null) return;
|
||||
ReloadSkeletonDataAsset(component.skeletonDataAsset);
|
||||
// Reinitialize.
|
||||
ReinitializeComponent(component);
|
||||
}
|
||||
|
||||
public static void ReloadSkeletonDataAsset (SkeletonDataAsset skeletonDataAsset) {
|
||||
if (skeletonDataAsset != null) {
|
||||
foreach (AtlasAssetBase aa in skeletonDataAsset.atlasAssets) {
|
||||
if (aa != null) aa.Clear();
|
||||
}
|
||||
skeletonDataAsset.Clear();
|
||||
}
|
||||
skeletonDataAsset.GetSkeletonData(true);
|
||||
}
|
||||
|
||||
public static void ReinitializeComponent (SkeletonRenderer component) {
|
||||
if (component == null) return;
|
||||
if (!SkeletonDataAssetIsValid(component.SkeletonDataAsset)) return;
|
||||
|
||||
var stateComponent = component as IAnimationStateComponent;
|
||||
AnimationState oldAnimationState = null;
|
||||
if (stateComponent != null) {
|
||||
oldAnimationState = stateComponent.AnimationState;
|
||||
}
|
||||
|
||||
component.Initialize(true); // implicitly clears any subscribers
|
||||
|
||||
if (oldAnimationState != null) {
|
||||
stateComponent.AnimationState.AssignEventSubscribersFrom(oldAnimationState);
|
||||
}
|
||||
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
SpineMaskUtilities.EditorAssignSpriteMaskMaterials(component);
|
||||
#endif
|
||||
component.LateUpdate();
|
||||
}
|
||||
|
||||
public static void ReinitializeComponent (SkeletonGraphic component) {
|
||||
if (component == null) return;
|
||||
if (!SkeletonDataAssetIsValid(component.SkeletonDataAsset)) return;
|
||||
component.Initialize(true);
|
||||
component.LateUpdate();
|
||||
}
|
||||
|
||||
public static bool SkeletonDataAssetIsValid (SkeletonDataAsset asset) {
|
||||
return asset != null && asset.GetSkeletonData(quiet: true) != null;
|
||||
}
|
||||
|
||||
public static bool IssueWarningsForUnrecommendedTextureSettings(string texturePath)
|
||||
{
|
||||
TextureImporter texImporter = (TextureImporter)TextureImporter.GetAtPath(texturePath);
|
||||
if (texImporter == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int extensionPos = texturePath.LastIndexOf('.');
|
||||
string materialPath = texturePath.Substring(0, extensionPos) + "_Material.mat";
|
||||
Material material = AssetDatabase.LoadAssetAtPath<Material>(materialPath);
|
||||
|
||||
if (material == null)
|
||||
return true;
|
||||
|
||||
string errorMessage = null;
|
||||
if (MaterialChecks.IsTextureSetupProblematic(material, PlayerSettings.colorSpace,
|
||||
texImporter. sRGBTexture, texImporter. mipmapEnabled, texImporter. alphaIsTransparency,
|
||||
texturePath, materialPath, ref errorMessage)) {
|
||||
Debug.LogWarning(errorMessage, material);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
#endregion
|
||||
|
||||
public static class HierarchyHandler {
|
||||
static Dictionary<int, GameObject> skeletonRendererTable = new Dictionary<int, GameObject>();
|
||||
static Dictionary<int, SkeletonUtilityBone> skeletonUtilityBoneTable = new Dictionary<int, SkeletonUtilityBone>();
|
||||
static Dictionary<int, BoundingBoxFollower> boundingBoxFollowerTable = new Dictionary<int, BoundingBoxFollower>();
|
||||
static Dictionary<int, BoundingBoxFollowerGraphic> boundingBoxFollowerGraphicTable = new Dictionary<int, BoundingBoxFollowerGraphic>();
|
||||
|
||||
#if NEWPLAYMODECALLBACKS
|
||||
internal static void IconsOnPlaymodeStateChanged (PlayModeStateChange stateChange) {
|
||||
#else
|
||||
internal static void IconsOnPlaymodeStateChanged () {
|
||||
#endif
|
||||
skeletonRendererTable.Clear();
|
||||
skeletonUtilityBoneTable.Clear();
|
||||
boundingBoxFollowerTable.Clear();
|
||||
boundingBoxFollowerGraphicTable.Clear();
|
||||
|
||||
#if NEWHIERARCHYWINDOWCALLBACKS
|
||||
EditorApplication.hierarchyChanged -= IconsOnChanged;
|
||||
#else
|
||||
EditorApplication.hierarchyWindowChanged -= IconsOnChanged;
|
||||
#endif
|
||||
EditorApplication.hierarchyWindowItemOnGUI -= IconsOnGUI;
|
||||
|
||||
if (!Application.isPlaying && Preferences.showHierarchyIcons) {
|
||||
#if NEWHIERARCHYWINDOWCALLBACKS
|
||||
EditorApplication.hierarchyChanged += IconsOnChanged;
|
||||
#else
|
||||
EditorApplication.hierarchyWindowChanged += IconsOnChanged;
|
||||
#endif
|
||||
EditorApplication.hierarchyWindowItemOnGUI += IconsOnGUI;
|
||||
IconsOnChanged();
|
||||
}
|
||||
}
|
||||
|
||||
internal static void IconsOnChanged () {
|
||||
skeletonRendererTable.Clear();
|
||||
skeletonUtilityBoneTable.Clear();
|
||||
boundingBoxFollowerTable.Clear();
|
||||
boundingBoxFollowerGraphicTable.Clear();
|
||||
|
||||
SkeletonRenderer[] arr = Object.FindObjectsOfType<SkeletonRenderer>();
|
||||
foreach (SkeletonRenderer r in arr)
|
||||
skeletonRendererTable[r.gameObject.GetInstanceID()] = r.gameObject;
|
||||
|
||||
SkeletonUtilityBone[] boneArr = Object.FindObjectsOfType<SkeletonUtilityBone>();
|
||||
foreach (SkeletonUtilityBone b in boneArr)
|
||||
skeletonUtilityBoneTable[b.gameObject.GetInstanceID()] = b;
|
||||
|
||||
BoundingBoxFollower[] bbfArr = Object.FindObjectsOfType<BoundingBoxFollower>();
|
||||
foreach (BoundingBoxFollower bbf in bbfArr)
|
||||
boundingBoxFollowerTable[bbf.gameObject.GetInstanceID()] = bbf;
|
||||
|
||||
BoundingBoxFollowerGraphic[] bbfgArr = Object.FindObjectsOfType<BoundingBoxFollowerGraphic>();
|
||||
foreach (BoundingBoxFollowerGraphic bbf in bbfgArr)
|
||||
boundingBoxFollowerGraphicTable[bbf.gameObject.GetInstanceID()] = bbf;
|
||||
}
|
||||
|
||||
internal static void IconsOnGUI (int instanceId, Rect selectionRect) {
|
||||
Rect r = new Rect(selectionRect);
|
||||
if (skeletonRendererTable.ContainsKey(instanceId)) {
|
||||
r.x = r.width - 15;
|
||||
r.width = 15;
|
||||
GUI.Label(r, Icons.spine);
|
||||
} else if (skeletonUtilityBoneTable.ContainsKey(instanceId)) {
|
||||
r.x -= 26;
|
||||
if (skeletonUtilityBoneTable[instanceId] != null) {
|
||||
if (skeletonUtilityBoneTable[instanceId].transform.childCount == 0)
|
||||
r.x += 13;
|
||||
r.y += 2;
|
||||
r.width = 13;
|
||||
r.height = 13;
|
||||
if (skeletonUtilityBoneTable[instanceId].mode == SkeletonUtilityBone.Mode.Follow)
|
||||
GUI.DrawTexture(r, Icons.bone);
|
||||
else
|
||||
GUI.DrawTexture(r, Icons.poseBones);
|
||||
}
|
||||
} else if (boundingBoxFollowerTable.ContainsKey(instanceId)) {
|
||||
r.x -= 26;
|
||||
if (boundingBoxFollowerTable[instanceId] != null) {
|
||||
if (boundingBoxFollowerTable[instanceId].transform.childCount == 0)
|
||||
r.x += 13;
|
||||
r.y += 2;
|
||||
r.width = 13;
|
||||
r.height = 13;
|
||||
GUI.DrawTexture(r, Icons.boundingBox);
|
||||
}
|
||||
} else if (boundingBoxFollowerGraphicTable.ContainsKey(instanceId)) {
|
||||
r.x -= 26;
|
||||
if (boundingBoxFollowerGraphicTable[instanceId] != null) {
|
||||
if (boundingBoxFollowerGraphicTable[instanceId].transform.childCount == 0)
|
||||
r.x += 13;
|
||||
r.y += 2;
|
||||
r.width = 13;
|
||||
r.height = 13;
|
||||
GUI.DrawTexture(r, Icons.boundingBox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static void HandleDragAndDrop (int instanceId, Rect selectionRect) {
|
||||
// HACK: Uses EditorApplication.hierarchyWindowItemOnGUI.
|
||||
// Only works when there is at least one item in the scene.
|
||||
var current = UnityEngine.Event.current;
|
||||
var eventType = current.type;
|
||||
bool isDraggingEvent = eventType == EventType.DragUpdated;
|
||||
bool isDropEvent = eventType == EventType.DragPerform;
|
||||
UnityEditor.DragAndDrop.visualMode = DragAndDropVisualMode.Copy;
|
||||
|
||||
if (isDraggingEvent || isDropEvent) {
|
||||
var mouseOverWindow = EditorWindow.mouseOverWindow;
|
||||
if (mouseOverWindow != null) {
|
||||
|
||||
// One, existing, valid SkeletonDataAsset
|
||||
var references = UnityEditor.DragAndDrop.objectReferences;
|
||||
if (references.Length == 1) {
|
||||
var skeletonDataAsset = references[0] as SkeletonDataAsset;
|
||||
if (skeletonDataAsset != null && skeletonDataAsset.GetSkeletonData(true) != null) {
|
||||
|
||||
// Allow drag-and-dropping anywhere in the Hierarchy Window.
|
||||
// HACK: string-compare because we can't get its type via reflection.
|
||||
const string HierarchyWindow = "UnityEditor.SceneHierarchyWindow";
|
||||
const string GenericDataTargetID = "target";
|
||||
if (HierarchyWindow.Equals(mouseOverWindow.GetType().ToString(), System.StringComparison.Ordinal)) {
|
||||
if (isDraggingEvent) {
|
||||
var mouseOverTarget = UnityEditor.EditorUtility.InstanceIDToObject(instanceId);
|
||||
if (mouseOverTarget)
|
||||
DragAndDrop.SetGenericData(GenericDataTargetID, mouseOverTarget);
|
||||
// Note: do not call current.Use(), otherwise we get the wrong drop-target parent.
|
||||
} else if (isDropEvent) {
|
||||
var parentGameObject = DragAndDrop.GetGenericData(GenericDataTargetID) as UnityEngine.GameObject;
|
||||
Transform parent = parentGameObject != null ? parentGameObject.transform : null;
|
||||
// when dragging into empty space in hierarchy below last node, last node would be parent.
|
||||
if (IsLastNodeInHierarchy(parent))
|
||||
parent = null;
|
||||
DragAndDropInstantiation.ShowInstantiateContextMenu(skeletonDataAsset, Vector3.zero, parent);
|
||||
UnityEditor.DragAndDrop.AcceptDrag();
|
||||
current.Use();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal static bool IsLastNodeInHierarchy (Transform node) {
|
||||
if (node == null)
|
||||
return false;
|
||||
|
||||
while (node.parent != null) {
|
||||
if (node.GetSiblingIndex() != node.parent.childCount - 1)
|
||||
return false;
|
||||
node = node.parent;
|
||||
}
|
||||
|
||||
var rootNodes = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects();
|
||||
bool isLastNode = (rootNodes.Length > 0 && rootNodes[rootNodes.Length - 1].transform == node);
|
||||
return isLastNode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TextureModificationWarningProcessor : UnityEditor.AssetModificationProcessor
|
||||
{
|
||||
static string[] OnWillSaveAssets(string[] paths)
|
||||
{
|
||||
if (SpineEditorUtilities.Preferences.textureImporterWarning) {
|
||||
foreach (string path in paths) {
|
||||
if ((path != null) &&
|
||||
(path.EndsWith(".png.meta", System.StringComparison.Ordinal) ||
|
||||
path.EndsWith(".jpg.meta", System.StringComparison.Ordinal))) {
|
||||
|
||||
string texturePath = System.IO.Path.ChangeExtension(path, null); // .meta removed
|
||||
string atlasPath = System.IO.Path.ChangeExtension(texturePath, "atlas.txt");
|
||||
if (System.IO.File.Exists(atlasPath))
|
||||
SpineEditorUtilities.IssueWarningsForUnrecommendedTextureSettings(texturePath);
|
||||
}
|
||||
}
|
||||
}
|
||||
return paths;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f834d5cd806ec4645915ac315edbdc60
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -1,501 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma warning disable 0219
|
||||
|
||||
#define SPINE_SKELETONMECANIM
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Globalization;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
using EventType = UnityEngine.EventType;
|
||||
|
||||
public static class SpineHandles {
|
||||
public static Color BoneColor { get { return new Color(0.8f, 0.8f, 0.8f, 0.4f); } }
|
||||
public static Color PathColor { get { return new Color(254/255f, 127/255f, 0); } }
|
||||
public static Color TransformContraintColor { get { return new Color(170/255f, 226/255f, 35/255f); } }
|
||||
public static Color IkColor { get { return new Color(228/255f,90/255f,43/255f); } }
|
||||
public static Color PointColor { get { return new Color(1f, 1f, 0f, 1f); } }
|
||||
|
||||
static Vector3[] _boneMeshVerts = {
|
||||
new Vector3(0, 0, 0),
|
||||
new Vector3(0.1f, 0.1f, 0),
|
||||
new Vector3(1, 0, 0),
|
||||
new Vector3(0.1f, -0.1f, 0)
|
||||
};
|
||||
static Mesh _boneMesh;
|
||||
public static Mesh BoneMesh {
|
||||
get {
|
||||
if (_boneMesh == null) {
|
||||
_boneMesh = new Mesh {
|
||||
vertices = _boneMeshVerts,
|
||||
uv = new Vector2[4],
|
||||
triangles = new [] { 0, 1, 2, 2, 3, 0 }
|
||||
};
|
||||
_boneMesh.RecalculateBounds();
|
||||
_boneMesh.RecalculateNormals();
|
||||
}
|
||||
return _boneMesh;
|
||||
}
|
||||
}
|
||||
|
||||
static Mesh _arrowheadMesh;
|
||||
public static Mesh ArrowheadMesh {
|
||||
get {
|
||||
if (_arrowheadMesh == null) {
|
||||
_arrowheadMesh = new Mesh {
|
||||
vertices = new [] {
|
||||
new Vector3(0, 0),
|
||||
new Vector3(-0.1f, 0.05f),
|
||||
new Vector3(-0.1f, -0.05f)
|
||||
},
|
||||
uv = new Vector2[3],
|
||||
triangles = new [] { 0, 1, 2 }
|
||||
};
|
||||
_arrowheadMesh.RecalculateBounds();
|
||||
_arrowheadMesh.RecalculateNormals();
|
||||
}
|
||||
return _arrowheadMesh;
|
||||
}
|
||||
}
|
||||
|
||||
static Material _boneMaterial;
|
||||
static Material BoneMaterial {
|
||||
get {
|
||||
if (_boneMaterial == null) {
|
||||
_boneMaterial = new Material(Shader.Find("Hidden/Spine/Bones"));
|
||||
_boneMaterial.SetColor("_Color", SpineHandles.BoneColor);
|
||||
}
|
||||
|
||||
return _boneMaterial;
|
||||
}
|
||||
}
|
||||
public static Material GetBoneMaterial () {
|
||||
BoneMaterial.SetColor("_Color", SpineHandles.BoneColor);
|
||||
return BoneMaterial;
|
||||
}
|
||||
|
||||
public static Material GetBoneMaterial (Color color) {
|
||||
BoneMaterial.SetColor("_Color", color);
|
||||
return BoneMaterial;
|
||||
}
|
||||
|
||||
static Material _ikMaterial;
|
||||
public static Material IKMaterial {
|
||||
get {
|
||||
if (_ikMaterial == null) {
|
||||
_ikMaterial = new Material(Shader.Find("Hidden/Spine/Bones"));
|
||||
_ikMaterial.SetColor("_Color", SpineHandles.IkColor);
|
||||
}
|
||||
return _ikMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
static GUIStyle _boneNameStyle;
|
||||
public static GUIStyle BoneNameStyle {
|
||||
get {
|
||||
if (_boneNameStyle == null) {
|
||||
_boneNameStyle = new GUIStyle(EditorStyles.whiteMiniLabel) {
|
||||
alignment = TextAnchor.MiddleCenter,
|
||||
stretchWidth = true,
|
||||
padding = new RectOffset(0, 0, 0, 0),
|
||||
contentOffset = new Vector2(-5f, 0f)
|
||||
};
|
||||
}
|
||||
return _boneNameStyle;
|
||||
}
|
||||
}
|
||||
|
||||
static GUIStyle _pathNameStyle;
|
||||
public static GUIStyle PathNameStyle {
|
||||
get {
|
||||
if (_pathNameStyle == null) {
|
||||
_pathNameStyle = new GUIStyle(SpineHandles.BoneNameStyle);
|
||||
_pathNameStyle.normal.textColor = SpineHandles.PathColor;
|
||||
}
|
||||
return _pathNameStyle;
|
||||
}
|
||||
}
|
||||
|
||||
static GUIStyle _pointNameStyle;
|
||||
public static GUIStyle PointNameStyle {
|
||||
get {
|
||||
if (_pointNameStyle == null) {
|
||||
_pointNameStyle = new GUIStyle(SpineHandles.BoneNameStyle);
|
||||
_pointNameStyle.normal.textColor = SpineHandles.PointColor;
|
||||
}
|
||||
return _pointNameStyle;
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawBoneNames (Transform transform, Skeleton skeleton, float positionScale = 1f) {
|
||||
GUIStyle style = BoneNameStyle;
|
||||
foreach (Bone b in skeleton.Bones) {
|
||||
if (!b.Active) continue;
|
||||
var pos = new Vector3(b.WorldX * positionScale, b.WorldY * positionScale, 0) + (new Vector3(b.A, b.C) * (b.Data.Length * 0.5f));
|
||||
pos = transform.TransformPoint(pos);
|
||||
Handles.Label(pos, b.Data.Name, style);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawBones (Transform transform, Skeleton skeleton, float positionScale = 1f) {
|
||||
float boneScale = 1.8f; // Draw the root bone largest;
|
||||
DrawCrosshairs2D(skeleton.Bones.Items[0].GetWorldPosition(transform), 0.08f, positionScale);
|
||||
|
||||
foreach (Bone b in skeleton.Bones) {
|
||||
if (!b.Active) continue;
|
||||
DrawBone(transform, b, boneScale, positionScale);
|
||||
boneScale = 1f;
|
||||
}
|
||||
}
|
||||
|
||||
static Vector3[] _boneWireBuffer = new Vector3[5];
|
||||
static Vector3[] GetBoneWireBuffer (Matrix4x4 m) {
|
||||
for (int i = 0, n = _boneMeshVerts.Length; i < n; i++)
|
||||
_boneWireBuffer[i] = m.MultiplyPoint(_boneMeshVerts[i]);
|
||||
|
||||
_boneWireBuffer[4] = _boneWireBuffer[0]; // closed polygon.
|
||||
return _boneWireBuffer;
|
||||
}
|
||||
public static void DrawBoneWireframe (Transform transform, Bone b, Color color, float skeletonRenderScale = 1f) {
|
||||
Handles.color = color;
|
||||
var pos = new Vector3(b.WorldX * skeletonRenderScale, b.WorldY * skeletonRenderScale, 0);
|
||||
float length = b.Data.Length;
|
||||
|
||||
if (length > 0) {
|
||||
Quaternion rot = Quaternion.Euler(0, 0, b.WorldRotationX);
|
||||
Vector3 scale = Vector3.one * length * b.WorldScaleX * skeletonRenderScale;
|
||||
const float my = 1.5f;
|
||||
scale.y *= (SpineEditorUtilities.Preferences.handleScale + 1) * 0.5f;
|
||||
scale.y = Mathf.Clamp(scale.x, -my * skeletonRenderScale, my * skeletonRenderScale);
|
||||
Handles.DrawPolyLine(GetBoneWireBuffer(transform.localToWorldMatrix * Matrix4x4.TRS(pos, rot, scale)));
|
||||
var wp = transform.TransformPoint(pos);
|
||||
DrawBoneCircle(wp, color, transform.forward, skeletonRenderScale);
|
||||
} else {
|
||||
var wp = transform.TransformPoint(pos);
|
||||
DrawBoneCircle(wp, color, transform.forward, skeletonRenderScale);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawBone (Transform transform, Bone b, float boneScale, float skeletonRenderScale = 1f) {
|
||||
var pos = new Vector3(b.WorldX * skeletonRenderScale, b.WorldY * skeletonRenderScale, 0);
|
||||
float length = b.Data.Length;
|
||||
if (length > 0) {
|
||||
Quaternion rot = Quaternion.Euler(0, 0, b.WorldRotationX);
|
||||
Vector3 scale = Vector3.one * length * b.WorldScaleX * skeletonRenderScale;
|
||||
const float my = 1.5f;
|
||||
scale.y *= (SpineEditorUtilities.Preferences.handleScale + 1f) * 0.5f;
|
||||
scale.y = Mathf.Clamp(scale.x, -my * skeletonRenderScale, my * skeletonRenderScale);
|
||||
SpineHandles.GetBoneMaterial().SetPass(0);
|
||||
Graphics.DrawMeshNow(SpineHandles.BoneMesh, transform.localToWorldMatrix * Matrix4x4.TRS(pos, rot, scale));
|
||||
} else {
|
||||
var wp = transform.TransformPoint(pos);
|
||||
DrawBoneCircle(wp, SpineHandles.BoneColor, transform.forward, boneScale * skeletonRenderScale);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawBone (Transform transform, Bone b, float boneScale, Color color, float skeletonRenderScale = 1f) {
|
||||
var pos = new Vector3(b.WorldX * skeletonRenderScale, b.WorldY * skeletonRenderScale, 0);
|
||||
float length = b.Data.Length;
|
||||
if (length > 0) {
|
||||
Quaternion rot = Quaternion.Euler(0, 0, b.WorldRotationX);
|
||||
Vector3 scale = Vector3.one * length * b.WorldScaleX;
|
||||
const float my = 1.5f;
|
||||
scale.y *= (SpineEditorUtilities.Preferences.handleScale + 1f) * 0.5f;
|
||||
scale.y = Mathf.Clamp(scale.x, -my, my);
|
||||
SpineHandles.GetBoneMaterial(color).SetPass(0);
|
||||
Graphics.DrawMeshNow(SpineHandles.BoneMesh, transform.localToWorldMatrix * Matrix4x4.TRS(pos, rot, scale));
|
||||
} else {
|
||||
var wp = transform.TransformPoint(pos);
|
||||
DrawBoneCircle(wp, color, transform.forward, boneScale * skeletonRenderScale);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawPaths (Transform transform, Skeleton skeleton) {
|
||||
foreach (Slot s in skeleton.DrawOrder) {
|
||||
var p = s.Attachment as PathAttachment;
|
||||
if (p != null) SpineHandles.DrawPath(s, p, transform, true);
|
||||
}
|
||||
}
|
||||
|
||||
static float[] pathVertexBuffer;
|
||||
public static void DrawPath (Slot s, PathAttachment p, Transform t, bool includeName) {
|
||||
int worldVerticesLength = p.WorldVerticesLength;
|
||||
|
||||
if (pathVertexBuffer == null || pathVertexBuffer.Length < worldVerticesLength)
|
||||
pathVertexBuffer = new float[worldVerticesLength];
|
||||
|
||||
float[] pv = pathVertexBuffer;
|
||||
p.ComputeWorldVertices(s, pv);
|
||||
|
||||
var ocolor = Handles.color;
|
||||
Handles.color = SpineHandles.PathColor;
|
||||
|
||||
Matrix4x4 m = t.localToWorldMatrix;
|
||||
const int step = 6;
|
||||
int n = worldVerticesLength - step;
|
||||
Vector3 p0, p1, p2, p3;
|
||||
for (int i = 2; i < n; i += step) {
|
||||
p0 = m.MultiplyPoint(new Vector3(pv[i], pv[i+1]));
|
||||
p1 = m.MultiplyPoint(new Vector3(pv[i+2], pv[i+3]));
|
||||
p2 = m.MultiplyPoint(new Vector3(pv[i+4], pv[i+5]));
|
||||
p3 = m.MultiplyPoint(new Vector3(pv[i+6], pv[i+7]));
|
||||
DrawCubicBezier(p0, p1, p2, p3);
|
||||
}
|
||||
|
||||
n += step;
|
||||
if (p.Closed) {
|
||||
p0 = m.MultiplyPoint(new Vector3(pv[n - 4], pv[n - 3]));
|
||||
p1 = m.MultiplyPoint(new Vector3(pv[n - 2], pv[n - 1]));
|
||||
p2 = m.MultiplyPoint(new Vector3(pv[0], pv[1]));
|
||||
p3 = m.MultiplyPoint(new Vector3(pv[2], pv[3]));
|
||||
DrawCubicBezier(p0, p1, p2, p3);
|
||||
}
|
||||
|
||||
const float endCapSize = 0.05f;
|
||||
Vector3 firstPoint = m.MultiplyPoint(new Vector3(pv[2], pv[3]));
|
||||
SpineHandles.DrawDot(firstPoint, endCapSize);
|
||||
|
||||
//if (!p.Closed) SpineHandles.DrawDot(m.MultiplyPoint(new Vector3(pv[n - 4], pv[n - 3])), endCapSize);
|
||||
if (includeName) Handles.Label(firstPoint + new Vector3(0,0.1f), p.Name, PathNameStyle);
|
||||
|
||||
Handles.color = ocolor;
|
||||
}
|
||||
|
||||
public static void DrawDot (Vector3 position, float size) {
|
||||
Handles.DotHandleCap(0, position, Quaternion.identity, size * HandleUtility.GetHandleSize(position), EventType.Ignore); //Handles.DotCap(0, position, Quaternion.identity, size * HandleUtility.GetHandleSize(position));
|
||||
}
|
||||
|
||||
public static void DrawBoundingBoxes (Transform transform, Skeleton skeleton) {
|
||||
foreach (var slot in skeleton.Slots) {
|
||||
var bba = slot.Attachment as BoundingBoxAttachment;
|
||||
if (bba != null) SpineHandles.DrawBoundingBox(slot, bba, transform);
|
||||
}
|
||||
}
|
||||
|
||||
public static void DrawBoundingBox (Slot slot, BoundingBoxAttachment box, Transform t) {
|
||||
if (box.Vertices.Length <= 2) return; // Handle cases where user creates a BoundingBoxAttachment but doesn't actually define it.
|
||||
|
||||
var worldVerts = new float[box.WorldVerticesLength];
|
||||
box.ComputeWorldVertices(slot, worldVerts);
|
||||
|
||||
Handles.color = Color.green;
|
||||
Vector3 lastVert = Vector3.zero;
|
||||
Vector3 vert = Vector3.zero;
|
||||
Vector3 firstVert = t.TransformPoint(new Vector3(worldVerts[0], worldVerts[1], 0));
|
||||
for (int i = 0; i < worldVerts.Length; i += 2) {
|
||||
vert.x = worldVerts[i];
|
||||
vert.y = worldVerts[i + 1];
|
||||
vert.z = 0;
|
||||
|
||||
vert = t.TransformPoint(vert);
|
||||
|
||||
if (i > 0)
|
||||
Handles.DrawLine(lastVert, vert);
|
||||
|
||||
lastVert = vert;
|
||||
}
|
||||
|
||||
Handles.DrawLine(lastVert, firstVert);
|
||||
}
|
||||
|
||||
public static void DrawPointAttachment (Bone bone, PointAttachment pointAttachment, Transform skeletonTransform) {
|
||||
if (bone == null) return;
|
||||
if (pointAttachment == null) return;
|
||||
|
||||
Vector2 localPos;
|
||||
pointAttachment.ComputeWorldPosition(bone, out localPos.x, out localPos.y);
|
||||
float localRotation = pointAttachment.ComputeWorldRotation(bone);
|
||||
Matrix4x4 m = Matrix4x4.TRS(localPos, Quaternion.Euler(0, 0, localRotation), Vector3.one) * Matrix4x4.TRS(Vector3.right * 0.25f, Quaternion.identity, Vector3.one);
|
||||
|
||||
DrawBoneCircle(skeletonTransform.TransformPoint(localPos), SpineHandles.PointColor, Vector3.back, 1.3f);
|
||||
DrawArrowhead(skeletonTransform.localToWorldMatrix * m);
|
||||
}
|
||||
|
||||
public static void DrawConstraints (Transform transform, Skeleton skeleton, float skeletonRenderScale = 1f) {
|
||||
Vector3 targetPos;
|
||||
Vector3 pos;
|
||||
bool active;
|
||||
Color handleColor;
|
||||
const float Thickness = 4f;
|
||||
Vector3 normal = transform.forward;
|
||||
|
||||
// Transform Constraints
|
||||
handleColor = SpineHandles.TransformContraintColor;
|
||||
foreach (var tc in skeleton.TransformConstraints) {
|
||||
var targetBone = tc.Target;
|
||||
targetPos = targetBone.GetWorldPosition(transform, skeletonRenderScale);
|
||||
|
||||
if (tc.TranslateMix > 0) {
|
||||
if (tc.TranslateMix != 1f) {
|
||||
Handles.color = handleColor;
|
||||
foreach (var b in tc.Bones) {
|
||||
pos = b.GetWorldPosition(transform, skeletonRenderScale);
|
||||
Handles.DrawDottedLine(targetPos, pos, Thickness);
|
||||
}
|
||||
}
|
||||
SpineHandles.DrawBoneCircle(targetPos, handleColor, normal, 1.3f * skeletonRenderScale);
|
||||
Handles.color = handleColor;
|
||||
SpineHandles.DrawCrosshairs(targetPos, 0.2f, targetBone.A, targetBone.B, targetBone.C, targetBone.D, transform, skeletonRenderScale);
|
||||
}
|
||||
}
|
||||
|
||||
// IK Constraints
|
||||
handleColor = SpineHandles.IkColor;
|
||||
foreach (var ikc in skeleton.IkConstraints) {
|
||||
Bone targetBone = ikc.Target;
|
||||
targetPos = targetBone.GetWorldPosition(transform, skeletonRenderScale);
|
||||
var bones = ikc.Bones;
|
||||
active = ikc.Mix > 0;
|
||||
if (active) {
|
||||
pos = bones.Items[0].GetWorldPosition(transform, skeletonRenderScale);
|
||||
switch (bones.Count) {
|
||||
case 1: {
|
||||
Handles.color = handleColor;
|
||||
Handles.DrawLine(targetPos, pos);
|
||||
SpineHandles.DrawBoneCircle(targetPos, handleColor, normal);
|
||||
var m = bones.Items[0].GetMatrix4x4();
|
||||
m.m03 = targetBone.WorldX * skeletonRenderScale;
|
||||
m.m13 = targetBone.WorldY * skeletonRenderScale;
|
||||
SpineHandles.DrawArrowhead(transform.localToWorldMatrix * m);
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
Bone childBone = bones.Items[1];
|
||||
Vector3 child = childBone.GetWorldPosition(transform, skeletonRenderScale);
|
||||
Handles.color = handleColor;
|
||||
Handles.DrawLine(child, pos);
|
||||
Handles.DrawLine(targetPos, child);
|
||||
SpineHandles.DrawBoneCircle(pos, handleColor, normal, 0.5f);
|
||||
SpineHandles.DrawBoneCircle(child, handleColor, normal, 0.5f);
|
||||
SpineHandles.DrawBoneCircle(targetPos, handleColor, normal);
|
||||
var m = childBone.GetMatrix4x4();
|
||||
m.m03 = targetBone.WorldX * skeletonRenderScale;
|
||||
m.m13 = targetBone.WorldY * skeletonRenderScale;
|
||||
SpineHandles.DrawArrowhead(transform.localToWorldMatrix * m);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
//Handles.Label(targetPos, ikc.Data.Name, SpineHandles.BoneNameStyle);
|
||||
}
|
||||
|
||||
// Path Constraints
|
||||
handleColor = SpineHandles.PathColor;
|
||||
foreach (var pc in skeleton.PathConstraints) {
|
||||
active = pc.TranslateMix > 0;
|
||||
if (active)
|
||||
foreach (var b in pc.Bones)
|
||||
SpineHandles.DrawBoneCircle(b.GetWorldPosition(transform, skeletonRenderScale), handleColor, normal, 1f * skeletonRenderScale);
|
||||
}
|
||||
}
|
||||
|
||||
static void DrawCrosshairs2D (Vector3 position, float scale, float skeletonRenderScale = 1f) {
|
||||
scale *= SpineEditorUtilities.Preferences.handleScale * skeletonRenderScale;
|
||||
Handles.DrawLine(position + new Vector3(-scale, 0), position + new Vector3(scale, 0));
|
||||
Handles.DrawLine(position + new Vector3(0, -scale), position + new Vector3(0, scale));
|
||||
}
|
||||
|
||||
static void DrawCrosshairs (Vector3 position, float scale, float a, float b, float c, float d, Transform transform, float skeletonRenderScale = 1f) {
|
||||
scale *= SpineEditorUtilities.Preferences.handleScale * skeletonRenderScale;
|
||||
|
||||
var xOffset = (Vector3)(new Vector2(a, c).normalized * scale);
|
||||
var yOffset = (Vector3)(new Vector2(b, d).normalized * scale);
|
||||
xOffset = transform.TransformDirection(xOffset);
|
||||
yOffset = transform.TransformDirection(yOffset);
|
||||
|
||||
Handles.DrawLine(position + xOffset, position - xOffset);
|
||||
Handles.DrawLine(position + yOffset, position - yOffset);
|
||||
}
|
||||
|
||||
static void DrawArrowhead2D (Vector3 pos, float localRotation, float scale = 1f) {
|
||||
scale *= SpineEditorUtilities.Preferences.handleScale;
|
||||
|
||||
SpineHandles.IKMaterial.SetPass(0);
|
||||
Graphics.DrawMeshNow(SpineHandles.ArrowheadMesh, Matrix4x4.TRS(pos, Quaternion.Euler(0, 0, localRotation), new Vector3(scale, scale, scale)));
|
||||
}
|
||||
|
||||
static void DrawArrowhead (Vector3 pos, Quaternion worldQuaternion) {
|
||||
Graphics.DrawMeshNow(SpineHandles.ArrowheadMesh, pos, worldQuaternion, 0);
|
||||
}
|
||||
|
||||
static void DrawArrowhead (Matrix4x4 m) {
|
||||
float s = SpineEditorUtilities.Preferences.handleScale;
|
||||
m.m00 *= s;
|
||||
m.m01 *= s;
|
||||
m.m02 *= s;
|
||||
m.m10 *= s;
|
||||
m.m11 *= s;
|
||||
m.m12 *= s;
|
||||
m.m20 *= s;
|
||||
m.m21 *= s;
|
||||
m.m22 *= s;
|
||||
|
||||
SpineHandles.IKMaterial.SetPass(0);
|
||||
Graphics.DrawMeshNow(SpineHandles.ArrowheadMesh, m);
|
||||
}
|
||||
|
||||
static void DrawBoneCircle (Vector3 pos, Color outlineColor, Vector3 normal, float scale = 1f) {
|
||||
scale *= SpineEditorUtilities.Preferences.handleScale;
|
||||
|
||||
Color o = Handles.color;
|
||||
Handles.color = outlineColor;
|
||||
float firstScale = 0.08f * scale;
|
||||
Handles.DrawSolidDisc(pos, normal, firstScale);
|
||||
const float Thickness = 0.03f;
|
||||
float secondScale = firstScale - (Thickness * SpineEditorUtilities.Preferences.handleScale * scale);
|
||||
|
||||
if (secondScale > 0f) {
|
||||
Handles.color = new Color(0.3f, 0.3f, 0.3f, 0.5f);
|
||||
Handles.DrawSolidDisc(pos, normal, secondScale);
|
||||
}
|
||||
|
||||
Handles.color = o;
|
||||
}
|
||||
|
||||
internal static void DrawCubicBezier (Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3) {
|
||||
Handles.DrawBezier(p0, p3, p1, p2, Handles.color, Texture2D.whiteTexture, 2f);
|
||||
// const float dotSize = 0.01f;
|
||||
// Quaternion q = Quaternion.identity;
|
||||
// Handles.DotCap(0, p0, q, dotSize);
|
||||
// Handles.DotCap(0, p1, q, dotSize);
|
||||
// Handles.DotCap(0, p2, q, dotSize);
|
||||
// Handles.DotCap(0, p3, q, dotSize);
|
||||
// Handles.DrawLine(p0, p1);
|
||||
// Handles.DrawLine(p3, p2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f4c97e41d3d90e24bbb40d634e6cc336
|
||||
timeCreated: 1563313275
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,376 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
public static class SpineInspectorUtility {
|
||||
|
||||
public static string Pluralize (int n, string singular, string plural) {
|
||||
return n + " " + (n == 1 ? singular : plural);
|
||||
}
|
||||
|
||||
public static string PluralThenS (int n) {
|
||||
return n == 1 ? "" : "s";
|
||||
}
|
||||
|
||||
public static string EmDash {
|
||||
get { return "\u2014"; }
|
||||
}
|
||||
|
||||
static GUIContent tempContent;
|
||||
internal static GUIContent TempContent (string text, Texture2D image = null, string tooltip = null) {
|
||||
if (tempContent == null) tempContent = new GUIContent();
|
||||
tempContent.text = text;
|
||||
tempContent.image = image;
|
||||
tempContent.tooltip = tooltip;
|
||||
return tempContent;
|
||||
}
|
||||
|
||||
public static void PropertyFieldWideLabel (SerializedProperty property, GUIContent label = null, float minimumLabelWidth = 150) {
|
||||
EditorGUIUtility.labelWidth = minimumLabelWidth;
|
||||
EditorGUILayout.PropertyField(property, label ?? TempContent(property.displayName, null, property.tooltip));
|
||||
EditorGUIUtility.labelWidth = 0; // Resets to default
|
||||
}
|
||||
|
||||
public static void PropertyFieldFitLabel (SerializedProperty property, GUIContent label = null, float extraSpace = 5f) {
|
||||
label = label ?? TempContent(property.displayName, null, property.tooltip);
|
||||
float width = GUI.skin.label.CalcSize(TempContent(label.text)).x + extraSpace;
|
||||
if (label.image != null)
|
||||
width += EditorGUIUtility.singleLineHeight;
|
||||
PropertyFieldWideLabel(property, label, width);
|
||||
}
|
||||
|
||||
/// <summary>Multi-edit-compatible version of EditorGUILayout.ToggleLeft(SerializedProperty)</summary>
|
||||
public static void ToggleLeftLayout (SerializedProperty property, GUIContent label = null, float width = 120f) {
|
||||
if (label == null) label = SpineInspectorUtility.TempContent(property.displayName, tooltip: property.tooltip);
|
||||
|
||||
if (property.hasMultipleDifferentValues) {
|
||||
bool previousShowMixedValue = EditorGUI.showMixedValue;
|
||||
EditorGUI.showMixedValue = true;
|
||||
|
||||
bool clicked = EditorGUILayout.ToggleLeft(label, property.boolValue, GUILayout.Width(width));
|
||||
if (clicked) property.boolValue = true; // Set all values to true when clicked.
|
||||
|
||||
EditorGUI.showMixedValue = previousShowMixedValue;
|
||||
} else {
|
||||
property.boolValue = EditorGUILayout.ToggleLeft(label, property.boolValue, GUILayout.Width(width));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Multi-edit-compatible version of EditorGUILayout.ToggleLeft(SerializedProperty)</summary>
|
||||
public static void ToggleLeft (Rect rect, SerializedProperty property, GUIContent label = null) {
|
||||
if (label == null) label = SpineInspectorUtility.TempContent(property.displayName, tooltip: property.tooltip);
|
||||
|
||||
if (property.hasMultipleDifferentValues) {
|
||||
bool previousShowMixedValue = EditorGUI.showMixedValue;
|
||||
EditorGUI.showMixedValue = true;
|
||||
|
||||
bool clicked = EditorGUI.ToggleLeft(rect, label, property.boolValue);
|
||||
if (clicked) property.boolValue = true; // Set all values to true when clicked.
|
||||
|
||||
EditorGUI.showMixedValue = previousShowMixedValue;
|
||||
} else {
|
||||
property.boolValue = EditorGUI.ToggleLeft(rect, label, property.boolValue);
|
||||
}
|
||||
}
|
||||
|
||||
public static bool UndoRedoPerformed (UnityEngine.Event current) {
|
||||
return current.type == EventType.ValidateCommand && current.commandName == "UndoRedoPerformed";
|
||||
}
|
||||
|
||||
public static Texture2D UnityIcon<T>() {
|
||||
return EditorGUIUtility.ObjectContent(null, typeof(T)).image as Texture2D;
|
||||
}
|
||||
|
||||
public static Texture2D UnityIcon(System.Type type) {
|
||||
return EditorGUIUtility.ObjectContent(null, type).image as Texture2D;
|
||||
}
|
||||
|
||||
public static FieldInfo GetNonPublicField (System.Type type, string fieldName) {
|
||||
return type.GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
|
||||
}
|
||||
|
||||
#region SerializedProperty Helpers
|
||||
public static SerializedProperty FindBaseOrSiblingProperty (this SerializedProperty property, string propertyName) {
|
||||
if (string.IsNullOrEmpty(propertyName)) return null;
|
||||
|
||||
SerializedProperty relativeProperty = property.serializedObject.FindProperty(propertyName); // baseProperty
|
||||
|
||||
// If base property is not found, look for the sibling property.
|
||||
if (relativeProperty == null) {
|
||||
string propertyPath = property.propertyPath;
|
||||
int localPathLength = property.name.Length;
|
||||
|
||||
string newPropertyPath = propertyPath.Remove(propertyPath.Length - localPathLength, localPathLength) + propertyName;
|
||||
relativeProperty = property.serializedObject.FindProperty(newPropertyPath);
|
||||
|
||||
// If a direct sibling property was not found, try to find the sibling of the array.
|
||||
if (relativeProperty == null && property.isArray) {
|
||||
int propertyPathLength = propertyPath.Length;
|
||||
|
||||
int dotCount = 0;
|
||||
const int SiblingOfListDotCount = 3;
|
||||
for (int i = 1; i < propertyPathLength; i++) {
|
||||
if (propertyPath[propertyPathLength - i] == '.') {
|
||||
dotCount++;
|
||||
if (dotCount >= SiblingOfListDotCount) {
|
||||
localPathLength = i - 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
newPropertyPath = propertyPath.Remove(propertyPath.Length - localPathLength, localPathLength) + propertyName;
|
||||
relativeProperty = property.serializedObject.FindProperty(newPropertyPath);
|
||||
}
|
||||
}
|
||||
|
||||
return relativeProperty;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Layout Scopes
|
||||
static GUIStyle grayMiniLabel;
|
||||
public static GUIStyle GrayMiniLabel {
|
||||
get {
|
||||
if (grayMiniLabel == null) {
|
||||
grayMiniLabel = new GUIStyle(EditorStyles.centeredGreyMiniLabel) {
|
||||
alignment = TextAnchor.UpperLeft
|
||||
};
|
||||
}
|
||||
return grayMiniLabel;
|
||||
}
|
||||
}
|
||||
|
||||
public class LabelWidthScope : System.IDisposable {
|
||||
public LabelWidthScope (float minimumLabelWidth = 190f) {
|
||||
EditorGUIUtility.labelWidth = minimumLabelWidth;
|
||||
}
|
||||
|
||||
public void Dispose () {
|
||||
EditorGUIUtility.labelWidth = 0f;
|
||||
}
|
||||
}
|
||||
|
||||
public class IndentScope : System.IDisposable {
|
||||
public IndentScope () { EditorGUI.indentLevel++; }
|
||||
public void Dispose () { EditorGUI.indentLevel--; }
|
||||
}
|
||||
|
||||
public class BoxScope : System.IDisposable {
|
||||
readonly bool indent;
|
||||
|
||||
static GUIStyle boxScopeStyle;
|
||||
public static GUIStyle BoxScopeStyle {
|
||||
get {
|
||||
if (boxScopeStyle == null) {
|
||||
boxScopeStyle = new GUIStyle(EditorStyles.helpBox);
|
||||
RectOffset p = boxScopeStyle.padding; // RectOffset is a class
|
||||
p.right += 6;
|
||||
p.top += 1;
|
||||
p.left += 3;
|
||||
}
|
||||
|
||||
return boxScopeStyle;
|
||||
}
|
||||
}
|
||||
|
||||
public BoxScope (bool indent = true) {
|
||||
this.indent = indent;
|
||||
EditorGUILayout.BeginVertical(BoxScopeStyle);
|
||||
if (indent) EditorGUI.indentLevel++;
|
||||
}
|
||||
|
||||
public void Dispose () {
|
||||
if (indent) EditorGUI.indentLevel--;
|
||||
EditorGUILayout.EndVertical();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Button
|
||||
const float CenterButtonMaxWidth = 270f;
|
||||
const float CenterButtonHeight = 30f;
|
||||
static GUIStyle spineButtonStyle;
|
||||
static GUIStyle SpineButtonStyle {
|
||||
get {
|
||||
if (spineButtonStyle == null) {
|
||||
spineButtonStyle = new GUIStyle(GUI.skin.button);
|
||||
spineButtonStyle.padding = new RectOffset(10, 10, 10, 10);
|
||||
}
|
||||
return spineButtonStyle;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool LargeCenteredButton (string label, bool sideSpace = true, float maxWidth = CenterButtonMaxWidth) {
|
||||
if (sideSpace) {
|
||||
bool clicked;
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
EditorGUILayout.Space();
|
||||
clicked = GUILayout.Button(label, SpineButtonStyle, GUILayout.MaxWidth(maxWidth), GUILayout.Height(CenterButtonHeight));
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
return clicked;
|
||||
} else {
|
||||
return GUILayout.Button(label, GUILayout.MaxWidth(CenterButtonMaxWidth), GUILayout.Height(CenterButtonHeight));
|
||||
}
|
||||
}
|
||||
|
||||
public static bool LargeCenteredButton (GUIContent content, bool sideSpace = true, float maxWidth = CenterButtonMaxWidth) {
|
||||
if (sideSpace) {
|
||||
bool clicked;
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
EditorGUILayout.Space();
|
||||
clicked = GUILayout.Button(content, SpineButtonStyle, GUILayout.MaxWidth(maxWidth), GUILayout.Height(CenterButtonHeight));
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
return clicked;
|
||||
} else {
|
||||
return GUILayout.Button(content, GUILayout.MaxWidth(CenterButtonMaxWidth), GUILayout.Height(CenterButtonHeight));
|
||||
}
|
||||
}
|
||||
|
||||
public static bool CenteredButton (GUIContent content, float height = 20f, bool sideSpace = true, float maxWidth = CenterButtonMaxWidth) {
|
||||
if (sideSpace) {
|
||||
bool clicked;
|
||||
using (new EditorGUILayout.HorizontalScope()) {
|
||||
EditorGUILayout.Space();
|
||||
clicked = GUILayout.Button(content, GUILayout.MaxWidth(maxWidth), GUILayout.Height(height));
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
return clicked;
|
||||
} else {
|
||||
return GUILayout.Button(content, GUILayout.MaxWidth(maxWidth), GUILayout.Height(height));
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Multi-Editing Helpers
|
||||
public static bool TargetsUseSameData (SerializedObject so) {
|
||||
if (so.isEditingMultipleObjects) {
|
||||
int n = so.targetObjects.Length;
|
||||
var first = so.targetObjects[0] as IHasSkeletonDataAsset;
|
||||
for (int i = 1; i < n; i++) {
|
||||
var sr = so.targetObjects[i] as IHasSkeletonDataAsset;
|
||||
if (sr != null && sr.SkeletonDataAsset != first.SkeletonDataAsset)
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static SerializedObject GetRenderersSerializedObject (SerializedObject serializedObject) {
|
||||
if (serializedObject.isEditingMultipleObjects) {
|
||||
var renderers = new List<Object>();
|
||||
foreach (var o in serializedObject.targetObjects) {
|
||||
var component = o as Component;
|
||||
if (component != null) {
|
||||
var renderer = component.GetComponent<Renderer>();
|
||||
if (renderer != null)
|
||||
renderers.Add(renderer);
|
||||
}
|
||||
}
|
||||
return new SerializedObject(renderers.ToArray());
|
||||
} else {
|
||||
var component = serializedObject.targetObject as Component;
|
||||
if (component != null) {
|
||||
var renderer = component.GetComponent<Renderer>();
|
||||
if (renderer != null)
|
||||
return new SerializedObject(renderer);
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
#endregion
|
||||
|
||||
#region Sorting Layer Field Helpers
|
||||
static readonly GUIContent SortingLayerLabel = new GUIContent("Sorting Layer", "MeshRenderer.sortingLayerID");
|
||||
static readonly GUIContent OrderInLayerLabel = new GUIContent("Order in Layer", "MeshRenderer.sortingOrder");
|
||||
|
||||
static MethodInfo m_SortingLayerFieldMethod;
|
||||
static MethodInfo SortingLayerFieldMethod {
|
||||
get {
|
||||
if (m_SortingLayerFieldMethod == null)
|
||||
m_SortingLayerFieldMethod = typeof(EditorGUILayout).GetMethod("SortingLayerField", BindingFlags.Static | BindingFlags.NonPublic, null, new [] { typeof(GUIContent), typeof(SerializedProperty), typeof(GUIStyle) }, null);
|
||||
|
||||
return m_SortingLayerFieldMethod;
|
||||
}
|
||||
}
|
||||
|
||||
public struct SerializedSortingProperties {
|
||||
public SerializedObject renderer;
|
||||
public SerializedProperty sortingLayerID;
|
||||
public SerializedProperty sortingOrder;
|
||||
|
||||
public SerializedSortingProperties (Renderer r) : this(new SerializedObject(r)) {}
|
||||
public SerializedSortingProperties (Object[] renderers) : this(new SerializedObject(renderers)) {}
|
||||
|
||||
public SerializedSortingProperties (SerializedObject rendererSerializedObject) {
|
||||
renderer = rendererSerializedObject;
|
||||
sortingLayerID = renderer.FindProperty("m_SortingLayerID");
|
||||
sortingOrder = renderer.FindProperty("m_SortingOrder");
|
||||
}
|
||||
|
||||
public void ApplyModifiedProperties () {
|
||||
renderer.ApplyModifiedProperties();
|
||||
|
||||
// SetDirty
|
||||
if (renderer.isEditingMultipleObjects)
|
||||
foreach (var o in renderer.targetObjects)
|
||||
EditorUtility.SetDirty(o);
|
||||
else
|
||||
EditorUtility.SetDirty(renderer.targetObject);
|
||||
}
|
||||
}
|
||||
|
||||
public static void SortingPropertyFields (SerializedSortingProperties prop, bool applyModifiedProperties) {
|
||||
if (applyModifiedProperties)
|
||||
EditorGUI.BeginChangeCheck();
|
||||
|
||||
if (SpineInspectorUtility.SortingLayerFieldMethod != null && prop.sortingLayerID != null)
|
||||
SpineInspectorUtility.SortingLayerFieldMethod.Invoke(null, new object[] { SortingLayerLabel, prop.sortingLayerID, EditorStyles.popup } );
|
||||
else
|
||||
EditorGUILayout.PropertyField(prop.sortingLayerID);
|
||||
|
||||
EditorGUILayout.PropertyField(prop.sortingOrder, OrderInLayerLabel);
|
||||
|
||||
if (applyModifiedProperties && EditorGUI.EndChangeCheck())
|
||||
prop.ApplyModifiedProperties();
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 663715b5714e2db499192c8d91ef1f86
|
||||
timeCreated: 1457404957
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,246 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#pragma warning disable 0219
|
||||
|
||||
#define SPINE_SKELETONMECANIM
|
||||
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
#define NEWPLAYMODECALLBACKS
|
||||
#endif
|
||||
|
||||
#if UNITY_2018_3 || UNITY_2019 || UNITY_2018_3_OR_NEWER
|
||||
#define NEW_PREFAB_SYSTEM
|
||||
#endif
|
||||
|
||||
#if UNITY_2018 || UNITY_2019 || UNITY_2018_3_OR_NEWER
|
||||
#define NEWHIERARCHYWINDOWCALLBACKS
|
||||
#endif
|
||||
|
||||
#if UNITY_2017_1_OR_NEWER
|
||||
#define BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
#endif
|
||||
|
||||
#if BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
|
||||
public class SpineMaskUtilities {
|
||||
|
||||
private const string MATERIAL_FILENAME_SUFFIX_INSIDE_MASK = "_InsideMask";
|
||||
private const string MATERIAL_FILENAME_SUFFIX_OUTSIDE_MASK = "_OutsideMask";
|
||||
|
||||
public static void EditorAssignSpriteMaskMaterials(SkeletonRenderer skeleton) {
|
||||
var maskMaterials = skeleton.maskMaterials;
|
||||
var maskInteraction = skeleton.maskInteraction;
|
||||
var meshRenderer = skeleton.GetComponent<MeshRenderer>();
|
||||
|
||||
if (maskMaterials.materialsMaskDisabled.Length > 0 && maskMaterials.materialsMaskDisabled[0] != null &&
|
||||
maskInteraction == SpriteMaskInteraction.None) {
|
||||
meshRenderer.materials = maskMaterials.materialsMaskDisabled;
|
||||
}
|
||||
else if (maskInteraction == SpriteMaskInteraction.VisibleInsideMask) {
|
||||
if (maskMaterials.materialsInsideMask.Length == 0 || maskMaterials.materialsInsideMask[0] == null)
|
||||
EditorInitSpriteMaskMaterialsInsideMask(skeleton);
|
||||
meshRenderer.materials = maskMaterials.materialsInsideMask;
|
||||
}
|
||||
else if (maskInteraction == SpriteMaskInteraction.VisibleOutsideMask) {
|
||||
if (maskMaterials.materialsOutsideMask.Length == 0 || maskMaterials.materialsOutsideMask[0] == null)
|
||||
EditorInitSpriteMaskMaterialsOutsideMask(skeleton);
|
||||
meshRenderer.materials = maskMaterials.materialsOutsideMask;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool AreMaskMaterialsMissing(SkeletonRenderer skeleton) {
|
||||
var maskMaterials = skeleton.maskMaterials;
|
||||
var maskInteraction = skeleton.maskInteraction;
|
||||
|
||||
if (maskInteraction == SpriteMaskInteraction.VisibleInsideMask) {
|
||||
return (maskMaterials.materialsInsideMask.Length == 0 || maskMaterials.materialsInsideMask[0] == null);
|
||||
}
|
||||
else if (maskInteraction == SpriteMaskInteraction.VisibleOutsideMask) {
|
||||
return (maskMaterials.materialsOutsideMask.Length == 0 || maskMaterials.materialsOutsideMask[0] == null);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void EditorInitMaskMaterials(SkeletonRenderer skeleton, SkeletonRenderer.SpriteMaskInteractionMaterials maskMaterials, SpriteMaskInteraction maskType) {
|
||||
if (maskType == SpriteMaskInteraction.None) {
|
||||
EditorConfirmDisabledMaskMaterialsInit(skeleton);
|
||||
}
|
||||
else if (maskType == SpriteMaskInteraction.VisibleInsideMask) {
|
||||
EditorInitSpriteMaskMaterialsInsideMask(skeleton);
|
||||
}
|
||||
else if (maskType == SpriteMaskInteraction.VisibleOutsideMask) {
|
||||
EditorInitSpriteMaskMaterialsOutsideMask(skeleton);
|
||||
}
|
||||
}
|
||||
|
||||
public static void EditorDeleteMaskMaterials(SkeletonRenderer.SpriteMaskInteractionMaterials maskMaterials, SpriteMaskInteraction maskType) {
|
||||
Material[] targetMaterials;
|
||||
if (maskType == SpriteMaskInteraction.VisibleInsideMask) {
|
||||
targetMaterials = maskMaterials.materialsInsideMask;
|
||||
}
|
||||
else if (maskType == SpriteMaskInteraction.VisibleOutsideMask) {
|
||||
targetMaterials = maskMaterials.materialsOutsideMask;
|
||||
}
|
||||
else {
|
||||
Debug.LogWarning("EditorDeleteMaskMaterials: Normal materials are kept as a reference and shall never be deleted.");
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < targetMaterials.Length; ++i) {
|
||||
var material = targetMaterials[i];
|
||||
if (material != null) {
|
||||
string materialPath = UnityEditor.AssetDatabase.GetAssetPath(material);
|
||||
UnityEditor.AssetDatabase.DeleteAsset(materialPath);
|
||||
Debug.Log(string.Concat("Deleted material '", materialPath, "'"));
|
||||
}
|
||||
}
|
||||
|
||||
if (maskType == SpriteMaskInteraction.VisibleInsideMask) {
|
||||
maskMaterials.materialsInsideMask = new Material[0];
|
||||
}
|
||||
else if (maskType == SpriteMaskInteraction.VisibleOutsideMask) {
|
||||
maskMaterials.materialsOutsideMask = new Material[0];
|
||||
}
|
||||
}
|
||||
|
||||
private static void EditorInitSpriteMaskMaterialsInsideMask(SkeletonRenderer skeleton) {
|
||||
var maskMaterials = skeleton.maskMaterials;
|
||||
EditorInitSpriteMaskMaterialsForMaskType(skeleton, SkeletonRenderer.STENCIL_COMP_MASKINTERACTION_VISIBLE_INSIDE,
|
||||
ref maskMaterials.materialsInsideMask);
|
||||
}
|
||||
|
||||
private static void EditorInitSpriteMaskMaterialsOutsideMask(SkeletonRenderer skeleton) {
|
||||
var maskMaterials = skeleton.maskMaterials;
|
||||
EditorInitSpriteMaskMaterialsForMaskType(skeleton, SkeletonRenderer.STENCIL_COMP_MASKINTERACTION_VISIBLE_OUTSIDE,
|
||||
ref maskMaterials.materialsOutsideMask);
|
||||
}
|
||||
|
||||
private static void EditorInitSpriteMaskMaterialsForMaskType(SkeletonRenderer skeleton, UnityEngine.Rendering.CompareFunction maskFunction,
|
||||
ref Material[] materialsToFill) {
|
||||
if (!EditorConfirmDisabledMaskMaterialsInit(skeleton))
|
||||
return;
|
||||
|
||||
var maskMaterials = skeleton.maskMaterials;
|
||||
var originalMaterials = maskMaterials.materialsMaskDisabled;
|
||||
materialsToFill = new Material[originalMaterials.Length];
|
||||
for (int i = 0; i < originalMaterials.Length; i++) {
|
||||
Material newMaterial = null;
|
||||
|
||||
if (!Application.isPlaying) {
|
||||
newMaterial = EditorCreateOrLoadMaskMaterialAsset(maskMaterials, maskFunction, originalMaterials[i]);
|
||||
}
|
||||
if (newMaterial == null) {
|
||||
newMaterial = new Material(originalMaterials[i]);
|
||||
newMaterial.SetFloat(SkeletonRenderer.STENCIL_COMP_PARAM_ID, (int)maskFunction);
|
||||
}
|
||||
materialsToFill[i] = newMaterial;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool EditorConfirmDisabledMaskMaterialsInit(SkeletonRenderer skeleton) {
|
||||
var maskMaterials = skeleton.maskMaterials;
|
||||
if (maskMaterials.materialsMaskDisabled.Length > 0 && maskMaterials.materialsMaskDisabled[0] != null) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var meshRenderer = skeleton.GetComponent<MeshRenderer>();
|
||||
Material[] currentMaterials = meshRenderer.sharedMaterials;
|
||||
|
||||
if (currentMaterials.Length == 0 || currentMaterials[0] == null) {
|
||||
Debug.LogWarning("No materials found assigned at " + skeleton.name);
|
||||
return false;
|
||||
}
|
||||
|
||||
// We have to be sure that there has not been a recompilation or similar events that led to
|
||||
// inside- or outside-mask materials being assigned to meshRenderer.sharedMaterials.
|
||||
string firstMaterialPath = UnityEditor.AssetDatabase.GetAssetPath(currentMaterials[0]);
|
||||
if (firstMaterialPath.Contains(MATERIAL_FILENAME_SUFFIX_INSIDE_MASK) ||
|
||||
firstMaterialPath.Contains(MATERIAL_FILENAME_SUFFIX_OUTSIDE_MASK)) {
|
||||
|
||||
maskMaterials.materialsMaskDisabled = new Material[currentMaterials.Length];
|
||||
for (int i = 0; i < currentMaterials.Length; ++i) {
|
||||
string path = UnityEditor.AssetDatabase.GetAssetPath(currentMaterials[i]);
|
||||
string correctPath = null;
|
||||
if (path.Contains(MATERIAL_FILENAME_SUFFIX_INSIDE_MASK)) {
|
||||
correctPath = path.Replace(MATERIAL_FILENAME_SUFFIX_INSIDE_MASK, "");
|
||||
}
|
||||
else if (path.Contains(MATERIAL_FILENAME_SUFFIX_OUTSIDE_MASK)) {
|
||||
correctPath = path.Replace(MATERIAL_FILENAME_SUFFIX_OUTSIDE_MASK, "");
|
||||
}
|
||||
|
||||
if (correctPath != null) {
|
||||
Material material = UnityEditor.AssetDatabase.LoadAssetAtPath<Material>(correctPath);
|
||||
if (material == null)
|
||||
Debug.LogWarning("No original ignore-mask material found for path " + correctPath);
|
||||
maskMaterials.materialsMaskDisabled[i] = material;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
maskMaterials.materialsMaskDisabled = currentMaterials;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static Material EditorCreateOrLoadMaskMaterialAsset(SkeletonRenderer.SpriteMaskInteractionMaterials maskMaterials,
|
||||
UnityEngine.Rendering.CompareFunction maskFunction, Material originalMaterial) {
|
||||
string originalMaterialPath = UnityEditor.AssetDatabase.GetAssetPath(originalMaterial);
|
||||
int posOfExtensionDot = originalMaterialPath.LastIndexOf('.');
|
||||
string materialPath = (maskFunction == SkeletonRenderer.STENCIL_COMP_MASKINTERACTION_VISIBLE_INSIDE) ?
|
||||
originalMaterialPath.Insert(posOfExtensionDot, MATERIAL_FILENAME_SUFFIX_INSIDE_MASK) :
|
||||
originalMaterialPath.Insert(posOfExtensionDot, MATERIAL_FILENAME_SUFFIX_OUTSIDE_MASK);
|
||||
|
||||
Material material = UnityEditor.AssetDatabase.LoadAssetAtPath<Material>(materialPath);
|
||||
if (material != null) {
|
||||
return material;
|
||||
}
|
||||
|
||||
material = new Material(originalMaterial);
|
||||
material.SetFloat(SkeletonRenderer.STENCIL_COMP_PARAM_ID, (int)maskFunction);
|
||||
|
||||
UnityEditor.AssetDatabase.CreateAsset(material, materialPath);
|
||||
Debug.Log(string.Concat("Created material '", materialPath, "' for mask interaction based on '", originalMaterialPath, "'."));
|
||||
UnityEditor.EditorUtility.SetDirty(material);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
return material;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // BUILT_IN_SPRITE_MASK_COMPONENT
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c1b3a9ddacb550458bb86affdf77bf5
|
||||
timeCreated: 1550564907
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,317 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#if UNITY_2017_2_OR_NEWER
|
||||
#define NEWPLAYMODECALLBACKS
|
||||
#endif
|
||||
|
||||
#if UNITY_2018_3_OR_NEWER
|
||||
#define NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
#endif
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
using System.Threading;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
|
||||
public class SpinePreferences : ScriptableObject {
|
||||
|
||||
#if NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
static int wasPreferencesDirCreated = 0;
|
||||
static int wasPreferencesAssetCreated = 0;
|
||||
#endif
|
||||
|
||||
public const string SPINE_SETTINGS_ASSET_PATH = "Assets/Editor/SpineSettings.asset";
|
||||
|
||||
#if SPINE_TK2D
|
||||
internal const float DEFAULT_DEFAULT_SCALE = 1f;
|
||||
#else
|
||||
internal const float DEFAULT_DEFAULT_SCALE = 0.01f;
|
||||
#endif
|
||||
public float defaultScale = DEFAULT_DEFAULT_SCALE;
|
||||
|
||||
internal const float DEFAULT_DEFAULT_MIX = 0.2f;
|
||||
public float defaultMix = DEFAULT_DEFAULT_MIX;
|
||||
|
||||
internal const string DEFAULT_DEFAULT_SHADER = "Spine/Skeleton";
|
||||
public string defaultShader = DEFAULT_DEFAULT_SHADER;
|
||||
|
||||
internal const float DEFAULT_DEFAULT_ZSPACING = 0f;
|
||||
public float defaultZSpacing = DEFAULT_DEFAULT_ZSPACING;
|
||||
|
||||
internal const bool DEFAULT_DEFAULT_INSTANTIATE_LOOP = true;
|
||||
public bool defaultInstantiateLoop = DEFAULT_DEFAULT_INSTANTIATE_LOOP;
|
||||
|
||||
internal const bool DEFAULT_SHOW_HIERARCHY_ICONS = true;
|
||||
public bool showHierarchyIcons = DEFAULT_SHOW_HIERARCHY_ICONS;
|
||||
|
||||
internal const bool DEFAULT_SET_TEXTUREIMPORTER_SETTINGS = true;
|
||||
public bool setTextureImporterSettings = DEFAULT_SET_TEXTUREIMPORTER_SETTINGS;
|
||||
|
||||
internal const string DEFAULT_TEXTURE_SETTINGS_REFERENCE = "";
|
||||
public string textureSettingsReference = DEFAULT_TEXTURE_SETTINGS_REFERENCE;
|
||||
|
||||
public bool UsesPMAWorkflow {
|
||||
get {
|
||||
return IsPMAWorkflow(textureSettingsReference);
|
||||
}
|
||||
}
|
||||
public static bool IsPMAWorkflow(string textureSettingsReference) {
|
||||
if (textureSettingsReference == null)
|
||||
return true;
|
||||
string settingsReference = textureSettingsReference.ToLower();
|
||||
if (settingsReference.Contains("straight") || !settingsReference.Contains("pma"))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
public const string DEFAULT_BLEND_MODE_MULTIPLY_MATERIAL = "SkeletonPMAMultiply";
|
||||
public const string DEFAULT_BLEND_MODE_SCREEN_MATERIAL = "SkeletonPMAScreen";
|
||||
public const string DEFAULT_BLEND_MODE_ADDITIVE_MATERIAL = "SkeletonPMAAdditive";
|
||||
|
||||
public Material blendModeMaterialMultiply = null;
|
||||
public Material blendModeMaterialScreen = null;
|
||||
public Material blendModeMaterialAdditive = null;
|
||||
|
||||
public string FindPathOfAsset (string assetName) {
|
||||
string typeSearchString = assetName;
|
||||
string[] guids = AssetDatabase.FindAssets(typeSearchString);
|
||||
if (guids.Length > 0) {
|
||||
return AssetDatabase.GUIDToAssetPath(guids[0]);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Material BlendModeMaterialMultiply {
|
||||
get {
|
||||
if (blendModeMaterialMultiply == null) {
|
||||
string path = FindPathOfAsset(DEFAULT_BLEND_MODE_MULTIPLY_MATERIAL);
|
||||
blendModeMaterialMultiply = AssetDatabase.LoadAssetAtPath<Material>(path);
|
||||
}
|
||||
return blendModeMaterialMultiply;
|
||||
}
|
||||
}
|
||||
public Material BlendModeMaterialScreen {
|
||||
get {
|
||||
if (blendModeMaterialScreen == null) {
|
||||
string path = FindPathOfAsset(DEFAULT_BLEND_MODE_SCREEN_MATERIAL);
|
||||
blendModeMaterialScreen = AssetDatabase.LoadAssetAtPath<Material>(path);
|
||||
}
|
||||
return blendModeMaterialScreen;
|
||||
}
|
||||
}
|
||||
public Material BlendModeMaterialAdditive {
|
||||
get {
|
||||
if (blendModeMaterialAdditive == null) {
|
||||
string path = FindPathOfAsset(DEFAULT_BLEND_MODE_ADDITIVE_MATERIAL);
|
||||
blendModeMaterialAdditive = AssetDatabase.LoadAssetAtPath<Material>(path);
|
||||
}
|
||||
return blendModeMaterialAdditive;
|
||||
}
|
||||
}
|
||||
|
||||
internal const bool DEFAULT_ATLASTXT_WARNING = true;
|
||||
public bool atlasTxtImportWarning = DEFAULT_ATLASTXT_WARNING;
|
||||
|
||||
internal const bool DEFAULT_TEXTUREIMPORTER_WARNING = true;
|
||||
public bool textureImporterWarning = DEFAULT_TEXTUREIMPORTER_WARNING;
|
||||
|
||||
internal const bool DEFAULT_COMPONENTMATERIAL_WARNING = true;
|
||||
public bool componentMaterialWarning = DEFAULT_COMPONENTMATERIAL_WARNING;
|
||||
|
||||
public const float DEFAULT_MIPMAPBIAS = -0.5f;
|
||||
|
||||
public const bool DEFAULT_AUTO_RELOAD_SCENESKELETONS = true;
|
||||
public bool autoReloadSceneSkeletons = DEFAULT_AUTO_RELOAD_SCENESKELETONS;
|
||||
|
||||
public const string SCENE_ICONS_SCALE_KEY = "SPINE_SCENE_ICONS_SCALE";
|
||||
internal const float DEFAULT_SCENE_ICONS_SCALE = 1f;
|
||||
[Range(0.01f, 2f)]
|
||||
public float handleScale = DEFAULT_SCENE_ICONS_SCALE;
|
||||
|
||||
public const bool DEFAULT_MECANIM_EVENT_INCLUDE_FOLDERNAME = true;
|
||||
public bool mecanimEventIncludeFolderName = DEFAULT_MECANIM_EVENT_INCLUDE_FOLDERNAME;
|
||||
|
||||
// Timeline extension module
|
||||
public const bool DEFAULT_TIMELINE_USE_BLEND_DURATION = true;
|
||||
public bool timelineUseBlendDuration = DEFAULT_TIMELINE_USE_BLEND_DURATION;
|
||||
|
||||
#if NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
public static void Load () {
|
||||
GetOrCreateSettings();
|
||||
}
|
||||
|
||||
static SpinePreferences settings = null;
|
||||
|
||||
internal static SpinePreferences GetOrCreateSettings () {
|
||||
if (settings != null)
|
||||
return settings;
|
||||
|
||||
settings = AssetDatabase.LoadAssetAtPath<SpinePreferences>(SPINE_SETTINGS_ASSET_PATH);
|
||||
if (settings == null)
|
||||
settings = FindSpinePreferences();
|
||||
if (settings == null)
|
||||
{
|
||||
settings = ScriptableObject.CreateInstance<SpinePreferences>();
|
||||
SpineEditorUtilities.OldPreferences.CopyOldToNewPreferences(ref settings);
|
||||
// Multiple threads may be calling this method during import, creating the folder
|
||||
// multiple times with ascending number suffix. Atomic wasPreferencesDirCreated int
|
||||
// variable is used to prevent any redundant create operations.
|
||||
if (!AssetDatabase.IsValidFolder("Assets/Editor") && Interlocked.Exchange(ref wasPreferencesDirCreated, 1) == 0)
|
||||
AssetDatabase.CreateFolder("Assets", "Editor");
|
||||
if (Interlocked.Exchange(ref wasPreferencesAssetCreated, 1) == 0)
|
||||
AssetDatabase.CreateAsset(settings, SPINE_SETTINGS_ASSET_PATH);
|
||||
}
|
||||
return settings;
|
||||
}
|
||||
|
||||
static SpinePreferences FindSpinePreferences () {
|
||||
string typeSearchString = " t:SpinePreferences";
|
||||
string[] guids = AssetDatabase.FindAssets(typeSearchString);
|
||||
foreach (string guid in guids) {
|
||||
string path = AssetDatabase.GUIDToAssetPath(guid);
|
||||
var preferences = AssetDatabase.LoadAssetAtPath<SpinePreferences>(path);
|
||||
if (preferences != null)
|
||||
return preferences;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void HandlePreferencesGUI (SerializedObject settings) {
|
||||
|
||||
float prevLabelWidth = EditorGUIUtility.labelWidth;
|
||||
EditorGUIUtility.labelWidth = 250;
|
||||
|
||||
using (new EditorGUI.IndentLevelScope()) {
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(settings.FindProperty("showHierarchyIcons"), new GUIContent("Show Hierarchy Icons", "Show relevant icons on GameObjects with Spine Components on them. Disable this if you have large, complex scenes."));
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
#if NEWPLAYMODECALLBACKS
|
||||
SpineEditorUtilities.HierarchyHandler.IconsOnPlaymodeStateChanged(PlayModeStateChange.EnteredEditMode);
|
||||
#else
|
||||
SpineEditorUtilities.HierarchyHandler.IconsOnPlaymodeStateChanged();
|
||||
#endif
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(settings.FindProperty("autoReloadSceneSkeletons"), new GUIContent("Auto-reload scene components", "Reloads Skeleton components in the scene whenever their SkeletonDataAsset is modified. This makes it so changes in the SkeletonDataAsset inspector are immediately reflected. This may be slow when your scenes have large numbers of SkeletonRenderers or SkeletonGraphic."));
|
||||
|
||||
EditorGUILayout.Separator();
|
||||
EditorGUILayout.LabelField("Auto-Import Settings", EditorStyles.boldLabel);
|
||||
{
|
||||
SpineEditorUtilities.FloatPropertyField(settings.FindProperty("defaultMix"), new GUIContent("Default Mix", "The Default Mix Duration for newly imported SkeletonDataAssets."), min: 0f);
|
||||
SpineEditorUtilities.FloatPropertyField(settings.FindProperty("defaultScale"), new GUIContent("Default SkeletonData Scale", "The Default skeleton import scale for newly imported SkeletonDataAssets."), min: 0.0000001f);
|
||||
|
||||
SpineEditorUtilities.ShaderPropertyField(settings.FindProperty("defaultShader"), new GUIContent("Default Shader"), SpinePreferences.DEFAULT_DEFAULT_SHADER);
|
||||
|
||||
EditorGUILayout.PropertyField(settings.FindProperty("setTextureImporterSettings"), new GUIContent("Apply Atlas Texture Settings", "Apply reference settings for Texture Importers."));
|
||||
var textureSettingsRef = settings.FindProperty("textureSettingsReference");
|
||||
SpineEditorUtilities.PresetAssetPropertyField(textureSettingsRef, new GUIContent("Atlas Texture Settings", "Apply the selected texture import settings at newly imported atlas textures. When exporting atlas textures from Spine with \"Premultiply alpha\" enabled (the default), you can leave it at \"PMATexturePreset\". If you have disabled \"Premultiply alpha\", set it to \"StraightAlphaTexturePreset\". You can also create your own TextureImporter Preset asset and assign it here."));
|
||||
if (string.IsNullOrEmpty(textureSettingsRef.stringValue)) {
|
||||
var pmaTextureSettingsReferenceGUIDS = AssetDatabase.FindAssets("PMATexturePreset");
|
||||
if (pmaTextureSettingsReferenceGUIDS.Length > 0) {
|
||||
var assetPath = AssetDatabase.GUIDToAssetPath(pmaTextureSettingsReferenceGUIDS[0]);
|
||||
if (!string.IsNullOrEmpty(assetPath))
|
||||
textureSettingsRef.stringValue = assetPath;
|
||||
}
|
||||
}
|
||||
|
||||
EditorGUILayout.PropertyField(settings.FindProperty("blendModeMaterialAdditive"), new GUIContent("Additive Material", "Additive blend mode Material template."));
|
||||
EditorGUILayout.PropertyField(settings.FindProperty("blendModeMaterialMultiply"), new GUIContent("Multiply Material", "Multiply blend mode Material template."));
|
||||
EditorGUILayout.PropertyField(settings.FindProperty("blendModeMaterialScreen"), new GUIContent("Screen Material", "Screen blend mode Material template."));
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Warnings", EditorStyles.boldLabel);
|
||||
{
|
||||
EditorGUILayout.PropertyField(settings.FindProperty("atlasTxtImportWarning"), new GUIContent("Atlas Extension Warning", "Log a warning and recommendation whenever a `.atlas` file is found."));
|
||||
EditorGUILayout.PropertyField(settings.FindProperty("textureImporterWarning"), new GUIContent("Texture Settings Warning", "Log a warning and recommendation whenever Texture Import Settings are detected that could lead to undesired effects, e.g. white border artifacts."));
|
||||
EditorGUILayout.PropertyField(settings.FindProperty("componentMaterialWarning"), new GUIContent("Component & Material Warning", "Log a warning and recommendation whenever Component and Material settings are not compatible."));
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Editor Instantiation", EditorStyles.boldLabel);
|
||||
{
|
||||
EditorGUILayout.Slider(settings.FindProperty("defaultZSpacing"), -0.1f, 0f, new GUIContent("Default Slot Z-Spacing"));
|
||||
EditorGUILayout.PropertyField(settings.FindProperty("defaultInstantiateLoop"), new GUIContent("Default Loop", "Spawn Spine GameObjects with loop enabled."));
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Mecanim Bake Settings", EditorStyles.boldLabel);
|
||||
{
|
||||
EditorGUILayout.PropertyField(settings.FindProperty("mecanimEventIncludeFolderName"), new GUIContent("Include Folder Name in Event", "When enabled, Mecanim events will call methods named 'FolderNameEventName', when disabled it will call 'EventName'."));
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
EditorGUILayout.LabelField("Handles and Gizmos", EditorStyles.boldLabel);
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var scaleProperty = settings.FindProperty("handleScale");
|
||||
EditorGUILayout.PropertyField(scaleProperty, new GUIContent("Editor Bone Scale"));
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
EditorPrefs.SetFloat(SpinePreferences.SCENE_ICONS_SCALE_KEY, scaleProperty.floatValue);
|
||||
SceneView.RepaintAll();
|
||||
}
|
||||
}
|
||||
|
||||
#if SPINE_TK2D_DEFINE
|
||||
bool isTK2DDefineSet = true;
|
||||
#else
|
||||
bool isTK2DDefineSet = false;
|
||||
#endif
|
||||
bool isTK2DAllowed = SpineEditorUtilities.SpineTK2DEditorUtility.IsTK2DAllowed;
|
||||
if (SpineEditorUtilities.SpineTK2DEditorUtility.IsTK2DInstalled() || isTK2DDefineSet) {
|
||||
GUILayout.Space(20);
|
||||
EditorGUILayout.LabelField("3rd Party Settings", EditorStyles.boldLabel);
|
||||
using (new GUILayout.HorizontalScope()) {
|
||||
EditorGUILayout.PrefixLabel("Define TK2D");
|
||||
if (isTK2DAllowed && GUILayout.Button("Enable", GUILayout.Width(64)))
|
||||
SpineEditorUtilities.SpineTK2DEditorUtility.EnableTK2D();
|
||||
if (GUILayout.Button("Disable", GUILayout.Width(64)))
|
||||
SpineEditorUtilities.SpineTK2DEditorUtility.DisableTK2D();
|
||||
}
|
||||
#if !SPINE_TK2D_DEFINE
|
||||
if (!isTK2DAllowed) {
|
||||
EditorGUILayout.LabelField("To allow TK2D support, please modify line 67 in", EditorStyles.boldLabel);
|
||||
EditorGUILayout.LabelField("Spine/Editor/spine-unity/Editor/Util./BuildSettings.cs", EditorStyles.boldLabel);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
GUILayout.Space(20);
|
||||
EditorGUILayout.LabelField("Timeline Extension", EditorStyles.boldLabel);
|
||||
{
|
||||
EditorGUILayout.PropertyField(settings.FindProperty("timelineUseBlendDuration"), new GUIContent("Use Blend Duration", "When enabled, MixDuration will be synced with timeline clip transition duration 'Ease In Duration'."));
|
||||
}
|
||||
}
|
||||
EditorGUIUtility.labelWidth = prevLabelWidth;
|
||||
}
|
||||
#endif // NEW_PREFERENCES_SETTINGS_PROVIDER
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b29e98153ec2fbd44b8f7da1b41194e8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,170 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
namespace Spine.Unity.Editor {
|
||||
|
||||
using Editor = UnityEditor.Editor;
|
||||
using Icons = SpineEditorUtilities.Icons;
|
||||
|
||||
public class SpriteAtlasImportWindow : EditorWindow {
|
||||
const bool IsUtilityWindow = false;
|
||||
|
||||
[MenuItem("Window/Spine/SpriteAtlas Import", false, 5000)]
|
||||
public static void Init (MenuCommand command) {
|
||||
var window = EditorWindow.GetWindow<SpriteAtlasImportWindow>(IsUtilityWindow);
|
||||
window.minSize = new Vector2(284f, 256f);
|
||||
window.maxSize = new Vector2(500f, 256f);
|
||||
window.titleContent = new GUIContent("Spine SpriteAtlas Import", Icons.spine);
|
||||
window.Show();
|
||||
}
|
||||
|
||||
public UnityEngine.U2D.SpriteAtlas spriteAtlasAsset;
|
||||
public TextAsset skeletonDataFile;
|
||||
public SpineSpriteAtlasAsset spineSpriteAtlasAsset;
|
||||
|
||||
SerializedObject so;
|
||||
|
||||
void OnEnable () {
|
||||
if (!SpineSpriteAtlasAsset.AnySpriteAtlasNeedsRegionsLoaded())
|
||||
return;
|
||||
EditorApplication.update -= SpineSpriteAtlasAsset.UpdateWhenEditorPlayModeStarted;
|
||||
EditorApplication.update += SpineSpriteAtlasAsset.UpdateWhenEditorPlayModeStarted;
|
||||
}
|
||||
|
||||
void OnDisable () {
|
||||
EditorApplication.update -= SpineSpriteAtlasAsset.UpdateWhenEditorPlayModeStarted;
|
||||
}
|
||||
|
||||
void OnGUI () {
|
||||
so = so ?? new SerializedObject(this);
|
||||
|
||||
EditorGUIUtility.wideMode = true;
|
||||
EditorGUILayout.LabelField("Spine SpriteAtlas Import", EditorStyles.boldLabel);
|
||||
|
||||
using (new SpineInspectorUtility.BoxScope()) {
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var spriteAtlasAssetProperty = so.FindProperty("spriteAtlasAsset");
|
||||
EditorGUILayout.PropertyField(spriteAtlasAssetProperty, new GUIContent("SpriteAtlas", EditorGUIUtility.IconContent("SpriteAtlas Icon").image));
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
so.ApplyModifiedProperties();
|
||||
if (spriteAtlasAsset != null) {
|
||||
if (AssetUtility.SpriteAtlasSettingsNeedAdjustment(spriteAtlasAsset)) {
|
||||
AssetUtility.AdjustSpriteAtlasSettings(spriteAtlasAsset);
|
||||
}
|
||||
GenerateAssetsFromSpriteAtlas(spriteAtlasAsset);
|
||||
}
|
||||
}
|
||||
|
||||
var spineSpriteAtlasAssetProperty = so.FindProperty("spineSpriteAtlasAsset");
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(spineSpriteAtlasAssetProperty, new GUIContent("SpineSpriteAtlasAsset", EditorGUIUtility.IconContent("ScriptableObject Icon").image));
|
||||
if (spineSpriteAtlasAssetProperty.objectReferenceValue == null) {
|
||||
spineSpriteAtlasAssetProperty.objectReferenceValue = spineSpriteAtlasAsset = FindSpineSpriteAtlasAsset(spriteAtlasAsset);
|
||||
}
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
so.ApplyModifiedProperties();
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
|
||||
using (new EditorGUI.DisabledScope(spineSpriteAtlasAsset == null)) {
|
||||
if (SpineInspectorUtility.LargeCenteredButton(new GUIContent("Load regions by entering Play mode"))) {
|
||||
GenerateAssetsFromSpriteAtlas(spriteAtlasAsset);
|
||||
SpineSpriteAtlasAsset.UpdateByStartingEditorPlayMode();
|
||||
}
|
||||
}
|
||||
|
||||
using (new SpineInspectorUtility.BoxScope()) {
|
||||
if (spriteAtlasAsset == null) {
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Please assign SpriteAtlas file.", Icons.warning), GUILayout.Height(46));
|
||||
}
|
||||
else if (spineSpriteAtlasAsset == null || spineSpriteAtlasAsset.RegionsNeedLoading) {
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("Please hit 'Load regions ..' to load\nregion info. Play mode is started\nand stopped automatically.", Icons.warning), GUILayout.Height(54));
|
||||
}
|
||||
else {
|
||||
EditorGUILayout.LabelField(SpineInspectorUtility.TempContent("SpriteAtlas imported\nsuccessfully.", Icons.spine), GUILayout.Height(46));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool isAtlasComplete = (spineSpriteAtlasAsset != null && !spineSpriteAtlasAsset.RegionsNeedLoading);
|
||||
bool canImportSkeleton = (spriteAtlasAsset != null && skeletonDataFile != null);
|
||||
using (new SpineInspectorUtility.BoxScope()) {
|
||||
|
||||
using (new EditorGUI.DisabledScope(!isAtlasComplete)) {
|
||||
var skeletonDataAssetProperty = so.FindProperty("skeletonDataFile");
|
||||
EditorGUI.BeginChangeCheck();
|
||||
EditorGUILayout.PropertyField(skeletonDataAssetProperty, SpineInspectorUtility.TempContent("Skeleton json/skel file", Icons.spine));
|
||||
if (EditorGUI.EndChangeCheck()) {
|
||||
so.ApplyModifiedProperties();
|
||||
}
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
using (new EditorGUI.DisabledScope(!canImportSkeleton)) {
|
||||
if (SpineInspectorUtility.LargeCenteredButton(new GUIContent("Import Skeleton"))) {
|
||||
//AssetUtility.IngestSpriteAtlas(spriteAtlasAsset, null);
|
||||
string skeletonPath = AssetDatabase.GetAssetPath(skeletonDataFile);
|
||||
string[] skeletons = new string[] { skeletonPath };
|
||||
AssetUtility.ImportSpineContent(skeletons, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GenerateAssetsFromSpriteAtlas (UnityEngine.U2D.SpriteAtlas spriteAtlasAsset) {
|
||||
AssetUtility.IngestSpriteAtlas(spriteAtlasAsset, null);
|
||||
string texturePath;
|
||||
if (AssetUtility.GeneratePngFromSpriteAtlas(spriteAtlasAsset, out texturePath)) {
|
||||
Debug.Log(string.Format("Generated SpriteAtlas texture '{0}'", texturePath), spriteAtlasAsset);
|
||||
}
|
||||
}
|
||||
|
||||
SpineSpriteAtlasAsset FindSpineSpriteAtlasAsset (UnityEngine.U2D.SpriteAtlas spriteAtlasAsset) {
|
||||
string path = AssetDatabase.GetAssetPath(spriteAtlasAsset).Replace(".spriteatlas", AssetUtility.SpriteAtlasSuffix + ".asset");
|
||||
if (System.IO.File.Exists(path)) {
|
||||
return AssetDatabase.LoadAssetAtPath<SpineSpriteAtlasAsset>(path);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
SkeletonDataAsset FindSkeletonDataAsset (TextAsset skeletonDataFile) {
|
||||
string path = AssetDatabase.GetAssetPath(skeletonDataFile);
|
||||
path = path.Replace(".json", AssetUtility.SkeletonDataSuffix + ".asset");
|
||||
path = path.Replace(".skel.bytes", AssetUtility.SkeletonDataSuffix + ".asset");
|
||||
if (System.IO.File.Exists(path)) {
|
||||
return AssetDatabase.LoadAssetAtPath<SkeletonDataAsset>(path);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a5b99b091defeef439a0cb8c99fd8a51
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,6 +0,0 @@
|
||||
{
|
||||
"name": "spine-unity",
|
||||
"references": [
|
||||
"Unity.ugui"
|
||||
]
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 68765d262e2128e4ab49c983f3411946
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 29a3535756b284a428d35dcd4327185e
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
userData:
|
||||
@@ -1,245 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using Spine;
|
||||
|
||||
namespace Spine.Unity {
|
||||
/// <summary>Loads and stores a Spine atlas and list of materials.</summary>
|
||||
[CreateAssetMenu(fileName = "New Spine Atlas Asset", menuName = "Spine/Spine Atlas Asset")]
|
||||
public class SpineAtlasAsset : AtlasAssetBase {
|
||||
public TextAsset atlasFile;
|
||||
public Material[] materials;
|
||||
protected Atlas atlas;
|
||||
|
||||
public override bool IsLoaded { get { return this.atlas != null; } }
|
||||
|
||||
public override IEnumerable<Material> Materials { get { return materials; } }
|
||||
public override int MaterialCount { get { return materials == null ? 0 : materials.Length; } }
|
||||
public override Material PrimaryMaterial { get { return materials[0]; } }
|
||||
|
||||
#region Runtime Instantiation
|
||||
/// <summary>
|
||||
/// Creates a runtime AtlasAsset</summary>
|
||||
public static SpineAtlasAsset CreateRuntimeInstance (TextAsset atlasText, Material[] materials, bool initialize) {
|
||||
SpineAtlasAsset atlasAsset = ScriptableObject.CreateInstance<SpineAtlasAsset>();
|
||||
atlasAsset.Reset();
|
||||
atlasAsset.atlasFile = atlasText;
|
||||
atlasAsset.materials = materials;
|
||||
|
||||
if (initialize)
|
||||
atlasAsset.GetAtlas();
|
||||
|
||||
return atlasAsset;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. <seealso cref="Spine.Unity.SpineAtlasAsset.CreateRuntimeInstance(TextAsset, Material[], bool)"/></summary>
|
||||
public static SpineAtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Material materialPropertySource, bool initialize) {
|
||||
// Get atlas page names.
|
||||
string atlasString = atlasText.text;
|
||||
atlasString = atlasString.Replace("\r", "");
|
||||
string[] atlasLines = atlasString.Split('\n');
|
||||
var pages = new List<string>();
|
||||
for (int i = 0; i < atlasLines.Length - 1; i++) {
|
||||
if (atlasLines[i].Trim().Length == 0)
|
||||
pages.Add(atlasLines[i + 1].Trim().Replace(".png", ""));
|
||||
}
|
||||
|
||||
// Populate Materials[] by matching texture names with page names.
|
||||
var materials = new Material[pages.Count];
|
||||
for (int i = 0, n = pages.Count; i < n; i++) {
|
||||
Material mat = null;
|
||||
|
||||
// Search for a match.
|
||||
string pageName = pages[i];
|
||||
for (int j = 0, m = textures.Length; j < m; j++) {
|
||||
if (string.Equals(pageName, textures[j].name, System.StringComparison.OrdinalIgnoreCase)) {
|
||||
// Match found.
|
||||
mat = new Material(materialPropertySource);
|
||||
mat.mainTexture = textures[j];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (mat != null)
|
||||
materials[i] = mat;
|
||||
else
|
||||
throw new ArgumentException("Could not find matching atlas page in the texture array.");
|
||||
}
|
||||
|
||||
// Create AtlasAsset normally
|
||||
return CreateRuntimeInstance(atlasText, materials, initialize);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a runtime AtlasAsset. Only providing the textures is slower because it has to search for atlas page matches. <seealso cref="Spine.Unity.AtlasAssetBase.CreateRuntimeInstance(TextAsset, Material[], bool)"/></summary>
|
||||
public static SpineAtlasAsset CreateRuntimeInstance (TextAsset atlasText, Texture2D[] textures, Shader shader, bool initialize) {
|
||||
if (shader == null)
|
||||
shader = Shader.Find("Spine/Skeleton");
|
||||
|
||||
Material materialProperySource = new Material(shader);
|
||||
var oa = CreateRuntimeInstance(atlasText, textures, materialProperySource, initialize);
|
||||
|
||||
return oa;
|
||||
}
|
||||
#endregion
|
||||
|
||||
void Reset () {
|
||||
Clear();
|
||||
}
|
||||
|
||||
public override void Clear () {
|
||||
atlas = null;
|
||||
}
|
||||
|
||||
/// <returns>The atlas or null if it could not be loaded.</returns>
|
||||
public override Atlas GetAtlas () {
|
||||
if (atlasFile == null) {
|
||||
Debug.LogError("Atlas file not set for atlas asset: " + name, this);
|
||||
Clear();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (materials == null || materials.Length == 0) {
|
||||
Debug.LogError("Materials not set for atlas asset: " + name, this);
|
||||
Clear();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (atlas != null) return atlas;
|
||||
|
||||
try {
|
||||
atlas = new Atlas(new StringReader(atlasFile.text), "", new MaterialsTextureLoader(this));
|
||||
atlas.FlipV();
|
||||
return atlas;
|
||||
} catch (Exception ex) {
|
||||
Debug.LogError("Error reading atlas file for atlas asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace, this);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Mesh GenerateMesh (string name, Mesh mesh, out Material material, float scale = 0.01f) {
|
||||
AtlasRegion region = atlas.FindRegion(name);
|
||||
material = null;
|
||||
if (region != null) {
|
||||
if (mesh == null) {
|
||||
mesh = new Mesh();
|
||||
mesh.name = name;
|
||||
}
|
||||
|
||||
Vector3[] verts = new Vector3[4];
|
||||
Vector2[] uvs = new Vector2[4];
|
||||
Color[] colors = { Color.white, Color.white, Color.white, Color.white };
|
||||
int[] triangles = { 0, 1, 2, 2, 3, 0 };
|
||||
|
||||
float left, right, top, bottom;
|
||||
left = region.width / -2f;
|
||||
right = left * -1f;
|
||||
top = region.height / 2f;
|
||||
bottom = top * -1;
|
||||
|
||||
verts[0] = new Vector3(left, bottom, 0) * scale;
|
||||
verts[1] = new Vector3(left, top, 0) * scale;
|
||||
verts[2] = new Vector3(right, top, 0) * scale;
|
||||
verts[3] = new Vector3(right, bottom, 0) * scale;
|
||||
float u, v, u2, v2;
|
||||
u = region.u;
|
||||
v = region.v;
|
||||
u2 = region.u2;
|
||||
v2 = region.v2;
|
||||
|
||||
if (!region.rotate) {
|
||||
uvs[0] = new Vector2(u, v2);
|
||||
uvs[1] = new Vector2(u, v);
|
||||
uvs[2] = new Vector2(u2, v);
|
||||
uvs[3] = new Vector2(u2, v2);
|
||||
} else {
|
||||
uvs[0] = new Vector2(u2, v2);
|
||||
uvs[1] = new Vector2(u, v2);
|
||||
uvs[2] = new Vector2(u, v);
|
||||
uvs[3] = new Vector2(u2, v);
|
||||
}
|
||||
|
||||
mesh.triangles = new int[0];
|
||||
mesh.vertices = verts;
|
||||
mesh.uv = uvs;
|
||||
mesh.colors = colors;
|
||||
mesh.triangles = triangles;
|
||||
mesh.RecalculateNormals();
|
||||
mesh.RecalculateBounds();
|
||||
|
||||
material = (Material)region.page.rendererObject;
|
||||
} else {
|
||||
mesh = null;
|
||||
}
|
||||
|
||||
return mesh;
|
||||
}
|
||||
}
|
||||
|
||||
public class MaterialsTextureLoader : TextureLoader {
|
||||
SpineAtlasAsset atlasAsset;
|
||||
|
||||
public MaterialsTextureLoader (SpineAtlasAsset atlasAsset) {
|
||||
this.atlasAsset = atlasAsset;
|
||||
}
|
||||
|
||||
public void Load (AtlasPage page, string path) {
|
||||
String name = Path.GetFileNameWithoutExtension(path);
|
||||
Material material = null;
|
||||
foreach (Material other in atlasAsset.materials) {
|
||||
if (other.mainTexture == null) {
|
||||
Debug.LogError("Material is missing texture: " + other.name, other);
|
||||
return;
|
||||
}
|
||||
if (other.mainTexture.name == name) {
|
||||
material = other;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (material == null) {
|
||||
Debug.LogError("Material with texture name \"" + name + "\" not found for atlas asset: " + atlasAsset.name, atlasAsset);
|
||||
return;
|
||||
}
|
||||
page.rendererObject = material;
|
||||
|
||||
// Very old atlas files expected the texture's actual size to be used at runtime.
|
||||
if (page.width == 0 || page.height == 0) {
|
||||
page.width = material.mainTexture.width;
|
||||
page.height = material.mainTexture.height;
|
||||
}
|
||||
}
|
||||
|
||||
public void Unload (object texture) { }
|
||||
}
|
||||
}
|
||||
@@ -1,10 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a6b194f808b1af6499c93410e504af42
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {fileID: 2800000, guid: 3fc714a0dc1cf6b4b959e073fff2844e, type: 3}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,397 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#if UNITY_2018_2_OR_NEWER
|
||||
#define EXPOSES_SPRITE_ATLAS_UTILITIES
|
||||
#endif
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using UnityEngine;
|
||||
using Spine;
|
||||
using UnityEngine.U2D;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using System.Reflection;
|
||||
#endif
|
||||
|
||||
namespace Spine.Unity {
|
||||
/// <summary>Loads and stores a Spine atlas and list of materials.</summary>
|
||||
[CreateAssetMenu(fileName = "New Spine SpriteAtlas Asset", menuName = "Spine/Spine SpriteAtlas Asset")]
|
||||
public class SpineSpriteAtlasAsset : AtlasAssetBase {
|
||||
public SpriteAtlas spriteAtlasFile;
|
||||
public Material[] materials;
|
||||
protected Atlas atlas;
|
||||
public bool updateRegionsInPlayMode;
|
||||
|
||||
[System.Serializable]
|
||||
protected class SavedRegionInfo {
|
||||
public float x, y, width, height;
|
||||
public SpritePackingRotation packingRotation;
|
||||
}
|
||||
[SerializeField] protected SavedRegionInfo[] savedRegions;
|
||||
|
||||
public override bool IsLoaded { get { return this.atlas != null; } }
|
||||
|
||||
public override IEnumerable<Material> Materials { get { return materials; } }
|
||||
public override int MaterialCount { get { return materials == null ? 0 : materials.Length; } }
|
||||
public override Material PrimaryMaterial { get { return materials[0]; } }
|
||||
|
||||
#if UNITY_EDITOR
|
||||
static MethodInfo GetPackedSpritesMethod, GetPreviewTexturesMethod;
|
||||
#if !EXPOSES_SPRITE_ATLAS_UTILITIES
|
||||
static MethodInfo PackAtlasesMethod;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#region Runtime Instantiation
|
||||
/// <summary>
|
||||
/// Creates a runtime AtlasAsset</summary>
|
||||
public static SpineSpriteAtlasAsset CreateRuntimeInstance (SpriteAtlas spriteAtlasFile, Material[] materials, bool initialize) {
|
||||
SpineSpriteAtlasAsset atlasAsset = ScriptableObject.CreateInstance<SpineSpriteAtlasAsset>();
|
||||
atlasAsset.Reset();
|
||||
atlasAsset.spriteAtlasFile = spriteAtlasFile;
|
||||
atlasAsset.materials = materials;
|
||||
|
||||
if (initialize)
|
||||
atlasAsset.GetAtlas();
|
||||
|
||||
return atlasAsset;
|
||||
}
|
||||
#endregion
|
||||
|
||||
void Reset () {
|
||||
Clear();
|
||||
}
|
||||
|
||||
public override void Clear () {
|
||||
atlas = null;
|
||||
}
|
||||
|
||||
/// <returns>The atlas or null if it could not be loaded.</returns>
|
||||
public override Atlas GetAtlas () {
|
||||
if (spriteAtlasFile == null) {
|
||||
Debug.LogError("SpriteAtlas file not set for SpineSpriteAtlasAsset: " + name, this);
|
||||
Clear();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (materials == null || materials.Length == 0) {
|
||||
Debug.LogError("Materials not set for SpineSpriteAtlasAsset: " + name, this);
|
||||
Clear();
|
||||
return null;
|
||||
}
|
||||
|
||||
if (atlas != null) return atlas;
|
||||
|
||||
try {
|
||||
atlas = LoadAtlas(spriteAtlasFile);
|
||||
return atlas;
|
||||
} catch (Exception ex) {
|
||||
Debug.LogError("Error analyzing SpriteAtlas for SpineSpriteAtlasAsset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace, this);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
protected void AssignRegionsFromSavedRegions (Sprite[] sprites, Atlas usedAtlas) {
|
||||
|
||||
if (savedRegions == null || savedRegions.Length != sprites.Length)
|
||||
return;
|
||||
|
||||
int i = 0;
|
||||
foreach (var region in usedAtlas) {
|
||||
var savedRegion = savedRegions[i];
|
||||
var page = region.page;
|
||||
|
||||
region.degrees = savedRegion.packingRotation == SpritePackingRotation.None ? 0 : 90;
|
||||
region.rotate = region.degrees != 0;
|
||||
|
||||
float x = savedRegion.x;
|
||||
float y = savedRegion.y;
|
||||
float width = savedRegion.width;
|
||||
float height = savedRegion.height;
|
||||
|
||||
region.u = x / (float)page.width;
|
||||
region.v = y / (float)page.height;
|
||||
if (region.rotate) {
|
||||
region.u2 = (x + height) / (float)page.width;
|
||||
region.v2 = (y + width) / (float)page.height;
|
||||
}
|
||||
else {
|
||||
region.u2 = (x + width) / (float)page.width;
|
||||
region.v2 = (y + height) / (float)page.height;
|
||||
}
|
||||
region.x = (int)x;
|
||||
region.y = (int)y;
|
||||
region.width = Math.Abs((int)width);
|
||||
region.height = Math.Abs((int)height);
|
||||
|
||||
// flip upside down
|
||||
var temp = region.v;
|
||||
region.v = region.v2;
|
||||
region.v2 = temp;
|
||||
|
||||
region.originalWidth = (int)width;
|
||||
region.originalHeight = (int)height;
|
||||
|
||||
// note: currently sprite pivot offsets are ignored.
|
||||
// var sprite = sprites[i];
|
||||
region.offsetX = 0;//sprite.pivot.x;
|
||||
region.offsetY = 0;//sprite.pivot.y;
|
||||
|
||||
++i;
|
||||
}
|
||||
}
|
||||
|
||||
private Atlas LoadAtlas (UnityEngine.U2D.SpriteAtlas spriteAtlas) {
|
||||
|
||||
List<AtlasPage> pages = new List<AtlasPage>();
|
||||
List<AtlasRegion> regions = new List<AtlasRegion>();
|
||||
|
||||
Sprite[] sprites = new UnityEngine.Sprite[spriteAtlas.spriteCount];
|
||||
spriteAtlas.GetSprites(sprites);
|
||||
if (sprites.Length == 0)
|
||||
return new Atlas(pages, regions);
|
||||
|
||||
Texture2D texture = null;
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
texture = AccessPackedTextureEditor(spriteAtlas);
|
||||
else
|
||||
#endif
|
||||
texture = AccessPackedTexture(sprites);
|
||||
|
||||
Material material = materials[0];
|
||||
#if !UNITY_EDITOR
|
||||
material.mainTexture = texture;
|
||||
#endif
|
||||
|
||||
Spine.AtlasPage page = new AtlasPage();
|
||||
page.name = spriteAtlas.name;
|
||||
page.width = texture.width;
|
||||
page.height = texture.height;
|
||||
page.format = Spine.Format.RGBA8888;
|
||||
|
||||
page.minFilter = TextureFilter.Linear;
|
||||
page.magFilter = TextureFilter.Linear;
|
||||
page.uWrap = TextureWrap.ClampToEdge;
|
||||
page.vWrap = TextureWrap.ClampToEdge;
|
||||
page.rendererObject = material;
|
||||
pages.Add(page);
|
||||
|
||||
sprites = AccessPackedSprites(spriteAtlas);
|
||||
|
||||
int i = 0;
|
||||
for ( ; i < sprites.Length; ++i) {
|
||||
var sprite = sprites[i];
|
||||
AtlasRegion region = new AtlasRegion();
|
||||
region.name = sprite.name.Replace("(Clone)", "");
|
||||
region.page = page;
|
||||
region.degrees = sprite.packingRotation == SpritePackingRotation.None ? 0 : 90;
|
||||
region.rotate = region.degrees != 0;
|
||||
|
||||
region.u2 = 1;
|
||||
region.v2 = 1;
|
||||
region.width = page.width;
|
||||
region.height = page.height;
|
||||
region.originalWidth = page.width;
|
||||
region.originalHeight = page.height;
|
||||
|
||||
region.index = i;
|
||||
regions.Add(region);
|
||||
}
|
||||
|
||||
var atlas = new Atlas(pages, regions);
|
||||
AssignRegionsFromSavedRegions(sprites, atlas);
|
||||
|
||||
return atlas;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public static void UpdateByStartingEditorPlayMode () {
|
||||
EditorApplication.isPlaying = true;
|
||||
}
|
||||
|
||||
public static bool AnySpriteAtlasNeedsRegionsLoaded () {
|
||||
string[] guids = UnityEditor.AssetDatabase.FindAssets("t:SpineSpriteAtlasAsset");
|
||||
foreach (var guid in guids) {
|
||||
string path = UnityEditor.AssetDatabase.GUIDToAssetPath(guid);
|
||||
if (!string.IsNullOrEmpty(path)) {
|
||||
var atlasAsset = UnityEditor.AssetDatabase.LoadAssetAtPath<SpineSpriteAtlasAsset>(path);
|
||||
if (atlasAsset) {
|
||||
if (atlasAsset.RegionsNeedLoading)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void UpdateWhenEditorPlayModeStarted () {
|
||||
if (!EditorApplication.isPlaying)
|
||||
return;
|
||||
|
||||
EditorApplication.update -= UpdateWhenEditorPlayModeStarted;
|
||||
string[] guids = UnityEditor.AssetDatabase.FindAssets("t:SpineSpriteAtlasAsset");
|
||||
if (guids.Length == 0)
|
||||
return;
|
||||
|
||||
Debug.Log("Updating SpineSpriteAtlasAssets");
|
||||
foreach (var guid in guids) {
|
||||
string path = UnityEditor.AssetDatabase.GUIDToAssetPath(guid);
|
||||
if (!string.IsNullOrEmpty(path)) {
|
||||
var atlasAsset = UnityEditor.AssetDatabase.LoadAssetAtPath<SpineSpriteAtlasAsset>(path);
|
||||
if (atlasAsset) {
|
||||
atlasAsset.atlas = atlasAsset.LoadAtlas(atlasAsset.spriteAtlasFile);
|
||||
atlasAsset.LoadRegionsInEditorPlayMode();
|
||||
Debug.Log(string.Format("Updated regions of '{0}'", atlasAsset.name), atlasAsset);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
EditorApplication.isPlaying = false;
|
||||
}
|
||||
|
||||
public bool RegionsNeedLoading {
|
||||
get { return savedRegions == null || savedRegions.Length == 0 || updateRegionsInPlayMode; }
|
||||
}
|
||||
|
||||
public void LoadRegionsInEditorPlayMode () {
|
||||
|
||||
Sprite[] sprites = null;
|
||||
System.Type T = Type.GetType("UnityEditor.U2D.SpriteAtlasExtensions,UnityEditor");
|
||||
var method = T.GetMethod("GetPackedSprites", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
if (method != null) {
|
||||
object retval = method.Invoke(null, new object[] { spriteAtlasFile });
|
||||
var spritesArray = retval as Sprite[];
|
||||
if (spritesArray != null && spritesArray.Length > 0) {
|
||||
sprites = spritesArray;
|
||||
}
|
||||
}
|
||||
if (sprites == null) {
|
||||
sprites = new UnityEngine.Sprite[spriteAtlasFile.spriteCount];
|
||||
spriteAtlasFile.GetSprites(sprites);
|
||||
}
|
||||
if (sprites.Length == 0) {
|
||||
Debug.LogWarning(string.Format("SpriteAtlas '{0}' contains no sprites. Please make sure all assigned images are set to import type 'Sprite'.", spriteAtlasFile.name), spriteAtlasFile);
|
||||
return;
|
||||
}
|
||||
else if (sprites[0].packingMode == SpritePackingMode.Tight) {
|
||||
Debug.LogError(string.Format("SpriteAtlas '{0}': Tight packing is not supported. Please disable 'Tight Packing' in the SpriteAtlas Inspector.", spriteAtlasFile.name), spriteAtlasFile);
|
||||
return;
|
||||
}
|
||||
|
||||
if (savedRegions == null || savedRegions.Length != sprites.Length)
|
||||
savedRegions = new SavedRegionInfo[sprites.Length];
|
||||
|
||||
int i = 0;
|
||||
foreach (var region in atlas) {
|
||||
var sprite = sprites[i];
|
||||
var rect = sprite.textureRect;
|
||||
float x = rect.min.x;
|
||||
float y = rect.min.y;
|
||||
float width = rect.width;
|
||||
float height = rect.height;
|
||||
|
||||
var savedRegion = new SavedRegionInfo();
|
||||
savedRegion.x = x;
|
||||
savedRegion.y = y;
|
||||
savedRegion.width = width;
|
||||
savedRegion.height = height;
|
||||
savedRegion.packingRotation = sprite.packingRotation;
|
||||
savedRegions[i] = savedRegion;
|
||||
|
||||
++i;
|
||||
}
|
||||
updateRegionsInPlayMode = false;
|
||||
AssignRegionsFromSavedRegions(sprites, atlas);
|
||||
EditorUtility.SetDirty(this);
|
||||
AssetDatabase.SaveAssets();
|
||||
}
|
||||
|
||||
public static Texture2D AccessPackedTextureEditor (SpriteAtlas spriteAtlas) {
|
||||
#if EXPOSES_SPRITE_ATLAS_UTILITIES
|
||||
UnityEditor.U2D.SpriteAtlasUtility.PackAtlases(new SpriteAtlas[] { spriteAtlas }, EditorUserBuildSettings.activeBuildTarget);
|
||||
#else
|
||||
/*if (PackAtlasesMethod == null) {
|
||||
System.Type T = Type.GetType("UnityEditor.U2D.SpriteAtlasUtility,UnityEditor");
|
||||
PackAtlasesMethod = T.GetMethod("PackAtlases", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
}
|
||||
if (PackAtlasesMethod != null) {
|
||||
PackAtlasesMethod.Invoke(null, new object[] { new SpriteAtlas[] { spriteAtlas }, EditorUserBuildSettings.activeBuildTarget });
|
||||
}*/
|
||||
#endif
|
||||
if (GetPreviewTexturesMethod == null) {
|
||||
System.Type T = Type.GetType("UnityEditor.U2D.SpriteAtlasExtensions,UnityEditor");
|
||||
GetPreviewTexturesMethod = T.GetMethod("GetPreviewTextures", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
}
|
||||
if (GetPreviewTexturesMethod != null) {
|
||||
object retval = GetPreviewTexturesMethod.Invoke(null, new object[] { spriteAtlas });
|
||||
var textures = retval as Texture2D[];
|
||||
if (textures.Length > 0)
|
||||
return textures[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
#endif
|
||||
public static Texture2D AccessPackedTexture (Sprite[] sprites) {
|
||||
return sprites[0].texture;
|
||||
}
|
||||
|
||||
|
||||
public static Sprite[] AccessPackedSprites (UnityEngine.U2D.SpriteAtlas spriteAtlas) {
|
||||
Sprite[] sprites = null;
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying) {
|
||||
|
||||
if (GetPackedSpritesMethod == null) {
|
||||
System.Type T = Type.GetType("UnityEditor.U2D.SpriteAtlasExtensions,UnityEditor");
|
||||
GetPackedSpritesMethod = T.GetMethod("GetPackedSprites", BindingFlags.NonPublic | BindingFlags.Static);
|
||||
}
|
||||
if (GetPackedSpritesMethod != null) {
|
||||
object retval = GetPackedSpritesMethod.Invoke(null, new object[] { spriteAtlas });
|
||||
var spritesArray = retval as Sprite[];
|
||||
if (spritesArray != null && spritesArray.Length > 0) {
|
||||
sprites = spritesArray;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (sprites == null) {
|
||||
sprites = new UnityEngine.Sprite[spriteAtlas.spriteCount];
|
||||
spriteAtlas.GetSprites(sprites);
|
||||
if (sprites.Length == 0)
|
||||
return null;
|
||||
}
|
||||
return sprites;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ce59897dd7e6cbc4690a05ebaf975dff
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,84 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
// Not for optimization. Do not disable.
|
||||
#define SPINE_TRIANGLECHECK // Avoid calling SetTriangles at the cost of checking for mesh differences (vertex counts, memberwise attachment list compare) every frame.
|
||||
//#define SPINE_DEBUG
|
||||
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Spine.Unity {
|
||||
public static class SpineMesh {
|
||||
internal const HideFlags MeshHideflags = HideFlags.DontSaveInBuild | HideFlags.DontSaveInEditor;
|
||||
|
||||
/// <summary>Factory method for creating a new mesh for use in Spine components. This can be called in field initializers.</summary>
|
||||
public static Mesh NewSkeletonMesh () {
|
||||
var m = new Mesh();
|
||||
m.MarkDynamic();
|
||||
m.name = "Skeleton Mesh";
|
||||
m.hideFlags = SpineMesh.MeshHideflags;
|
||||
return m;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Instructions for how to generate a mesh or submesh: "Render this skeleton's slots: start slot, up to but not including endSlot, using this material."</summary>
|
||||
public struct SubmeshInstruction {
|
||||
public Skeleton skeleton;
|
||||
public int startSlot;
|
||||
public int endSlot;
|
||||
public Material material;
|
||||
|
||||
public bool forceSeparate;
|
||||
public int preActiveClippingSlotSource;
|
||||
|
||||
#if SPINE_TRIANGLECHECK
|
||||
// Cached values because they are determined in the process of generating instructions,
|
||||
// but could otherwise be pulled from accessing attachments, checking materials and counting tris and verts.
|
||||
public int rawTriangleCount;
|
||||
public int rawVertexCount;
|
||||
public int rawFirstVertexIndex;
|
||||
public bool hasClipping;
|
||||
#endif
|
||||
|
||||
/// <summary>The number of slots in this SubmeshInstruction's range. Not necessarily the number of attachments.</summary>
|
||||
public int SlotCount { get { return endSlot - startSlot; } }
|
||||
|
||||
public override string ToString () {
|
||||
return
|
||||
string.Format("[SubmeshInstruction: slots {0} to {1}. (Material){2}. preActiveClippingSlotSource:{3}]",
|
||||
startSlot,
|
||||
endSlot - 1,
|
||||
material == null ? "<none>" : material.name,
|
||||
preActiveClippingSlotSource
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f834c8746034db645a52a9506ff1de89
|
||||
timeCreated: 1455416715
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,156 +0,0 @@
|
||||
/******************************************************************************
|
||||
* Spine Runtimes License Agreement
|
||||
* Last updated January 1, 2020. Replaces all prior versions.
|
||||
*
|
||||
* Copyright (c) 2013-2020, Esoteric Software LLC
|
||||
*
|
||||
* Integration of the Spine Runtimes into software or otherwise creating
|
||||
* derivative works of the Spine Runtimes is permitted under the terms and
|
||||
* conditions of Section 2 of the Spine Editor License Agreement:
|
||||
* http://esotericsoftware.com/spine-editor-license
|
||||
*
|
||||
* Otherwise, it is permitted to integrate the Spine Runtimes into software
|
||||
* or otherwise create derivative works of the Spine Runtimes (collectively,
|
||||
* "Products"), provided that each user of the Products must obtain their own
|
||||
* Spine Editor license and redistribution of the Products in any form must
|
||||
* include this license and copyright notice.
|
||||
*
|
||||
* THE SPINE RUNTIMES ARE PROVIDED BY ESOTERIC SOFTWARE LLC "AS IS" AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL ESOTERIC SOFTWARE LLC BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES,
|
||||
* BUSINESS INTERRUPTION, OR LOSS OF USE, DATA, OR PROFITS) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
||||
* THE SPINE RUNTIMES, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*****************************************************************************/
|
||||
|
||||
#if SPINE_TK2D
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using Spine;
|
||||
|
||||
// MITCH: handle TPackerCW flip mode (probably not swap uv horizontaly)
|
||||
namespace Spine.Unity.TK2D {
|
||||
public class SpriteCollectionAttachmentLoader : AttachmentLoader {
|
||||
private tk2dSpriteCollectionData sprites;
|
||||
private float u, v, u2, v2;
|
||||
private bool regionRotated;
|
||||
private float regionOriginalWidth, regionOriginalHeight;
|
||||
private float regionWidth, regionHeight;
|
||||
private float regionOffsetX, regionOffsetY;
|
||||
private Material material;
|
||||
|
||||
public SpriteCollectionAttachmentLoader (tk2dSpriteCollectionData sprites) {
|
||||
if (sprites == null)
|
||||
throw new ArgumentNullException("sprites cannot be null.");
|
||||
this.sprites = sprites;
|
||||
}
|
||||
|
||||
private void ProcessSpriteDefinition (String name) {
|
||||
// Strip folder names.
|
||||
int index = name.LastIndexOfAny(new char[] {'/', '\\'});
|
||||
if (index != -1)
|
||||
name = name.Substring(index + 1);
|
||||
|
||||
tk2dSpriteDefinition def = sprites.inst.GetSpriteDefinition(name);
|
||||
|
||||
if (def == null) {
|
||||
Debug.Log("Sprite not found in atlas: " + name, sprites);
|
||||
throw new Exception("Sprite not found in atlas: " + name);
|
||||
}
|
||||
if (def.complexGeometry)
|
||||
throw new NotImplementedException("Complex geometry is not supported: " + name);
|
||||
if (def.flipped == tk2dSpriteDefinition.FlipMode.TPackerCW)
|
||||
throw new NotImplementedException("Only 2D Toolkit atlases are supported: " + name);
|
||||
|
||||
Vector2 minTexCoords = Vector2.one, maxTexCoords = Vector2.zero;
|
||||
for (int i = 0; i < def.uvs.Length; ++i) {
|
||||
Vector2 uv = def.uvs[i];
|
||||
minTexCoords = Vector2.Min(minTexCoords, uv);
|
||||
maxTexCoords = Vector2.Max(maxTexCoords, uv);
|
||||
}
|
||||
regionRotated = def.flipped == tk2dSpriteDefinition.FlipMode.Tk2d;
|
||||
if (regionRotated) {
|
||||
float temp = minTexCoords.x;
|
||||
minTexCoords.x = maxTexCoords.x;
|
||||
maxTexCoords.x = temp;
|
||||
}
|
||||
u = minTexCoords.x;
|
||||
v = maxTexCoords.y;
|
||||
u2 = maxTexCoords.x;
|
||||
v2 = minTexCoords.y;
|
||||
|
||||
regionOriginalWidth = (int)(def.untrimmedBoundsData[1].x / def.texelSize.x);
|
||||
regionOriginalHeight = (int)(def.untrimmedBoundsData[1].y / def.texelSize.y);
|
||||
|
||||
regionWidth = (int)(def.boundsData[1].x / def.texelSize.x);
|
||||
regionHeight = (int)(def.boundsData[1].y / def.texelSize.y);
|
||||
|
||||
float x0 = def.untrimmedBoundsData[0].x - def.untrimmedBoundsData[1].x / 2;
|
||||
float x1 = def.boundsData[0].x - def.boundsData[1].x / 2;
|
||||
regionOffsetX = (int)((x1 - x0) / def.texelSize.x);
|
||||
|
||||
float y0 = def.untrimmedBoundsData[0].y - def.untrimmedBoundsData[1].y / 2;
|
||||
float y1 = def.boundsData[0].y - def.boundsData[1].y / 2;
|
||||
regionOffsetY = (int)((y1 - y0) / def.texelSize.y);
|
||||
|
||||
material = def.materialInst;
|
||||
}
|
||||
|
||||
public RegionAttachment NewRegionAttachment (Skin skin, String name, String path) {
|
||||
ProcessSpriteDefinition(path);
|
||||
|
||||
RegionAttachment region = new RegionAttachment(name);
|
||||
region.Path = path;
|
||||
region.RendererObject = material;
|
||||
region.SetUVs(u, v, u2, v2, regionRotated);
|
||||
region.RegionOriginalWidth = regionOriginalWidth;
|
||||
region.RegionOriginalHeight = regionOriginalHeight;
|
||||
region.RegionWidth = regionWidth;
|
||||
region.RegionHeight = regionHeight;
|
||||
region.RegionOffsetX = regionOffsetX;
|
||||
region.RegionOffsetY = regionOffsetY;
|
||||
return region;
|
||||
}
|
||||
|
||||
public MeshAttachment NewMeshAttachment (Skin skin, String name, String path) {
|
||||
ProcessSpriteDefinition(path);
|
||||
|
||||
MeshAttachment mesh = new MeshAttachment(name);
|
||||
mesh.Path = path;
|
||||
mesh.RendererObject = material;
|
||||
mesh.RegionU = u;
|
||||
mesh.RegionV = v;
|
||||
mesh.RegionU2 = u2;
|
||||
mesh.RegionV2 = v2;
|
||||
mesh.RegionRotate = regionRotated;
|
||||
mesh.RegionOriginalWidth = regionOriginalWidth;
|
||||
mesh.RegionOriginalHeight = regionOriginalHeight;
|
||||
mesh.RegionWidth = regionWidth;
|
||||
mesh.RegionHeight = regionHeight;
|
||||
mesh.RegionOffsetX = regionOffsetX;
|
||||
mesh.RegionOffsetY = regionOffsetY;
|
||||
return mesh;
|
||||
}
|
||||
|
||||
public BoundingBoxAttachment NewBoundingBoxAttachment (Skin skin, String name) {
|
||||
return new BoundingBoxAttachment(name);
|
||||
}
|
||||
|
||||
public PathAttachment NewPathAttachment (Skin skin, string name) {
|
||||
return new PathAttachment(name);
|
||||
}
|
||||
|
||||
public PointAttachment NewPointAttachment (Skin skin, string name) {
|
||||
return new PointAttachment(name);
|
||||
}
|
||||
|
||||
public ClippingAttachment NewClippingAttachment (Skin skin, string name) {
|
||||
return new ClippingAttachment(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,8 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 03238e4a73953c045a6cb289162532f3
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
@@ -1,128 +0,0 @@
|
||||
// Spine/Skeleton PMA Multiply
|
||||
// - single color multiply tint
|
||||
// - unlit
|
||||
// - Premultiplied alpha Multiply blending
|
||||
// - No depth, no backface culling, no fog.
|
||||
// - ShadowCaster pass
|
||||
|
||||
Shader "Spine/Blend Modes/Skeleton PMA Multiply" {
|
||||
Properties {
|
||||
_Color ("Tint Color", Color) = (1,1,1,1)
|
||||
[NoScaleOffset] _MainTex ("MainTex", 2D) = "black" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
LOD 100
|
||||
|
||||
Fog { Mode Off }
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend DstColor OneMinusSrcAlpha
|
||||
Lighting Off
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
Pass {
|
||||
Name "Normal"
|
||||
|
||||
CGPROGRAM
|
||||
#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
uniform sampler2D _MainTex;
|
||||
uniform float4 _Color;
|
||||
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
o.vertexColor = v.vertexColor * float4(_Color.rgb * _Color.a, _Color.a); // Combine a PMA version of _Color with vertexColor.
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag (VertexOutput i) : SV_Target {
|
||||
float4 texColor = tex2D(_MainTex, i.uv);
|
||||
|
||||
#if defined(_STRAIGHT_ALPHA_INPUT)
|
||||
texColor.rgb *= texColor.a;
|
||||
#endif
|
||||
|
||||
return (texColor * i.vertexColor);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass {
|
||||
Name "Caster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
Offset 1, 1
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
struct v2f {
|
||||
V2F_SHADOW_CASTER;
|
||||
float4 uvAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
uniform float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata_base v, float4 vertexColor : COLOR) {
|
||||
v2f o;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
o.uvAndAlpha.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.uvAndAlpha.z = 0;
|
||||
o.uvAndAlpha.a = vertexColor.a;
|
||||
return o;
|
||||
}
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
uniform fixed _Cutoff;
|
||||
|
||||
float4 frag (v2f i) : SV_Target {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy);
|
||||
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8bdcdc7ee298e594a9c20c61d25c33b6
|
||||
timeCreated: 1496446742
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,128 +0,0 @@
|
||||
// Spine/Skeleton PMA Screen
|
||||
// - single color multiply tint
|
||||
// - unlit
|
||||
// - Premultiplied alpha Multiply blending
|
||||
// - No depth, no backface culling, no fog.
|
||||
// - ShadowCaster pass
|
||||
|
||||
Shader "Spine/Blend Modes/Skeleton PMA Screen" {
|
||||
Properties {
|
||||
_Color ("Tint Color", Color) = (1,1,1,1)
|
||||
[NoScaleOffset] _MainTex ("MainTex", 2D) = "black" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
LOD 100
|
||||
|
||||
Fog { Mode Off }
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcColor
|
||||
Lighting Off
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
Pass {
|
||||
Name "Normal"
|
||||
|
||||
CGPROGRAM
|
||||
#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
uniform sampler2D _MainTex;
|
||||
uniform float4 _Color;
|
||||
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
o.vertexColor = v.vertexColor * float4(_Color.rgb * _Color.a, _Color.a); // Combine a PMA version of _Color with vertexColor.
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag (VertexOutput i) : SV_Target {
|
||||
float4 texColor = tex2D(_MainTex, i.uv);
|
||||
|
||||
#if defined(_STRAIGHT_ALPHA_INPUT)
|
||||
texColor.rgb *= texColor.a;
|
||||
#endif
|
||||
|
||||
return (texColor * i.vertexColor);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass {
|
||||
Name "Caster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
Offset 1, 1
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
struct v2f {
|
||||
V2F_SHADOW_CASTER;
|
||||
float4 uvAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
uniform float4 _MainTex_ST;
|
||||
|
||||
v2f vert (appdata_base v, float4 vertexColor : COLOR) {
|
||||
v2f o;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
o.uvAndAlpha.xy = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.uvAndAlpha.z = 0;
|
||||
o.uvAndAlpha.a = vertexColor.a;
|
||||
return o;
|
||||
}
|
||||
|
||||
uniform sampler2D _MainTex;
|
||||
uniform fixed _Cutoff;
|
||||
|
||||
float4 frag (v2f i) : SV_Target {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy);
|
||||
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4e8caa36c07aacf4ab270da00784e4d9
|
||||
timeCreated: 1496448787
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,27 +0,0 @@
|
||||
#ifndef SKELETON_TINT_COMMON_INCLUDED
|
||||
#define SKELETON_TINT_COMMON_INCLUDED
|
||||
|
||||
float4 fragTintedColor(float4 texColor, float3 darkTintColor, float4 lightTintColorPMA, float lightColorAlpha, float darkColorAlpha) {
|
||||
|
||||
float a = texColor.a * lightTintColorPMA.a;
|
||||
|
||||
#if !defined(_STRAIGHT_ALPHA_INPUT)
|
||||
float3 texDarkColor = (texColor.a - texColor.rgb);
|
||||
#else
|
||||
float3 texDarkColor = (1 - texColor.rgb);
|
||||
#endif
|
||||
float3 darkColor = texDarkColor * darkTintColor.rgb * lightColorAlpha;
|
||||
float3 lightColor = texColor.rgb * lightTintColorPMA.rgb;
|
||||
|
||||
float4 fragColor = float4(darkColor + lightColor, a);
|
||||
#if defined(_STRAIGHT_ALPHA_INPUT)
|
||||
fragColor.rgb *= texColor.a;
|
||||
#endif
|
||||
|
||||
#if defined(_DARK_COLOR_ALPHA_ADDITIVE)
|
||||
fragColor.a = a * (1 - darkColorAlpha);
|
||||
#endif
|
||||
return fragColor;
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: cc9439c8e75fb7e4c82ad725b649b047
|
||||
ShaderImporter:
|
||||
externalObjects: {}
|
||||
defaultTextures: []
|
||||
nonModifiableTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,46 +0,0 @@
|
||||
// Outline shader variant of "Spine/Blend Modes/Skeleton PMA Screen"
|
||||
|
||||
Shader "Spine/Outline/Blend Modes/Skeleton PMA Screen" {
|
||||
Properties {
|
||||
_Color ("Tint Color", Color) = (1,1,1,1)
|
||||
[NoScaleOffset] _MainTex ("MainTex", 2D) = "black" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
LOD 100
|
||||
|
||||
Fog { Mode Off }
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcColor
|
||||
Lighting Off
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
UsePass "Spine/Outline/Skeleton/OUTLINE"
|
||||
|
||||
UsePass "Spine/Blend Modes/Skeleton PMA Screen/NORMAL"
|
||||
|
||||
UsePass "Spine/Blend Modes/Skeleton PMA Screen/CASTER"
|
||||
}
|
||||
FallBack "Spine/Blend Modes/Skeleton PMA Screen"
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e61a8d94e453ff641a7e39c4b11cac95
|
||||
timeCreated: 1573829476
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,75 +0,0 @@
|
||||
// Outline shader variant of "Spine/SkeletonGraphic"
|
||||
|
||||
Shader "Spine/Outline/SkeletonGraphic"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
[Toggle(_CANVAS_GROUP_COMPATIBLE)] _CanvasGroupCompatible("CanvasGroup Compatible", Int) = 0
|
||||
_Color ("Tint", Color) = (1,1,1,1)
|
||||
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp ("Stencil Comparison", Float) = 8
|
||||
[HideInInspector] _Stencil ("Stencil ID", Float) = 0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.StencilOp)] _StencilOp ("Stencil Operation", Float) = 0
|
||||
[HideInInspector] _StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||
[HideInInspector] _StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||
|
||||
[HideInInspector] _ColorMask ("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
"PreviewType"="Plane"
|
||||
"CanUseSpriteAtlas"="True"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Fog { Mode Off }
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass {
|
||||
Name "Outline"
|
||||
CGPROGRAM
|
||||
#pragma vertex vertOutlineGraphic
|
||||
#pragma fragment fragOutline
|
||||
#define SKELETON_GRAPHIC
|
||||
#pragma shader_feature _ _USE8NEIGHBOURHOOD_ON
|
||||
#include "../CGIncludes/Spine-Outline-Pass.cginc"
|
||||
ENDCG
|
||||
}
|
||||
|
||||
UsePass "Spine/SkeletonGraphic/NORMAL"
|
||||
}
|
||||
FallBack "Spine/SkeletonGraphic"
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f5d14d2a7fedb84998c50eb96c8b748
|
||||
timeCreated: 1573829873
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,68 +0,0 @@
|
||||
// Outline shader variant of "Spine/SkeletonGraphic Tint Black"
|
||||
|
||||
Shader "Spine/Outline/SkeletonGraphic Tint Black"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
[Toggle(_CANVAS_GROUP_COMPATIBLE)] _CanvasGroupCompatible("CanvasGroup Compatible", Int) = 0
|
||||
|
||||
_Color ("Tint", Color) = (1,1,1,1)
|
||||
_Black ("Black Point", Color) = (0,0,0,0)
|
||||
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp ("Stencil Comparison", Float) = 8
|
||||
[HideInInspector] _Stencil ("Stencil ID", Float) = 0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.StencilOp)] _StencilOp ("Stencil Operation", Float) = 0
|
||||
[HideInInspector] _StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||
[HideInInspector] _StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||
|
||||
[HideInInspector] _ColorMask ("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
"PreviewType"="Plane"
|
||||
"CanUseSpriteAtlas"="True"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Fog { Mode Off }
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
UsePass "Spine/Outline/SkeletonGraphic/OUTLINE"
|
||||
|
||||
UsePass "Spine/SkeletonGraphic Tint Black/NORMAL"
|
||||
}
|
||||
FallBack "Spine/SkeletonGraphic Tint Black"
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d55d64dd09c46af40a319933a62fa1b2
|
||||
timeCreated: 1573830121
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,46 +0,0 @@
|
||||
// Outline shader variant of "Spine/Skeleton Tint"
|
||||
|
||||
Shader "Spine/Outline/Skeleton Tint" {
|
||||
Properties {
|
||||
_Color ("Tint Color", Color) = (1,1,1,1)
|
||||
_Black ("Black Point", Color) = (0,0,0,0)
|
||||
[NoScaleOffset] _MainTex ("MainTex", 2D) = "black" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
_Cutoff("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
|
||||
|
||||
Fog { Mode Off }
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
Lighting Off
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
UsePass "Spine/Outline/Skeleton/OUTLINE"
|
||||
|
||||
UsePass "Spine/Skeleton Tint/NORMAL"
|
||||
|
||||
UsePass "Spine/Skeleton Tint/CASTER"
|
||||
}
|
||||
FallBack "Spine/Skeleton Tint"
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f1fdc166fed03649835949d3b79cba3
|
||||
timeCreated: 1573817434
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,47 +0,0 @@
|
||||
// Outline shader variant of "Spine/Skeleton Tint Black"
|
||||
|
||||
Shader "Spine/Outline/Skeleton Tint Black" {
|
||||
Properties {
|
||||
_Color ("Tint Color", Color) = (1,1,1,1)
|
||||
_Black ("Black Point", Color) = (0,0,0,0)
|
||||
[NoScaleOffset] _MainTex ("MainTex", 2D) = "black" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
LOD 100
|
||||
|
||||
Fog { Mode Off }
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
Lighting Off
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
UsePass "Spine/Outline/Skeleton/OUTLINE"
|
||||
|
||||
UsePass "Spine/Skeleton Tint Black/NORMAL"
|
||||
|
||||
UsePass "Spine/Skeleton Tint Black/CASTER"
|
||||
}
|
||||
FallBack "Spine/Special/Skeleton Grayscale"
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 49cf725a1e40e7742be92917f83946c3
|
||||
timeCreated: 1573828963
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,43 +0,0 @@
|
||||
// Outline shader variant of "Spine/Special/Skeleton Grayscale"
|
||||
|
||||
Shader "Spine/Outline/Special/Skeleton Grayscale" {
|
||||
Properties {
|
||||
_GrayPhase ("Phase", Range(0, 1)) = 1
|
||||
[NoScaleOffset] _MainTex ("MainTex", 2D) = "white" {}
|
||||
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
|
||||
Blend One OneMinusSrcAlpha
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Lighting Off
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
UsePass "Spine/Outline/Skeleton/OUTLINE"
|
||||
|
||||
UsePass "Spine/Special/Skeleton Grayscale/NORMAL"
|
||||
|
||||
UsePass "Spine/Special/Skeleton Grayscale/CASTER"
|
||||
}
|
||||
FallBack "Spine/Special/Skeleton Grayscale"
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1d3e1518ae643a749b086bc7972893d2
|
||||
timeCreated: 1573828963
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 615182d5e489bf3478299e5bbf15dc23
|
||||
folderAsset: yes
|
||||
timeCreated: 1573830740
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,81 +0,0 @@
|
||||
// Outline shader variant of "Spine/Sprite/Pixel Lit"
|
||||
|
||||
Shader "Spine/Outline/Sprite/Pixel Lit"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Main Texture", 2D) = "white" {}
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
|
||||
_BumpScale("Scale", Float) = 1.0
|
||||
_BumpMap ("Normal Map", 2D) = "bump" {}
|
||||
|
||||
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
|
||||
|
||||
_EmissionColor("Color", Color) = (0,0,0,0)
|
||||
_EmissionMap("Emission", 2D) = "white" {}
|
||||
_EmissionPower("Emission Power", Float) = 2.0
|
||||
|
||||
_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5
|
||||
_GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0
|
||||
[Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
|
||||
_MetallicGlossMap("Metallic", 2D) = "white" {}
|
||||
|
||||
_DiffuseRamp ("Diffuse Ramp Texture", 2D) = "gray" {}
|
||||
|
||||
_FixedNormal ("Fixed Normal", Vector) = (0,0,1,1)
|
||||
_Cutoff ("Depth alpha cutoff", Range(0,1)) = 0.5
|
||||
_ShadowAlphaCutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
_CustomRenderQueue ("Custom Render Queue", Float) = 0.0
|
||||
|
||||
_OverlayColor ("Overlay Color", Color) = (0,0,0,0)
|
||||
_Hue("Hue", Range(-0.5,0.5)) = 0.0
|
||||
_Saturation("Saturation", Range(0,2)) = 1.0
|
||||
_Brightness("Brightness", Range(0,2)) = 1.0
|
||||
|
||||
_RimPower("Rim Power", Float) = 2.0
|
||||
_RimColor ("Rim Color", Color) = (1,1,1,1)
|
||||
|
||||
_BlendTex ("Blend Texture", 2D) = "white" {}
|
||||
_BlendAmount ("Blend", Range(0,1)) = 0.0
|
||||
|
||||
[HideInInspector] _SrcBlend ("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend ("__dst", Float) = 0.0
|
||||
[HideInInspector] _RenderQueue ("__queue", Float) = 0.0
|
||||
[HideInInspector] _Cull ("__cull", Float) = 0.0
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "RenderType"="Sprite" "AlphaDepth"="False" "CanUseSpriteAtlas"="True" "IgnoreProjector"="True" }
|
||||
LOD 200
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
UsePass "Spine/Outline/Skeleton/OUTLINE"
|
||||
|
||||
UsePass "Spine/Sprite/Pixel Lit/FORWARD"
|
||||
|
||||
UsePass "Spine/Sprite/Pixel Lit/FORWARD_DELTA"
|
||||
|
||||
UsePass "Spine/Sprite/Pixel Lit/SHADOWCASTER"
|
||||
}
|
||||
|
||||
FallBack "Spine/Sprite/Pixel Lit"
|
||||
CustomEditor "SpineSpriteShaderGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a27d4b27c8ecd9840a03558ccc5ad8a3
|
||||
timeCreated: 1573830741
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,61 +0,0 @@
|
||||
// Outline shader variant of "Spine/Sprite/Unlit"
|
||||
|
||||
Shader "Spine/Outline/Sprite/Unlit"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Main Texture", 2D) = "white" {}
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
|
||||
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
|
||||
|
||||
_ZWrite ("Depth Write", Float) = 0.0
|
||||
_Cutoff ("Depth alpha cutoff", Range(0,1)) = 0.0
|
||||
_ShadowAlphaCutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
_CustomRenderQueue ("Custom Render Queue", Float) = 0.0
|
||||
|
||||
_OverlayColor ("Overlay Color", Color) = (0,0,0,0)
|
||||
_Hue("Hue", Range(-0.5,0.5)) = 0.0
|
||||
_Saturation("Saturation", Range(0,2)) = 1.0
|
||||
_Brightness("Brightness", Range(0,2)) = 1.0
|
||||
|
||||
_BlendTex ("Blend Texture", 2D) = "white" {}
|
||||
_BlendAmount ("Blend", Range(0,1)) = 0.0
|
||||
|
||||
[HideInInspector] _SrcBlend ("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend ("__dst", Float) = 0.0
|
||||
[HideInInspector] _RenderQueue ("__queue", Float) = 0.0
|
||||
[HideInInspector] _Cull ("__cull", Float) = 0.0
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "RenderType"="Sprite" "AlphaDepth"="False" "CanUseSpriteAtlas"="True" "IgnoreProjector"="True" }
|
||||
LOD 100
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
UsePass "Spine/Outline/Skeleton/OUTLINE"
|
||||
|
||||
UsePass "Spine/Sprite/Unlit/NORMAL"
|
||||
|
||||
UsePass "Spine/Sprite/Unlit/SHADOWCASTER"
|
||||
}
|
||||
FallBack "Spine/Sprite/Unlit"
|
||||
CustomEditor "SpineSpriteShaderGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 276c07e3bdd5719458187a5823e9d96a
|
||||
timeCreated: 1573830740
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,80 +0,0 @@
|
||||
// Outline shader variant of "Spine/Sprite/Vertex Lit"
|
||||
|
||||
Shader "Spine/Outline/Sprite/Vertex Lit"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Main Texture", 2D) = "white" {}
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
|
||||
_BumpScale("Scale", Float) = 1.0
|
||||
_BumpMap ("Normal Map", 2D) = "bump" {}
|
||||
|
||||
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
|
||||
|
||||
_EmissionColor("Color", Color) = (0,0,0,0)
|
||||
_EmissionMap("Emission", 2D) = "white" {}
|
||||
_EmissionPower("Emission Power", Float) = 2.0
|
||||
|
||||
_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5
|
||||
_GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0
|
||||
[Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
|
||||
_MetallicGlossMap("Metallic", 2D) = "white" {}
|
||||
|
||||
_DiffuseRamp ("Diffuse Ramp Texture", 2D) = "gray" {}
|
||||
|
||||
_FixedNormal ("Fixed Normal", Vector) = (0,0,1,1)
|
||||
_ZWrite ("Depth Write", Float) = 0.0
|
||||
_Cutoff ("Depth alpha cutoff", Range(0,1)) = 0.0
|
||||
_ShadowAlphaCutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
_CustomRenderQueue ("Custom Render Queue", Float) = 0.0
|
||||
|
||||
_OverlayColor ("Overlay Color", Color) = (0,0,0,0)
|
||||
_Hue("Hue", Range(-0.5,0.5)) = 0.0
|
||||
_Saturation("Saturation", Range(0,2)) = 1.0
|
||||
_Brightness("Brightness", Range(0,2)) = 1.0
|
||||
|
||||
_RimPower("Rim Power", Float) = 2.0
|
||||
_RimColor ("Rim Color", Color) = (1,1,1,1)
|
||||
|
||||
_BlendTex ("Blend Texture", 2D) = "white" {}
|
||||
_BlendAmount ("Blend", Range(0,1)) = 0.0
|
||||
|
||||
[HideInInspector] _SrcBlend ("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend ("__dst", Float) = 0.0
|
||||
[HideInInspector] _RenderQueue ("__queue", Float) = 0.0
|
||||
[HideInInspector] _Cull ("__cull", Float) = 0.0
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "RenderType"="Sprite" "AlphaDepth"="False" "CanUseSpriteAtlas"="True" "IgnoreProjector"="True" }
|
||||
LOD 150
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
UsePass "Spine/Outline/Skeleton/OUTLINE"
|
||||
|
||||
UsePass "Spine/Sprite/Vertex Lit/VERTEX"
|
||||
|
||||
UsePass "Spine/Sprite/Vertex Lit/SHADOWCASTER"
|
||||
}
|
||||
|
||||
FallBack "Spine/Sprite/Vertex Lit"
|
||||
CustomEditor "SpineSpriteShaderGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 30ef5dd318033004588a6481c092416a
|
||||
timeCreated: 1573830740
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,148 +0,0 @@
|
||||
// This is a premultiply-alpha adaptation of the built-in Unity shader "UI/Default" to allow Unity UI stencil masking.
|
||||
|
||||
Shader "Spine/SkeletonGraphic Tint Black"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
[Toggle(_CANVAS_GROUP_COMPATIBLE)] _CanvasGroupCompatible("CanvasGroup Compatible", Int) = 0
|
||||
|
||||
_Color ("Tint Color", Color) = (1,1,1,1)
|
||||
_Black ("Dark Color", Color) = (0,0,0,0)
|
||||
[Toggle(_DARK_COLOR_ALPHA_ADDITIVE)] _DarkColorAlphaAdditive("Additive DarkColor.A", Int) = 0
|
||||
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp ("Stencil Comparison", Float) = 8
|
||||
[HideInInspector] _Stencil ("Stencil ID", Float) = 0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.StencilOp)] _StencilOp ("Stencil Operation", Float) = 0
|
||||
[HideInInspector] _StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||
[HideInInspector] _StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||
|
||||
[HideInInspector] _ColorMask ("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
"PreviewType"="Plane"
|
||||
"CanUseSpriteAtlas"="True"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Fog { Mode Off }
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Normal"
|
||||
|
||||
CGPROGRAM
|
||||
#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
|
||||
#pragma shader_feature _ _CANVAS_GROUP_COMPATIBLE
|
||||
#pragma shader_feature _ _DARK_COLOR_ALPHA_ADDITIVE
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float2 uv1 : TEXCOORD1;
|
||||
float2 uv2 : TEXCOORD2;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
half2 texcoord : TEXCOORD0;
|
||||
float4 darkColor : TEXCOORD1;
|
||||
float4 worldPosition : TEXCOORD2;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
fixed4 _Black;
|
||||
fixed4 _TextureSampleAdd;
|
||||
float4 _ClipRect;
|
||||
|
||||
VertexOutput vert (VertexInput IN) {
|
||||
VertexOutput OUT;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(IN);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
||||
|
||||
OUT.worldPosition = IN.vertex;
|
||||
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
|
||||
OUT.texcoord = IN.texcoord;
|
||||
|
||||
OUT.color = IN.color;
|
||||
OUT.darkColor = float4(IN.uv1.r, IN.uv1.g, IN.uv2.r, IN.uv2.g);
|
||||
return OUT;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
#include "../CGIncludes/Spine-Skeleton-Tint-Common.cginc"
|
||||
|
||||
fixed4 frag (VertexOutput IN) : SV_Target
|
||||
{
|
||||
half4 texColor = (tex2D(_MainTex, IN.texcoord) + _TextureSampleAdd);
|
||||
texColor *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip(texColor.a - 0.001);
|
||||
#endif
|
||||
|
||||
float4 vertexColor = IN.color * float4(_Color.rgb * _Color.a, _Color.a);
|
||||
#ifdef _CANVAS_GROUP_COMPATIBLE
|
||||
// CanvasGroup alpha multiplies existing vertex color alpha, but
|
||||
// does not premultiply it to rgb components. This causes problems
|
||||
// with additive blending (alpha = 0), which is why we store the
|
||||
// alpha value in uv2.g (darkColor.a).
|
||||
float originalAlpha = IN.darkColor.a;
|
||||
float canvasAlpha = (originalAlpha == 0) ? IN.color.a : IN.color.a / originalAlpha;
|
||||
vertexColor.a = originalAlpha * _Color.a;
|
||||
#endif
|
||||
float4 fragColor = fragTintedColor(texColor, _Black.rgb + IN.darkColor, vertexColor, _Color.a, _Black.a);
|
||||
#ifdef _CANVAS_GROUP_COMPATIBLE
|
||||
fragColor.rgba *= canvasAlpha;
|
||||
#endif
|
||||
return fragColor;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f64c7bc238bb2c246b8ca1912b2b6b9c
|
||||
timeCreated: 1455080068
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,141 +0,0 @@
|
||||
// This is a premultiply-alpha adaptation of the built-in Unity shader "UI/Default" in Unity 5.6.2 to allow Unity UI stencil masking.
|
||||
|
||||
Shader "Spine/SkeletonGraphic"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
[Toggle(_CANVAS_GROUP_COMPATIBLE)] _CanvasGroupCompatible("CanvasGroup Compatible", Int) = 0
|
||||
_Color ("Tint", Color) = (1,1,1,1)
|
||||
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp ("Stencil Comparison", Float) = 8
|
||||
[HideInInspector] _Stencil ("Stencil ID", Float) = 0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.StencilOp)] _StencilOp ("Stencil Operation", Float) = 0
|
||||
[HideInInspector] _StencilWriteMask ("Stencil Write Mask", Float) = 255
|
||||
[HideInInspector] _StencilReadMask ("Stencil Read Mask", Float) = 255
|
||||
|
||||
[HideInInspector] _ColorMask ("Color Mask", Float) = 15
|
||||
|
||||
[Toggle(UNITY_UI_ALPHACLIP)] _UseUIAlphaClip ("Use Alpha Clip", Float) = 0
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags
|
||||
{
|
||||
"Queue"="Transparent"
|
||||
"IgnoreProjector"="True"
|
||||
"RenderType"="Transparent"
|
||||
"PreviewType"="Plane"
|
||||
"CanUseSpriteAtlas"="True"
|
||||
}
|
||||
|
||||
Stencil
|
||||
{
|
||||
Ref [_Stencil]
|
||||
Comp [_StencilComp]
|
||||
Pass [_StencilOp]
|
||||
ReadMask [_StencilReadMask]
|
||||
WriteMask [_StencilWriteMask]
|
||||
}
|
||||
|
||||
Cull Off
|
||||
Lighting Off
|
||||
ZWrite Off
|
||||
ZTest [unity_GUIZTestMode]
|
||||
Fog { Mode Off }
|
||||
Blend One OneMinusSrcAlpha
|
||||
ColorMask [_ColorMask]
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Normal"
|
||||
|
||||
CGPROGRAM
|
||||
#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
|
||||
#pragma shader_feature _ _CANVAS_GROUP_COMPATIBLE
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma target 2.0
|
||||
|
||||
#include "UnityCG.cginc"
|
||||
#include "UnityUI.cginc"
|
||||
|
||||
#pragma multi_compile __ UNITY_UI_ALPHACLIP
|
||||
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
float4 vertex : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
half2 texcoord : TEXCOORD0;
|
||||
float4 worldPosition : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
fixed4 _Color;
|
||||
fixed4 _TextureSampleAdd;
|
||||
float4 _ClipRect;
|
||||
|
||||
VertexOutput vert (VertexInput IN) {
|
||||
VertexOutput OUT;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(IN);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(OUT);
|
||||
|
||||
OUT.worldPosition = IN.vertex;
|
||||
OUT.vertex = UnityObjectToClipPos(OUT.worldPosition);
|
||||
OUT.texcoord = IN.texcoord;
|
||||
|
||||
#ifdef UNITY_HALF_TEXEL_OFFSET
|
||||
OUT.vertex.xy += (_ScreenParams.zw-1.0) * float2(-1,1);
|
||||
#endif
|
||||
|
||||
OUT.color = IN.color * float4(_Color.rgb * _Color.a, _Color.a); // Combine a PMA version of _Color with vertexColor.
|
||||
return OUT;
|
||||
}
|
||||
|
||||
sampler2D _MainTex;
|
||||
|
||||
fixed4 frag (VertexOutput IN) : SV_Target
|
||||
{
|
||||
half4 texColor = tex2D(_MainTex, IN.texcoord);
|
||||
|
||||
#if defined(_STRAIGHT_ALPHA_INPUT)
|
||||
texColor.rgb *= texColor.a;
|
||||
#endif
|
||||
|
||||
half4 color = (texColor + _TextureSampleAdd) * IN.color;
|
||||
#ifdef _CANVAS_GROUP_COMPATIBLE
|
||||
// CanvasGroup alpha sets vertex color alpha, but does not premultiply it to rgb components.
|
||||
color.rgb *= IN.color.a;
|
||||
#endif
|
||||
|
||||
color *= UnityGet2DClipping(IN.worldPosition.xy, _ClipRect);
|
||||
|
||||
#ifdef UNITY_UI_ALPHACLIP
|
||||
clip (color.a - 0.001);
|
||||
#endif
|
||||
|
||||
return color;
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fa95b0fb6983c0f40a152e6f9aa82bfb
|
||||
timeCreated: 1455080068
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,127 +0,0 @@
|
||||
// Spine/Skeleton Tint
|
||||
// - Two color tint
|
||||
// - unlit
|
||||
// - Premultiplied alpha blending (Optional straight alpha input)
|
||||
// - No depth, no backface culling, no fog.
|
||||
|
||||
Shader "Spine/Skeleton Tint" {
|
||||
Properties {
|
||||
_Color ("Tint Color", Color) = (1,1,1,1)
|
||||
_Black ("Dark Color", Color) = (0,0,0,0)
|
||||
[NoScaleOffset] _MainTex ("MainTex", 2D) = "black" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
_Cutoff("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[Toggle(_DARK_COLOR_ALPHA_ADDITIVE)] _DarkColorAlphaAdditive("Additive DarkColor.A", Int) = 0
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
|
||||
|
||||
Fog { Mode Off }
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
Lighting Off
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
Pass {
|
||||
Name "Normal"
|
||||
|
||||
CGPROGRAM
|
||||
#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
|
||||
#pragma shader_feature _ _DARK_COLOR_ALPHA_ADDITIVE
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
sampler2D _MainTex;
|
||||
float4 _Color;
|
||||
float4 _Black;
|
||||
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
o.vertexColor = v.vertexColor * float4(_Color.rgb * _Color.a, _Color.a); // Combine a PMA version of _Color with vertexColor.
|
||||
return o;
|
||||
}
|
||||
|
||||
#include "CGIncludes/Spine-Skeleton-Tint-Common.cginc"
|
||||
|
||||
float4 frag (VertexOutput i) : SV_Target {
|
||||
float4 texColor = tex2D(_MainTex, i.uv);
|
||||
return fragTintedColor(texColor, _Black.rgb, i.vertexColor, _Color.a, _Black.a);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass {
|
||||
Name "Caster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
Offset 1, 1
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
Fog { Mode Off }
|
||||
Cull Off
|
||||
Lighting Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
sampler2D _MainTex;
|
||||
fixed _Cutoff;
|
||||
|
||||
struct VertexOutput {
|
||||
V2F_SHADOW_CASTER;
|
||||
float4 uvAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
VertexOutput vert (appdata_base v, float4 vertexColor : COLOR) {
|
||||
VertexOutput o;
|
||||
o.uvAndAlpha = v.texcoord;
|
||||
o.uvAndAlpha.a = vertexColor.a;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag (VertexOutput i) : SV_Target {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy);
|
||||
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 522f03282fd79be47b306e2ef4b593fd
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,131 +0,0 @@
|
||||
// Spine/Skeleton Tint Black
|
||||
// - Two color tint
|
||||
// - UV2 and UV3 as Black Tint color.
|
||||
// - Final black tint is (UV black data and _Black/"Black Point")
|
||||
// - unlit
|
||||
// - Premultiplied alpha blending (optional straight alpha input)
|
||||
// - No depth, no backface culling, no fog.
|
||||
|
||||
Shader "Spine/Skeleton Tint Black" {
|
||||
Properties {
|
||||
_Color ("Tint Color", Color) = (1,1,1,1)
|
||||
_Black ("Dark Color", Color) = (0,0,0,0)
|
||||
[NoScaleOffset] _MainTex ("MainTex", 2D) = "black" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[Toggle(_DARK_COLOR_ALPHA_ADDITIVE)] _DarkColorAlphaAdditive("Additive DarkColor.A", Int) = 0
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
|
||||
LOD 100
|
||||
|
||||
Fog { Mode Off }
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
Lighting Off
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
Pass {
|
||||
Name "Normal"
|
||||
|
||||
CGPROGRAM
|
||||
#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
|
||||
#pragma shader_feature _ _DARK_COLOR_ALPHA_ADDITIVE
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
sampler2D _MainTex;
|
||||
float4 _Color;
|
||||
float4 _Black;
|
||||
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float2 uv1 : TEXCOORD1;
|
||||
float2 uv2 : TEXCOORD2;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float3 darkColor : TEXCOORD1;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o;
|
||||
o.pos = UnityObjectToClipPos(v.vertex); // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
|
||||
o.uv = v.uv;
|
||||
o.vertexColor = v.vertexColor * float4(_Color.rgb * _Color.a, _Color.a); // Combine a PMA version of _Color with vertexColor.
|
||||
o.darkColor = float3(v.uv1.r, v.uv1.g, v.uv2.r);
|
||||
return o;
|
||||
}
|
||||
|
||||
#include "CGIncludes/Spine-Skeleton-Tint-Common.cginc"
|
||||
|
||||
float4 frag (VertexOutput i) : SV_Target {
|
||||
float4 texColor = tex2D(_MainTex, i.uv);
|
||||
return fragTintedColor(texColor, _Black.rgb + i.darkColor, i.vertexColor, _Color.a, _Black.a);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass {
|
||||
Name "Caster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
Offset 1, 1
|
||||
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
sampler2D _MainTex;
|
||||
fixed _Cutoff;
|
||||
|
||||
struct v2f {
|
||||
V2F_SHADOW_CASTER;
|
||||
float4 uvAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
v2f vert (appdata_base v, float4 vertexColor : COLOR) {
|
||||
v2f o;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
o.uvAndAlpha = v.texcoord;
|
||||
o.uvAndAlpha.a = vertexColor.a;
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag (v2f i) : SV_Target {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy);
|
||||
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: deee23ab4aa38564ead2ac05e112c169
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,118 +0,0 @@
|
||||
Shader "Spine/Skeleton" {
|
||||
Properties {
|
||||
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[NoScaleOffset] _MainTex ("Main Texture", 2D) = "black" {}
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
|
||||
|
||||
Fog { Mode Off }
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Blend One OneMinusSrcAlpha
|
||||
Lighting Off
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
Pass {
|
||||
Name "Normal"
|
||||
|
||||
CGPROGRAM
|
||||
#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
sampler2D _MainTex;
|
||||
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.uv;
|
||||
o.vertexColor = v.vertexColor;
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag (VertexOutput i) : SV_Target {
|
||||
float4 texColor = tex2D(_MainTex, i.uv);
|
||||
|
||||
#if defined(_STRAIGHT_ALPHA_INPUT)
|
||||
texColor.rgb *= texColor.a;
|
||||
#endif
|
||||
|
||||
return (texColor * i.vertexColor);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass {
|
||||
Name "Caster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
Offset 1, 1
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
Fog { Mode Off }
|
||||
Cull Off
|
||||
Lighting Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
sampler2D _MainTex;
|
||||
fixed _Cutoff;
|
||||
|
||||
struct VertexOutput {
|
||||
V2F_SHADOW_CASTER;
|
||||
float4 uvAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
VertexOutput vert (appdata_base v, float4 vertexColor : COLOR) {
|
||||
VertexOutput o;
|
||||
o.uvAndAlpha = v.texcoord;
|
||||
o.uvAndAlpha.a = vertexColor.a;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag (VertexOutput i) : SV_Target {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy);
|
||||
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e8a610c9e01c3648bac42585e5fc676
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,127 +0,0 @@
|
||||
// - Unlit
|
||||
// - Premultiplied Alpha Blending (Optional straight alpha input)
|
||||
// - Double-sided, no depth
|
||||
|
||||
Shader "Spine/Special/Skeleton Grayscale" {
|
||||
Properties {
|
||||
_GrayPhase ("Phase", Range(0, 1)) = 1
|
||||
[NoScaleOffset] _MainTex ("MainTex", 2D) = "white" {}
|
||||
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" "PreviewType"="Plane" }
|
||||
Blend One OneMinusSrcAlpha
|
||||
Cull Off
|
||||
ZWrite Off
|
||||
Lighting Off
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
Pass {
|
||||
Name "Normal"
|
||||
|
||||
CGPROGRAM
|
||||
#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
sampler2D _MainTex;
|
||||
float _GrayPhase;
|
||||
|
||||
struct VertexInput {
|
||||
float4 vertex : POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
struct VertexOutput {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 vertexColor : COLOR;
|
||||
};
|
||||
|
||||
VertexOutput vert (VertexInput v) {
|
||||
VertexOutput o = (VertexOutput)0;
|
||||
o.uv = v.uv;
|
||||
o.vertexColor = v.vertexColor;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag (VertexOutput i) : SV_Target {
|
||||
float4 rawColor = tex2D(_MainTex,i.uv);
|
||||
float finalAlpha = (rawColor.a * i.vertexColor.a);
|
||||
|
||||
#if defined(_STRAIGHT_ALPHA_INPUT)
|
||||
rawColor.rgb *= rawColor.a;
|
||||
#endif
|
||||
|
||||
rawColor.rgb *= i.vertexColor.rgb;
|
||||
|
||||
float3 finalColor = lerp(rawColor.rgb, dot(rawColor.rgb, float3(0.3, 0.59, 0.11)), _GrayPhase);
|
||||
return fixed4(finalColor, finalAlpha);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
Pass {
|
||||
Name "Caster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
Offset 1, 1
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
|
||||
Fog { Mode Off }
|
||||
Cull Off
|
||||
Lighting Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#include "UnityCG.cginc"
|
||||
sampler2D _MainTex;
|
||||
fixed _Cutoff;
|
||||
|
||||
struct VertexOutput {
|
||||
V2F_SHADOW_CASTER;
|
||||
float4 uvAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
VertexOutput vert (appdata_base v, float4 vertexColor : COLOR) {
|
||||
VertexOutput o;
|
||||
o.uvAndAlpha = v.texcoord;
|
||||
o.uvAndAlpha.a = vertexColor.a;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
return o;
|
||||
}
|
||||
|
||||
float4 frag (VertexOutput i) : SV_Target {
|
||||
fixed4 texcol = tex2D(_MainTex, i.uvAndAlpha.xy);
|
||||
clip(texcol.a * i.uvAndAlpha.a - _Cutoff);
|
||||
SHADOW_CASTER_FRAGMENT(i)
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
FallBack "Diffuse"
|
||||
CustomEditor "SpineShaderWithOutlineGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ea7e7c05f36541b4bb280f98ebda8ba1
|
||||
timeCreated: 1492385797
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a831a8ed72a588a48b2fb892e7f37371
|
||||
folderAsset: yes
|
||||
timeCreated: 1479419399
|
||||
licenseType: Free
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,225 +0,0 @@
|
||||
#ifndef SPRITE_LIGHTING_INCLUDED
|
||||
#define SPRITE_LIGHTING_INCLUDED
|
||||
|
||||
//Check for using mesh normals
|
||||
#if !defined(_FIXED_NORMALS_VIEWSPACE) && !defined(_FIXED_NORMALS_VIEWSPACE_BACKFACE) && !defined(_FIXED_NORMALS_MODELSPACE) && !defined(_FIXED_NORMALS_MODELSPACE_BACKFACE) && !defined(_FIXED_NORMALS_WORLDSPACE)
|
||||
#define MESH_NORMALS
|
||||
#endif
|
||||
|
||||
//Check for fixing backfacing tangents
|
||||
#if defined(_FIXED_NORMALS_VIEWSPACE_BACKFACE) || defined(_FIXED_NORMALS_MODELSPACE_BACKFACE)
|
||||
#define FIXED_NORMALS_BACKFACE_RENDERING
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////
|
||||
// Vertex structs
|
||||
//
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 texcoord : TEXCOORD0;
|
||||
float4 color : COLOR;
|
||||
#if defined(MESH_NORMALS)
|
||||
float3 normal : NORMAL;
|
||||
#endif // _FIXED_NORMALS
|
||||
#if defined(_NORMALMAP)
|
||||
float4 tangent : TANGENT;
|
||||
#endif // _NORMALMAP
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
////////////////////////////////////////
|
||||
// Normal functions
|
||||
//
|
||||
|
||||
#if !defined(USE_LWRP) && !defined(USE_URP)
|
||||
uniform float4 _FixedNormal = float4(0, 0, 1, 1);
|
||||
#endif
|
||||
|
||||
inline float3 getFixedNormal()
|
||||
{
|
||||
return _FixedNormal.xyz;
|
||||
}
|
||||
|
||||
inline float calculateBackfacingSign(float3 worldPos)
|
||||
{
|
||||
//If we're using fixed normals and mesh is facing away from camera, flip tangentSign
|
||||
//Unity uses a left handed coordinate system so camera always looks down the negative z axis
|
||||
float3 cameraForward = float3(0,0,-1);
|
||||
float3 meshWorldForward = mul((float3x3)unity_ObjectToWorld, cameraForward);
|
||||
float3 toCamera = _WorldSpaceCameraPos - worldPos;
|
||||
return sign(dot(toCamera, meshWorldForward));
|
||||
}
|
||||
|
||||
inline half3 calculateSpriteWorldNormal(VertexInput vertex, float backFaceSign)
|
||||
{
|
||||
#if defined(MESH_NORMALS)
|
||||
|
||||
return calculateWorldNormal(vertex.normal);
|
||||
|
||||
#else // !MESH_NORMALS
|
||||
|
||||
float3 normal = getFixedNormal();
|
||||
|
||||
#if defined(_FIXED_NORMALS_VIEWSPACE) || defined(_FIXED_NORMALS_VIEWSPACE_BACKFACE)
|
||||
//View space fixed normal
|
||||
//Rotate fixed normal by inverse view matrix to convert the fixed normal into world space
|
||||
float3x3 invView = transpose((float3x3)UNITY_MATRIX_V);
|
||||
return normalize(mul(invView, normal));
|
||||
#elif defined (_FIXED_NORMALS_WORLDSPACE)
|
||||
//World space fixed normal
|
||||
return normal;
|
||||
#else
|
||||
//Model space fixed normal.
|
||||
#if defined(FIXED_NORMALS_BACKFACE_RENDERING)
|
||||
//If back face rendering is enabled and the sprite is facing away from the camera (ie we're rendering the backface) then need to flip the normal
|
||||
normal *= backFaceSign;
|
||||
#endif
|
||||
return calculateWorldNormal(normal);
|
||||
#endif
|
||||
|
||||
#endif // !MESH_NORMALS
|
||||
}
|
||||
|
||||
inline half3 calculateSpriteViewNormal(VertexInput vertex, float backFaceSign)
|
||||
{
|
||||
#if defined(MESH_NORMALS)
|
||||
|
||||
return normalize(mul((float3x3)UNITY_MATRIX_IT_MV, vertex.normal));
|
||||
|
||||
#else // !MESH_NORMALS
|
||||
|
||||
float3 normal = getFixedNormal();
|
||||
|
||||
#if defined(_FIXED_NORMALS_VIEWSPACE) || defined(_FIXED_NORMALS_VIEWSPACE_BACKFACE)
|
||||
//View space fixed normal
|
||||
return normal;
|
||||
#elif defined (_FIXED_NORMALS_WORLDSPACE)
|
||||
//World space fixed normal
|
||||
return normalize(mul((float3x3)UNITY_MATRIX_V, normal));
|
||||
#else
|
||||
//Model space fixed normal
|
||||
#if defined(FIXED_NORMALS_BACKFACE_RENDERING)
|
||||
//If back face rendering is enabled and the sprite is facing away from the camera (ie we're rendering the backface) then need to flip the normal
|
||||
normal *= backFaceSign;
|
||||
#endif
|
||||
return normalize(mul((float3x3)UNITY_MATRIX_IT_MV, normal));
|
||||
#endif
|
||||
|
||||
#endif // !MESH_NORMALS
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
// Normal map functions
|
||||
//
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
|
||||
inline half3 calculateSpriteWorldBinormal(VertexInput vertex, half3 normalWorld, half3 tangentWorld, float backFaceSign)
|
||||
{
|
||||
float tangentSign = vertex.tangent.w;
|
||||
|
||||
#if defined(FIXED_NORMALS_BACKFACE_RENDERING)
|
||||
tangentSign *= backFaceSign;
|
||||
#endif
|
||||
|
||||
return calculateWorldBinormal(normalWorld, tangentWorld, tangentSign);
|
||||
}
|
||||
|
||||
#endif // _NORMALMAP
|
||||
|
||||
#if defined(_DIFFUSE_RAMP)
|
||||
|
||||
|
||||
////////////////////////////////////////
|
||||
// Diffuse ramp functions
|
||||
//
|
||||
|
||||
uniform sampler2D _DiffuseRamp;
|
||||
|
||||
inline fixed3 calculateDiffuseRamp(float ramp)
|
||||
{
|
||||
return tex2D(_DiffuseRamp, float2(ramp, ramp)).rgb;
|
||||
}
|
||||
|
||||
inline fixed3 calculateRampedDiffuse(fixed3 lightColor, float attenuation, float angleDot)
|
||||
{
|
||||
#if defined(_FULLRANGE_HARD_RAMP)
|
||||
float d = angleDot;
|
||||
half3 ramp = calculateDiffuseRamp(d);
|
||||
return lightColor * ramp * attenuation;
|
||||
#elif defined(_FULLRANGE_SOFT_RAMP)
|
||||
float d = angleDot;
|
||||
half3 ramp = calculateDiffuseRamp(d * attenuation);
|
||||
return lightColor * ramp;
|
||||
#elif defined(_OLD_SOFT_RAMP)
|
||||
// for unmodified behaviour with existing projects when
|
||||
// the HARD_DIFFUSE_RAMP define was disabled in this file.
|
||||
// uses only the right half of the ramp texture, as
|
||||
// negative angleDot is clamped to [0,1] before.
|
||||
float d = angleDot * 0.5 + 0.5;
|
||||
half3 ramp = calculateDiffuseRamp(d);
|
||||
return lightColor * ramp * (attenuation * 2);
|
||||
#else // _OLD_HARD_RAMP
|
||||
// old default, for unmodified behaviour with existing projects,
|
||||
// uses only the right half of the ramp texture, as
|
||||
// negative angleDot is clamped to [0,1] before.
|
||||
float d = angleDot * 0.5 + 0.5;
|
||||
half3 ramp = calculateDiffuseRamp(d * attenuation * 2);
|
||||
return lightColor * ramp;
|
||||
#endif
|
||||
}
|
||||
#endif // _DIFFUSE_RAMP
|
||||
|
||||
////////////////////////////////////////
|
||||
// Rim Lighting functions
|
||||
//
|
||||
|
||||
#ifdef _RIM_LIGHTING
|
||||
#if !defined(USE_LWRP) && !defined(USE_URP)
|
||||
uniform float _RimPower;
|
||||
uniform fixed4 _RimColor;
|
||||
#endif
|
||||
|
||||
inline fixed3 applyRimLighting(fixed3 posWorld, fixed3 normalWorld, fixed4 pixel) : SV_Target
|
||||
{
|
||||
fixed3 viewDir = normalize(_WorldSpaceCameraPos - posWorld);
|
||||
float invDot = 1.0 - saturate(dot(normalWorld, viewDir));
|
||||
float rimPower = pow(invDot, _RimPower);
|
||||
float rim = saturate(rimPower * _RimColor.a);
|
||||
|
||||
#if defined(_DIFFUSE_RAMP)
|
||||
rim = calculateDiffuseRamp(rim).r;
|
||||
#endif
|
||||
|
||||
return lerp(pixel.rgb, _RimColor.xyz * pixel.a, rim);
|
||||
}
|
||||
|
||||
#endif //_RIM_LIGHTING
|
||||
|
||||
////////////////////////////////////////
|
||||
// Emission functions
|
||||
//
|
||||
|
||||
#ifdef _EMISSION
|
||||
|
||||
uniform sampler2D _EmissionMap;
|
||||
|
||||
#if !defined(USE_LWRP) && !defined(USE_URP)
|
||||
uniform fixed4 _EmissionColor;
|
||||
uniform float _EmissionPower;
|
||||
#endif
|
||||
|
||||
|
||||
#define APPLY_EMISSION(diffuse, uv) diffuse += tex2D(_EmissionMap, uv).rgb * _EmissionColor.rgb * _EmissionPower;
|
||||
#define APPLY_EMISSION_SPECULAR(pixel, uv) pixel.rgb += (tex2D(_EmissionMap, uv).rgb * _EmissionColor.rgb * _EmissionPower) * pixel.a;
|
||||
|
||||
#else //!_EMISSION
|
||||
|
||||
#define APPLY_EMISSION(diffuse, uv)
|
||||
#define APPLY_EMISSION_SPECULAR(pixel, uv)
|
||||
|
||||
#endif //!_EMISSION
|
||||
|
||||
#endif // SPRITE_LIGHTING_INCLUDED
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cfb891658099ca4bb0c9544c08e60f9
|
||||
timeCreated: 1494092582
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,252 +0,0 @@
|
||||
#ifndef SPRITE_PIXEL_LIGHTING_INCLUDED
|
||||
#define SPRITE_PIXEL_LIGHTING_INCLUDED
|
||||
|
||||
#include "ShaderShared.cginc"
|
||||
#include "SpriteLighting.cginc"
|
||||
#include "SpriteSpecular.cginc"
|
||||
#include "AutoLight.cginc"
|
||||
|
||||
////////////////////////////////////////
|
||||
// Defines
|
||||
//
|
||||
|
||||
////////////////////////////////////////
|
||||
// Vertex output struct
|
||||
//
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
#define _VERTEX_LIGHTING_INDEX TEXCOORD5
|
||||
#define _LIGHT_COORD_INDEX_0 6
|
||||
#define _LIGHT_COORD_INDEX_1 7
|
||||
#define _FOG_COORD_INDEX 8
|
||||
#else
|
||||
#define _VERTEX_LIGHTING_INDEX TEXCOORD3
|
||||
#define _LIGHT_COORD_INDEX_0 4
|
||||
#define _LIGHT_COORD_INDEX_1 5
|
||||
#define _FOG_COORD_INDEX 6
|
||||
#endif // _NORMALMAP
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
float4 posWorld : TEXCOORD1;
|
||||
half3 normalWorld : TEXCOORD2;
|
||||
#if defined(_NORMALMAP)
|
||||
half3 tangentWorld : TEXCOORD3;
|
||||
half3 binormalWorld : TEXCOORD4;
|
||||
#endif // _NORMALMAP
|
||||
fixed3 vertexLighting : _VERTEX_LIGHTING_INDEX;
|
||||
LIGHTING_COORDS(_LIGHT_COORD_INDEX_0, _LIGHT_COORD_INDEX_1)
|
||||
#if defined(_FOG)
|
||||
UNITY_FOG_COORDS(_FOG_COORD_INDEX)
|
||||
#endif // _FOG
|
||||
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
////////////////////////////////////////
|
||||
// Light calculations
|
||||
//
|
||||
|
||||
uniform fixed4 _LightColor0;
|
||||
|
||||
inline fixed3 calculateLightDiffuse(VertexOutput input, float3 normalWorld, inout fixed4 albedo)
|
||||
{
|
||||
//For directional lights _WorldSpaceLightPos0.w is set to zero
|
||||
float3 lightWorldDirection = normalize(_WorldSpaceLightPos0.xyz - input.posWorld.xyz * _WorldSpaceLightPos0.w);
|
||||
|
||||
float attenuation = LIGHT_ATTENUATION(input);
|
||||
float angleDot = max(0, dot(normalWorld, lightWorldDirection));
|
||||
|
||||
#if defined(_DIFFUSE_RAMP)
|
||||
fixed3 lightDiffuse = calculateRampedDiffuse(_LightColor0.rgb, attenuation, angleDot);
|
||||
#else
|
||||
fixed3 lightDiffuse = _LightColor0.rgb * (attenuation * angleDot);
|
||||
#endif // _DIFFUSE_RAMP
|
||||
|
||||
return lightDiffuse;
|
||||
}
|
||||
|
||||
inline float3 calculateNormalWorld(VertexOutput input)
|
||||
{
|
||||
#if defined(_NORMALMAP)
|
||||
return calculateNormalFromBumpMap(input.texcoord, input.tangentWorld, input.binormalWorld, input.normalWorld);
|
||||
#else
|
||||
return input.normalWorld;
|
||||
#endif
|
||||
}
|
||||
|
||||
fixed3 calculateVertexLighting(float3 posWorld, float3 normalWorld)
|
||||
{
|
||||
fixed3 vertexLighting = fixed3(0,0,0);
|
||||
|
||||
#ifdef VERTEXLIGHT_ON
|
||||
//Get approximated illumination from non-important point lights
|
||||
vertexLighting = Shade4PointLights ( unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0,
|
||||
unity_LightColor[0].rgb, unity_LightColor[1].rgb, unity_LightColor[2].rgb, unity_LightColor[3].rgb,
|
||||
unity_4LightAtten0, posWorld, normalWorld) * 0.5;
|
||||
#endif
|
||||
|
||||
return vertexLighting;
|
||||
}
|
||||
|
||||
fixed3 calculateAmbientLight(half3 normalWorld)
|
||||
{
|
||||
#if defined(_SPHERICAL_HARMONICS)
|
||||
fixed3 ambient = ShadeSH9(half4(normalWorld, 1.0));
|
||||
#else
|
||||
fixed3 ambient = unity_AmbientSky.rgb;
|
||||
#endif
|
||||
return ambient;
|
||||
}
|
||||
|
||||
#if defined(SPECULAR)
|
||||
|
||||
fixed4 calculateSpecularLight(SpecularCommonData s, float3 viewDir, float3 normal, float3 lightDir, float3 lightColor, half3 ambient)
|
||||
{
|
||||
SpecularLightData data = calculatePhysicsBasedSpecularLight (s.specColor, s.oneMinusReflectivity, s.smoothness, normal, viewDir, lightDir, lightColor, ambient, unity_IndirectSpecColor.rgb);
|
||||
fixed4 pixel = calculateLitPixel(fixed4(s.diffColor, s.alpha), data.lighting);
|
||||
pixel.rgb += data.specular * s.alpha;
|
||||
return pixel;
|
||||
}
|
||||
|
||||
fixed4 calculateSpecularLightAdditive(SpecularCommonData s, float3 viewDir, float3 normal, float3 lightDir, float3 lightColor)
|
||||
{
|
||||
SpecularLightData data = calculatePhysicsBasedSpecularLight (s.specColor, s.oneMinusReflectivity, s.smoothness, normal, viewDir, lightDir, lightColor, half3(0,0,0), half3(0,0,0));
|
||||
fixed4 pixel = calculateAdditiveLitPixel(fixed4(s.diffColor, s.alpha), data.lighting);
|
||||
pixel.rgb += data.specular * s.alpha;
|
||||
return pixel;
|
||||
}
|
||||
|
||||
#endif //SPECULAR
|
||||
|
||||
////////////////////////////////////////
|
||||
// Vertex program
|
||||
//
|
||||
|
||||
VertexOutput vert(VertexInput v)
|
||||
{
|
||||
VertexOutput output;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
output.pos = calculateLocalPos(v.vertex);
|
||||
output.color = calculateVertexColor(v.color);
|
||||
output.texcoord = calculateTextureCoord(v.texcoord);
|
||||
output.posWorld = calculateWorldPos(v.vertex);
|
||||
|
||||
float backFaceSign = 1;
|
||||
#if defined(FIXED_NORMALS_BACKFACE_RENDERING)
|
||||
backFaceSign = calculateBackfacingSign(output.posWorld.xyz);
|
||||
#endif
|
||||
|
||||
output.normalWorld = calculateSpriteWorldNormal(v, backFaceSign);
|
||||
output.vertexLighting = calculateVertexLighting(output.posWorld, output.normalWorld);
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
output.tangentWorld = calculateWorldTangent(v.tangent);
|
||||
output.binormalWorld = calculateSpriteWorldBinormal(v, output.normalWorld, output.tangentWorld, backFaceSign);
|
||||
#endif
|
||||
|
||||
TRANSFER_VERTEX_TO_FRAGMENT(output)
|
||||
|
||||
#if defined(_FOG)
|
||||
UNITY_TRANSFER_FOG(output,output.pos);
|
||||
#endif // _FOG
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
// Fragment programs
|
||||
//
|
||||
fixed4 fragBase(VertexOutput input) : SV_Target
|
||||
{
|
||||
fixed4 texureColor = calculateTexturePixel(input.texcoord);
|
||||
RETURN_UNLIT_IF_ADDITIVE_SLOT(texureColor, input.color) // shall be called before ALPHA_CLIP
|
||||
ALPHA_CLIP(texureColor, input.color)
|
||||
|
||||
//Get normal direction
|
||||
fixed3 normalWorld = calculateNormalWorld(input);
|
||||
|
||||
//Get Ambient diffuse
|
||||
fixed3 ambient = calculateAmbientLight(normalWorld);
|
||||
|
||||
|
||||
#if defined(SPECULAR)
|
||||
|
||||
//For directional lights _WorldSpaceLightPos0.w is set to zero
|
||||
float3 lightWorldDirection = normalize(_WorldSpaceLightPos0.xyz - input.posWorld.xyz * _WorldSpaceLightPos0.w);
|
||||
float attenuation = LIGHT_ATTENUATION(input);
|
||||
|
||||
//Returns pixel lit by light, texture color should inlcluded alpha
|
||||
half3 viewDir = normalize(_WorldSpaceCameraPos - input.posWorld.xyz);
|
||||
fixed4 pixel = calculateSpecularLight(getSpecularData(input.texcoord.xy, texureColor, input.color), viewDir, normalWorld, lightWorldDirection, _LightColor0.rgb * attenuation, ambient + input.vertexLighting);
|
||||
|
||||
APPLY_EMISSION_SPECULAR(pixel, input.texcoord)
|
||||
|
||||
#else
|
||||
|
||||
//Get primary pixel light diffuse
|
||||
fixed3 diffuse = calculateLightDiffuse(input, normalWorld, texureColor);
|
||||
|
||||
//Combine along with vertex lighting for the base lighting pass
|
||||
fixed3 lighting = ambient + diffuse + input.vertexLighting;
|
||||
|
||||
APPLY_EMISSION(lighting, input.texcoord)
|
||||
|
||||
fixed4 pixel = calculateLitPixel(texureColor, input.color, lighting);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_RIM_LIGHTING)
|
||||
pixel.rgb = applyRimLighting(input.posWorld, normalWorld, pixel);
|
||||
#endif
|
||||
|
||||
COLORISE(pixel)
|
||||
APPLY_FOG(pixel, input)
|
||||
|
||||
return pixel;
|
||||
}
|
||||
|
||||
fixed4 fragAdd(VertexOutput input) : SV_Target
|
||||
{
|
||||
fixed4 texureColor = calculateTexturePixel(input.texcoord);
|
||||
|
||||
#if defined(_COLOR_ADJUST)
|
||||
texureColor = adjustColor(texureColor);
|
||||
#endif // _COLOR_ADJUST
|
||||
|
||||
ALPHA_CLIP(texureColor, input.color)
|
||||
|
||||
//Get normal direction
|
||||
fixed3 normalWorld = calculateNormalWorld(input);
|
||||
|
||||
#if defined(SPECULAR)
|
||||
|
||||
//For directional lights _WorldSpaceLightPos0.w is set to zero
|
||||
float3 lightWorldDirection = normalize(_WorldSpaceLightPos0.xyz - input.posWorld.xyz * _WorldSpaceLightPos0.w);
|
||||
float attenuation = LIGHT_ATTENUATION(input);
|
||||
|
||||
half3 viewDir = normalize(_WorldSpaceCameraPos - input.posWorld.xyz);
|
||||
fixed4 pixel = calculateSpecularLightAdditive(getSpecularData(input.texcoord.xy, texureColor, input.color), viewDir, normalWorld, lightWorldDirection, _LightColor0.rgb * attenuation);
|
||||
|
||||
#else
|
||||
|
||||
//Get light diffuse
|
||||
fixed3 lighting = calculateLightDiffuse(input, normalWorld, texureColor);
|
||||
fixed4 pixel = calculateAdditiveLitPixel(texureColor, input.color, lighting);
|
||||
|
||||
#endif
|
||||
|
||||
COLORISE_ADDITIVE(pixel)
|
||||
APPLY_FOG_ADDITIVE(pixel, input)
|
||||
|
||||
return pixel;
|
||||
}
|
||||
|
||||
|
||||
#endif // SPRITE_PIXEL_LIGHTING_INCLUDED
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ffc57e05c42ec748838bea0a3aff9f9
|
||||
timeCreated: 1494092582
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,51 +0,0 @@
|
||||
#ifndef SPRITE_SHADOWS_INCLUDED
|
||||
#define SPRITE_SHADOWS_INCLUDED
|
||||
|
||||
#include "ShaderShared.cginc"
|
||||
|
||||
////////////////////////////////////////
|
||||
// Vertex structs
|
||||
//
|
||||
|
||||
struct vertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 texcoord : TEXCOORD0;
|
||||
};
|
||||
|
||||
struct vertexOutput
|
||||
{
|
||||
V2F_SHADOW_CASTER;
|
||||
float4 texcoordAndAlpha : TEXCOORD1;
|
||||
};
|
||||
|
||||
////////////////////////////////////////
|
||||
// Vertex program
|
||||
//
|
||||
|
||||
vertexOutput vert(vertexInput v, float4 vertexColor : COLOR)
|
||||
{
|
||||
vertexOutput o;
|
||||
TRANSFER_SHADOW_CASTER(o)
|
||||
o.texcoordAndAlpha.xy = calculateTextureCoord(v.texcoord);
|
||||
o.texcoordAndAlpha.z = 0;
|
||||
o.texcoordAndAlpha.a = vertexColor.a;
|
||||
return o;
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
// Fragment program
|
||||
//
|
||||
|
||||
|
||||
uniform fixed _ShadowAlphaCutoff;
|
||||
|
||||
fixed4 frag(vertexOutput IN) : SV_Target
|
||||
{
|
||||
fixed4 texureColor = calculateTexturePixel(IN.texcoordAndAlpha.xy);
|
||||
clip(texureColor.a * IN.texcoordAndAlpha.a - _ShadowAlphaCutoff);
|
||||
|
||||
SHADOW_CASTER_FRAGMENT(IN)
|
||||
}
|
||||
|
||||
#endif // SPRITE_SHADOWS_INCLUDED
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b7dbdfb1f55ee26459284220ad6d5bc4
|
||||
timeCreated: 1494092582
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,246 +0,0 @@
|
||||
#ifndef SPRITE_SPECULAR_INCLUDED
|
||||
#define SPRITE_SPECULAR_INCLUDED
|
||||
|
||||
#include "ShaderMaths.cginc"
|
||||
|
||||
////////////////////////////////////////
|
||||
// Specular functions
|
||||
//
|
||||
|
||||
#if defined(_SPECULAR) || defined(_SPECULAR_GLOSSMAP)
|
||||
|
||||
#define SPECULAR
|
||||
|
||||
|
||||
//ALL THESE FUNCTIONS ARE TAKEN AND ADAPTED FROM UNITY'S OWN PHYSICS BASED STANDARD SHADER
|
||||
|
||||
uniform float _Metallic;
|
||||
uniform float _Glossiness;
|
||||
uniform float _GlossMapScale;
|
||||
uniform sampler2D _MetallicGlossMap;
|
||||
|
||||
struct SpecularLightData
|
||||
{
|
||||
half3 lighting;
|
||||
half3 specular;
|
||||
};
|
||||
|
||||
struct SpecularCommonData
|
||||
{
|
||||
half3 diffColor, specColor;
|
||||
// Note: smoothness & oneMinusReflectivity for optimization purposes, mostly for DX9 SM2.0 level.
|
||||
// Most of the math is being done on these (1-x) values, and that saves a few precious ALU slots.
|
||||
half oneMinusReflectivity, smoothness;
|
||||
half alpha;
|
||||
};
|
||||
|
||||
inline half2 getMetallicGloss(float2 uv)
|
||||
{
|
||||
half2 mg;
|
||||
|
||||
#ifdef _SPECULAR_GLOSSMAP
|
||||
mg = tex2D(_MetallicGlossMap, uv).ra;
|
||||
mg.g *= _GlossMapScale;
|
||||
#else
|
||||
mg.r = _Metallic;
|
||||
mg.g = _Glossiness;
|
||||
#endif
|
||||
|
||||
return mg;
|
||||
}
|
||||
|
||||
inline half getOneMinusReflectivityFromMetallic(half metallic)
|
||||
{
|
||||
// We'll need oneMinusReflectivity, so
|
||||
// 1-reflectivity = 1-lerp(dielectricSpec, 1, metallic) = lerp(1-dielectricSpec, 0, metallic)
|
||||
// store (1-dielectricSpec) in unity_ColorSpaceDielectricSpec.a, then
|
||||
// 1-reflectivity = lerp(alpha, 0, metallic) = alpha + metallic*(0 - alpha) =
|
||||
// = alpha - metallic * alpha
|
||||
half oneMinusDielectricSpec = unity_ColorSpaceDielectricSpec.a;
|
||||
return oneMinusDielectricSpec - metallic * oneMinusDielectricSpec;
|
||||
}
|
||||
|
||||
inline SpecularCommonData getSpecularData(float2 uv, half4 texureColor, fixed4 color)
|
||||
{
|
||||
half2 metallicGloss = getMetallicGloss(uv);
|
||||
half metallic = metallicGloss.x;
|
||||
half smoothness = metallicGloss.y; // this is 1 minus the square root of real roughness m.
|
||||
|
||||
fixed4 albedo = calculatePixel(texureColor, color);
|
||||
|
||||
half3 specColor = lerp (unity_ColorSpaceDielectricSpec.rgb, albedo, metallic);
|
||||
half oneMinusReflectivity = getOneMinusReflectivityFromMetallic(metallic);
|
||||
half3 diffColor = albedo * oneMinusReflectivity;
|
||||
|
||||
SpecularCommonData o = (SpecularCommonData)0;
|
||||
o.diffColor = diffColor;
|
||||
o.specColor = specColor;
|
||||
o.oneMinusReflectivity = oneMinusReflectivity;
|
||||
o.smoothness = smoothness;
|
||||
|
||||
#if defined(_ALPHAPREMULTIPLY_ON) && (SHADER_TARGET >= 30)
|
||||
// Reflectivity 'removes' from the rest of components, including Transparency
|
||||
// outAlpha = 1-(1-alpha)*(1-reflectivity) = 1-(oneMinusReflectivity - alpha*oneMinusReflectivity) =
|
||||
// = 1-oneMinusReflectivity + alpha*oneMinusReflectivity
|
||||
//o.alpha = 1-oneMinusReflectivity + albedo.a*oneMinusReflectivity;
|
||||
o.alpha = albedo.a;
|
||||
#else
|
||||
o.alpha = albedo.a;
|
||||
#endif
|
||||
|
||||
return o;
|
||||
}
|
||||
inline half SmoothnessToPerceptualRoughness(half smoothness)
|
||||
{
|
||||
return (1 - smoothness);
|
||||
}
|
||||
|
||||
inline half PerceptualRoughnessToRoughness(half perceptualRoughness)
|
||||
{
|
||||
return perceptualRoughness * perceptualRoughness;
|
||||
}
|
||||
|
||||
// Ref: http://jcgt.org/published/0003/02/03/paper.pdf
|
||||
inline half SmithJointGGXVisibilityTerm (half NdotL, half NdotV, half roughness)
|
||||
{
|
||||
#if 0
|
||||
// Original formulation:
|
||||
// lambda_v = (-1 + sqrt(a2 * (1 - NdotL2) / NdotL2 + 1)) * 0.5f;
|
||||
// lambda_l = (-1 + sqrt(a2 * (1 - NdotV2) / NdotV2 + 1)) * 0.5f;
|
||||
// G = 1 / (1 + lambda_v + lambda_l);
|
||||
|
||||
// Reorder code to be more optimal
|
||||
half a = roughness;
|
||||
half a2 = a * a;
|
||||
|
||||
half lambdaV = NdotL * sqrt((-NdotV * a2 + NdotV) * NdotV + a2);
|
||||
half lambdaL = NdotV * sqrt((-NdotL * a2 + NdotL) * NdotL + a2);
|
||||
|
||||
// Simplify visibility term: (2.0f * NdotL * NdotV) / ((4.0f * NdotL * NdotV) * (lambda_v + lambda_l + 1e-5f));
|
||||
return 0.5f / (lambdaV + lambdaL + 1e-5f); // This function is not intended to be running on Mobile,
|
||||
// therefore epsilon is smaller than can be represented by half
|
||||
#else
|
||||
// Approximation of the above formulation (simplify the sqrt, not mathematically correct but close enough)
|
||||
half a = roughness;
|
||||
half lambdaV = NdotL * (NdotV * (1 - a) + a);
|
||||
half lambdaL = NdotV * (NdotL * (1 - a) + a);
|
||||
|
||||
return 0.5f / (lambdaV + lambdaL + 1e-5f);
|
||||
#endif
|
||||
}
|
||||
|
||||
inline half GGXTerm (half NdotH, half roughness)
|
||||
{
|
||||
half a2 = roughness * roughness;
|
||||
half d = (NdotH * a2 - NdotH) * NdotH + 1.0f; // 2 mad
|
||||
return UNITY_INV_PI * a2 / (d * d + 1e-7f); // This function is not intended to be running on Mobile,
|
||||
// therefore epsilon is smaller than what can be represented by half
|
||||
}
|
||||
|
||||
inline half3 FresnelTerm (half3 F0, half cosA)
|
||||
{
|
||||
half t = pow5 (1 - cosA); // ala Schlick interpoliation
|
||||
return F0 + (1-F0) * t;
|
||||
}
|
||||
|
||||
inline half3 FresnelLerp (half3 F0, half F90, half cosA)
|
||||
{
|
||||
half t = pow5 (1 - cosA); // ala Schlick interpoliation
|
||||
return lerp (F0, F90, t);
|
||||
}
|
||||
|
||||
// Note: Disney diffuse must be multiply by diffuseAlbedo / PI. This is done outside of this function.
|
||||
inline half DisneyDiffuse(half NdotV, half NdotL, half LdotH, half perceptualRoughness)
|
||||
{
|
||||
half fd90 = 0.5 + 2 * LdotH * LdotH * perceptualRoughness;
|
||||
// Two schlick fresnel term
|
||||
half lightScatter = (1 + (fd90 - 1) * pow5(1 - NdotL));
|
||||
half viewScatter = (1 + (fd90 - 1) * pow5(1 - NdotV));
|
||||
|
||||
return lightScatter * viewScatter;
|
||||
}
|
||||
|
||||
// Main Physically Based BRDF
|
||||
// Derived from Disney work and based on Torrance-Sparrow micro-facet model
|
||||
//
|
||||
// BRDF = kD / pi + kS * (D * V * F) / 4
|
||||
// I = BRDF * NdotL
|
||||
//
|
||||
// * NDF (depending on UNITY_BRDF_GGX):
|
||||
// a) Normalized BlinnPhong
|
||||
// b) GGX
|
||||
// * Smith for Visiblity term
|
||||
// * Schlick approximation for Fresnel
|
||||
SpecularLightData calculatePhysicsBasedSpecularLight(half3 specColor, half oneMinusReflectivity, half smoothness, half3 normal, half3 viewDir, half3 lightdir, half3 lightColor, half3 indirectDiffuse, half3 indirectSpecular)
|
||||
{
|
||||
half perceptualRoughness = SmoothnessToPerceptualRoughness (smoothness);
|
||||
half3 halfDir = safeNormalize (lightdir + viewDir);
|
||||
|
||||
// NdotV should not be negative for visible pixels, but it can happen due to perspective projection and normal mapping
|
||||
// In this case normal should be modified to become valid (i.e facing camera) and not cause weird artifacts.
|
||||
// but this operation adds few ALU and users may not want it. Alternative is to simply take the abs of NdotV (less correct but works too).
|
||||
// Following define allow to control this. Set it to 0 if ALU is critical on your platform.
|
||||
// This correction is interesting for GGX with SmithJoint visibility function because artifacts are more visible in this case due to highlight edge of rough surface
|
||||
// Edit: Disable this code by default for now as it is not compatible with two sided lighting used in SpeedTree.
|
||||
#define UNITY_HANDLE_CORRECTLY_NEGATIVE_NDOTV 0
|
||||
|
||||
#if UNITY_HANDLE_CORRECTLY_NEGATIVE_NDOTV
|
||||
// The amount we shift the normal toward the view vector is defined by the dot product.
|
||||
half shiftAmount = dot(normal, viewDir);
|
||||
normal = shiftAmount < 0.0f ? normal + viewDir * (-shiftAmount + 1e-5f) : normal;
|
||||
// A re-normalization should be applied here but as the shift is small we don't do it to save ALU.
|
||||
//normal = normalize(normal);
|
||||
|
||||
half nv = saturate(dot(normal, viewDir)); // TODO: this saturate should no be necessary here
|
||||
#else
|
||||
half nv = abs(dot(normal, viewDir)); // This abs allow to limit artifact
|
||||
#endif
|
||||
|
||||
half nl = saturate(dot(normal, lightdir));
|
||||
half nh = saturate(dot(normal, halfDir));
|
||||
|
||||
half lv = saturate(dot(lightdir, viewDir));
|
||||
half lh = saturate(dot(lightdir, halfDir));
|
||||
|
||||
// Diffuse term
|
||||
half diffuseTerm = DisneyDiffuse(nv, nl, lh, perceptualRoughness) * nl;
|
||||
|
||||
// Specular term
|
||||
// HACK: theoretically we should divide diffuseTerm by Pi and not multiply specularTerm!
|
||||
// BUT 1) that will make shader look significantly darker than Legacy ones
|
||||
// and 2) on engine side "Non-important" lights have to be divided by Pi too in cases when they are injected into ambient SH
|
||||
half roughness = PerceptualRoughnessToRoughness(perceptualRoughness);
|
||||
half V = SmithJointGGXVisibilityTerm (nl, nv, roughness);
|
||||
half D = GGXTerm (nh, roughness);
|
||||
|
||||
half specularTerm = V*D * UNITY_PI; // Torrance-Sparrow model, Fresnel is applied later
|
||||
|
||||
# ifdef UNITY_COLORSPACE_GAMMA
|
||||
specularTerm = sqrt(max(1e-4h, specularTerm));
|
||||
# endif
|
||||
|
||||
// specularTerm * nl can be NaN on Metal in some cases, use max() to make sure it's a sane value
|
||||
specularTerm = max(0, specularTerm * nl);
|
||||
|
||||
// surfaceReduction = Int D(NdotH) * NdotH * Id(NdotL>0) dH = 1/(roughness^2+1)
|
||||
half surfaceReduction;
|
||||
# ifdef UNITY_COLORSPACE_GAMMA
|
||||
surfaceReduction = 1.0 - 0.28f * roughness * perceptualRoughness; // 1-0.28*x^3 as approximation for (1/(x^4+1))^(1/2.2) on the domain [0;1]
|
||||
# else
|
||||
surfaceReduction = 1.0 / (roughness*roughness + 1.0); // fade \in [0.5;1]
|
||||
# endif
|
||||
|
||||
// To provide true Lambert lighting, we need to be able to kill specular completely.
|
||||
specularTerm *= any(specColor) ? 1.0 : 0.0;
|
||||
|
||||
half grazingTerm = saturate(smoothness + (1-oneMinusReflectivity));
|
||||
|
||||
SpecularLightData outData = (SpecularLightData)0;
|
||||
outData.lighting = indirectDiffuse + lightColor * diffuseTerm;
|
||||
outData.specular = (specularTerm * lightColor * FresnelTerm (specColor, lh)) + (surfaceReduction * indirectSpecular * FresnelLerp (specColor, grazingTerm, nv));
|
||||
return outData;
|
||||
}
|
||||
|
||||
#endif // _SPECULAR && _SPECULAR_GLOSSMAP
|
||||
|
||||
#endif // SPRITE_SPECULAR_INCLUDED
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f195336fc94457241a37a0aa85923681
|
||||
timeCreated: 1494092582
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,68 +0,0 @@
|
||||
#ifndef SPRITE_UNLIT_INCLUDED
|
||||
#define SPRITE_UNLIT_INCLUDED
|
||||
|
||||
#include "ShaderShared.cginc"
|
||||
|
||||
////////////////////////////////////////
|
||||
// Vertex structs
|
||||
//
|
||||
|
||||
struct VertexInput
|
||||
{
|
||||
float4 vertex : POSITION;
|
||||
float4 texcoord : TEXCOORD0;
|
||||
fixed4 color : COLOR;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
float2 texcoord : TEXCOORD0;
|
||||
fixed4 color : COLOR;
|
||||
#if defined(_FOG)
|
||||
UNITY_FOG_COORDS(1)
|
||||
#endif // _FOG
|
||||
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
////////////////////////////////////////
|
||||
// Vertex program
|
||||
//
|
||||
|
||||
VertexOutput vert(VertexInput input)
|
||||
{
|
||||
VertexOutput output;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
output.pos = calculateLocalPos(input.vertex);
|
||||
output.texcoord = calculateTextureCoord(input.texcoord);
|
||||
output.color = calculateVertexColor(input.color);
|
||||
|
||||
#if defined(_FOG)
|
||||
UNITY_TRANSFER_FOG(output,output.pos);
|
||||
#endif // _FOG
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
// Fragment program
|
||||
//
|
||||
fixed4 frag(VertexOutput input) : SV_Target
|
||||
{
|
||||
fixed4 texureColor = calculateTexturePixel(input.texcoord.xy);
|
||||
RETURN_UNLIT_IF_ADDITIVE_SLOT(texureColor, input.color) // shall be called before ALPHA_CLIP
|
||||
ALPHA_CLIP(texureColor, input.color)
|
||||
fixed4 pixel = calculatePixel(texureColor, input.color);
|
||||
|
||||
COLORISE(pixel)
|
||||
APPLY_FOG(pixel, input)
|
||||
|
||||
return pixel;
|
||||
}
|
||||
|
||||
#endif // SPRITE_UNLIT_INCLUDED
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 072e7b07ec7fb1346a9dcd3bcbbb7111
|
||||
timeCreated: 1494092582
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,473 +0,0 @@
|
||||
#ifndef SPRITE_VERTEX_LIGHTING_INCLUDED
|
||||
#define SPRITE_VERTEX_LIGHTING_INCLUDED
|
||||
|
||||
#include "ShaderShared.cginc"
|
||||
#include "SpriteLighting.cginc"
|
||||
#include "SpriteSpecular.cginc"
|
||||
|
||||
////////////////////////////////////////
|
||||
// Defines
|
||||
//
|
||||
|
||||
//Define to use spot lights (more expensive)
|
||||
#define SPOT_LIGHTS
|
||||
|
||||
//Have to process lighting per pixel if using normal maps or a diffuse ramp or rim lighting or specular
|
||||
#if defined(_NORMALMAP) || defined(_DIFFUSE_RAMP) || defined(_RIM_LIGHTING) || defined(SPECULAR)
|
||||
#define PER_PIXEL_LIGHTING
|
||||
#endif
|
||||
|
||||
//Turn off bump mapping and diffuse ramping on older shader models as they dont support needed number of outputs
|
||||
#if defined(PER_PIXEL_LIGHTING) && (SHADER_TARGET < 30)
|
||||
#undef PER_PIXEL_LIGHTING
|
||||
#undef _NORMALMAP
|
||||
#undef _DIFFUSE_RAMP
|
||||
#undef _RIM_LIGHTING
|
||||
#endif
|
||||
|
||||
//In D3D9 only have a max of 9 TEXCOORD so can't have diffuse ramping or fog or rim lighting if processing lights per pixel
|
||||
#if defined(SHADER_API_D3D9) && defined(PER_PIXEL_LIGHTING)
|
||||
#if defined(_NORMALMAP)
|
||||
#undef _DIFFUSE_RAMP
|
||||
#undef _FOG
|
||||
#undef _RIM_LIGHTING
|
||||
#elif defined(_DIFFUSE_RAMP)
|
||||
#undef _FOG
|
||||
#undef _RIM_LIGHTING
|
||||
#elif defined(_RIM_LIGHTING)
|
||||
#undef _FOG
|
||||
#undef _DIFFUSE_RAMP
|
||||
#else
|
||||
#undef _DIFFUSE_RAMP
|
||||
#undef _RIM_LIGHTING
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(PER_PIXEL_LIGHTING)
|
||||
#if defined(_NORMALMAP) && defined(_DIFFUSE_RAMP)
|
||||
#define ATTENUATIONS TEXCOORD9
|
||||
#if defined(_RIM_LIGHTING)
|
||||
#define _POS_WORLD_INDEX TEXCOORD10
|
||||
#define _FOG_COORD_INDEX 11
|
||||
#else
|
||||
#define _FOG_COORD_INDEX 10
|
||||
#endif
|
||||
#elif defined(_NORMALMAP) != defined(_DIFFUSE_RAMP)
|
||||
#define ATTENUATIONS TEXCOORD8
|
||||
#if defined(_RIM_LIGHTING)
|
||||
#define _POS_WORLD_INDEX TEXCOORD9
|
||||
#define _FOG_COORD_INDEX 10
|
||||
#else
|
||||
#define _FOG_COORD_INDEX 9
|
||||
#endif
|
||||
#else //!_DIFFUSE_RAMP && !_NORMALMAP
|
||||
#if defined(_RIM_LIGHTING)
|
||||
#define _POS_WORLD_INDEX TEXCOORD8
|
||||
#define _FOG_COORD_INDEX 9
|
||||
#else
|
||||
#define _FOG_COORD_INDEX 8
|
||||
#endif
|
||||
#endif
|
||||
#else //!PER_PIXEL_LIGHTING
|
||||
#define _FOG_COORD_INDEX 2
|
||||
#endif
|
||||
|
||||
////////////////////////////////////////
|
||||
// Vertex output struct
|
||||
//
|
||||
|
||||
struct VertexOutput
|
||||
{
|
||||
float4 pos : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float3 texcoord : TEXCOORD0;
|
||||
|
||||
#if defined(PER_PIXEL_LIGHTING)
|
||||
|
||||
half4 VertexLightInfo0 : TEXCOORD1;
|
||||
half4 VertexLightInfo1 : TEXCOORD2;
|
||||
half4 VertexLightInfo2 : TEXCOORD3;
|
||||
half4 VertexLightInfo3 : TEXCOORD4;
|
||||
half4 VertexLightInfo4 : TEXCOORD5;
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
half4 normalWorld : TEXCOORD6;
|
||||
half4 tangentWorld : TEXCOORD7;
|
||||
half4 binormalWorld : TEXCOORD8;
|
||||
#else
|
||||
half3 normalWorld : TEXCOORD6;
|
||||
half3 VertexLightInfo5 : TEXCOORD7;
|
||||
#endif
|
||||
#if defined(_DIFFUSE_RAMP)
|
||||
half4 LightAttenuations : ATTENUATIONS;
|
||||
#endif
|
||||
#if defined(_RIM_LIGHTING)
|
||||
float4 posWorld : _POS_WORLD_INDEX;
|
||||
#endif
|
||||
|
||||
#else //!PER_PIXEL_LIGHTING
|
||||
|
||||
half3 FullLighting : TEXCOORD1;
|
||||
|
||||
#endif // !PER_PIXEL_LIGHTING
|
||||
|
||||
#if defined(_FOG)
|
||||
UNITY_FOG_COORDS(_FOG_COORD_INDEX)
|
||||
#endif // _FOG
|
||||
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
////////////////////////////////////////
|
||||
// Light calculations
|
||||
//
|
||||
|
||||
struct VertexLightInfo
|
||||
{
|
||||
half3 lightDirection;
|
||||
fixed3 lightColor;
|
||||
|
||||
#if defined(_DIFFUSE_RAMP)
|
||||
float attenuation;
|
||||
#endif // _DIFFUSE_RAMP
|
||||
};
|
||||
|
||||
inline VertexLightInfo getVertexLightAttenuatedInfo(int index, float3 viewPos)
|
||||
{
|
||||
VertexLightInfo lightInfo;
|
||||
|
||||
//For directional lights unity_LightPosition.w is set to zero
|
||||
lightInfo.lightDirection = unity_LightPosition[index].xyz - viewPos.xyz * unity_LightPosition[index].w;
|
||||
float lengthSq = dot(lightInfo.lightDirection, lightInfo.lightDirection);
|
||||
|
||||
// don't produce NaNs if some vertex position overlaps with the light
|
||||
lengthSq = max(lengthSq, 0.000001);
|
||||
|
||||
lightInfo.lightDirection *= rsqrt(lengthSq);
|
||||
|
||||
float attenuation = 1.0 / (1.0 + lengthSq * unity_LightAtten[index].z);
|
||||
|
||||
#if defined(SPOT_LIGHTS)
|
||||
//Spot light attenuation - for non-spot lights unity_LightAtten.x is set to -1 and y is set to 1
|
||||
{
|
||||
float rho = max (0, dot(lightInfo.lightDirection, unity_SpotDirection[index].xyz));
|
||||
float spotAtt = (rho - unity_LightAtten[index].x) * unity_LightAtten[index].y;
|
||||
attenuation *= saturate(spotAtt);
|
||||
}
|
||||
#endif // SPOT_LIGHTS
|
||||
|
||||
//If using a diffuse ramp texture then need to pass through the lights attenuation, otherwise premultiply the light color with it
|
||||
#if defined(_DIFFUSE_RAMP)
|
||||
lightInfo.lightColor = unity_LightColor[index].rgb;
|
||||
lightInfo.attenuation = attenuation;
|
||||
#else
|
||||
lightInfo.lightColor = unity_LightColor[index].rgb * attenuation;
|
||||
#endif // _DIFFUSE_RAMP
|
||||
|
||||
return lightInfo;
|
||||
}
|
||||
|
||||
//Magic constants used to tweak ambient to approximate pixel shader spherical harmonics
|
||||
static const fixed3 worldUp = fixed3(0, 1, 0);
|
||||
static const float skyGroundDotMul = 2.5;
|
||||
static const float minEquatorMix = 0.5;
|
||||
static const float equatorColorBlur = 0.33;
|
||||
|
||||
fixed3 calculateAmbientLight(half3 normalWorld)
|
||||
{
|
||||
#if defined(_SPHERICAL_HARMONICS)
|
||||
float upDot = dot(normalWorld, worldUp);
|
||||
|
||||
//Fade between a flat lerp from sky to ground and a 3 way lerp based on how bright the equator light is.
|
||||
//This simulates how directional lights get blurred using spherical harmonics
|
||||
|
||||
//Work out color from ground and sky, ignoring equator
|
||||
float adjustedDot = upDot * skyGroundDotMul;
|
||||
fixed3 skyGroundColor = lerp(unity_AmbientGround, unity_AmbientSky, saturate((adjustedDot + 1.0) * 0.5));
|
||||
|
||||
//Work out equator lights brightness
|
||||
float equatorBright = saturate(dot(unity_AmbientEquator.rgb, unity_AmbientEquator.rgb));
|
||||
|
||||
//Blur equator color with sky and ground colors based on how bright it is.
|
||||
fixed3 equatorBlurredColor = lerp(unity_AmbientEquator, saturate(unity_AmbientEquator + unity_AmbientGround + unity_AmbientSky), equatorBright * equatorColorBlur);
|
||||
|
||||
//Work out 3 way lerp inc equator light
|
||||
fixed3 equatorColor = lerp(equatorBlurredColor, unity_AmbientGround, -upDot) * step(upDot, 0) + lerp(equatorBlurredColor, unity_AmbientSky, upDot) * step(0, upDot);
|
||||
|
||||
//Mix the two colors together based on how bright the equator light is
|
||||
return lerp(skyGroundColor, equatorColor, saturate(equatorBright + minEquatorMix));
|
||||
|
||||
#else // !_SPHERICAL_HARMONICS
|
||||
|
||||
//Flat ambient is just the sky color
|
||||
return unity_AmbientSky.rgb;
|
||||
|
||||
#endif // !_SPHERICAL_HARMONICS
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
// Light Packing Functions
|
||||
//
|
||||
|
||||
#if defined(_DIFFUSE_RAMP)
|
||||
|
||||
inline fixed3 calculateLightDiffuse(fixed3 lightColor, half3 viewNormal, half3 lightViewDir, float attenuation)
|
||||
{
|
||||
float angleDot = max(0, dot(viewNormal, lightViewDir));
|
||||
fixed3 lightDiffuse = calculateRampedDiffuse(lightColor, attenuation, angleDot);
|
||||
return lightDiffuse;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
inline fixed3 calculateLightDiffuse(fixed3 attenuatedLightColor, half3 viewNormal, half3 lightViewDir)
|
||||
{
|
||||
float angleDot = max(0, dot(viewNormal, lightViewDir));
|
||||
fixed3 lightDiffuse = attenuatedLightColor * angleDot;
|
||||
|
||||
return lightDiffuse;
|
||||
}
|
||||
|
||||
#endif // _NORMALMAP
|
||||
|
||||
|
||||
#if defined(PER_PIXEL_LIGHTING)
|
||||
|
||||
#define VERTEX_LIGHT_0_DIR VertexLightInfo0.xyz
|
||||
#define VERTEX_LIGHT_0_R VertexLightInfo4.x
|
||||
#define VERTEX_LIGHT_0_G VertexLightInfo4.y
|
||||
#define VERTEX_LIGHT_0_B VertexLightInfo4.z
|
||||
|
||||
#define VERTEX_LIGHT_1_DIR VertexLightInfo1.xyz
|
||||
#define VERTEX_LIGHT_1_R VertexLightInfo0.w
|
||||
#define VERTEX_LIGHT_1_G VertexLightInfo1.w
|
||||
#define VERTEX_LIGHT_1_B VertexLightInfo2.w
|
||||
|
||||
#define VERTEX_LIGHT_2_DIR VertexLightInfo2.xyz
|
||||
#define VERTEX_LIGHT_2_R VertexLightInfo3.w
|
||||
#define VERTEX_LIGHT_2_G VertexLightInfo4.w
|
||||
#define VERTEX_LIGHT_2_B texcoord.z
|
||||
|
||||
#define VERTEX_LIGHT_3_DIR VertexLightInfo3.xyz
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
#define VERTEX_LIGHT_3_R normalWorld.w
|
||||
#define VERTEX_LIGHT_3_G tangentWorld.w
|
||||
#define VERTEX_LIGHT_3_B binormalWorld.w
|
||||
#else
|
||||
#define VERTEX_LIGHT_3_R VertexLightInfo5.x
|
||||
#define VERTEX_LIGHT_3_G VertexLightInfo5.y
|
||||
#define VERTEX_LIGHT_3_B VertexLightInfo5.z
|
||||
#endif
|
||||
|
||||
#if defined(_DIFFUSE_RAMP)
|
||||
|
||||
#define LIGHT_DIFFUSE_ATTEN_0 LightAttenuations.x
|
||||
#define LIGHT_DIFFUSE_ATTEN_1 LightAttenuations.y
|
||||
#define LIGHT_DIFFUSE_ATTEN_2 LightAttenuations.z
|
||||
#define LIGHT_DIFFUSE_ATTEN_3 LightAttenuations.w
|
||||
|
||||
#define PACK_VERTEX_LIGHT_DIFFUSE(index, output, lightInfo) \
|
||||
{ \
|
||||
output.LIGHT_DIFFUSE_ATTEN_##index = lightInfo.attenuation; \
|
||||
}
|
||||
|
||||
#define ADD_VERTEX_LIGHT_DIFFUSE(index, diffuse, input, lightColor, viewNormal, lightViewDir) \
|
||||
{ \
|
||||
diffuse += calculateLightDiffuse(lightColor, viewNormal, lightViewDir, input.LIGHT_DIFFUSE_ATTEN_##index); \
|
||||
}
|
||||
#else
|
||||
#define PACK_VERTEX_LIGHT_DIFFUSE(index, output, lightInfo)
|
||||
#define ADD_VERTEX_LIGHT_DIFFUSE(index, diffuse, input, lightColor, viewNormal, lightViewDir) \
|
||||
{ \
|
||||
diffuse += calculateLightDiffuse(lightColor, viewNormal, lightViewDir); \
|
||||
}
|
||||
#endif
|
||||
|
||||
#define PACK_VERTEX_LIGHT(index, output, viewPos) \
|
||||
{ \
|
||||
VertexLightInfo lightInfo = getVertexLightAttenuatedInfo(index, viewPos); \
|
||||
output.VERTEX_LIGHT_##index##_DIR = lightInfo.lightDirection; \
|
||||
output.VERTEX_LIGHT_##index##_R = lightInfo.lightColor.r; \
|
||||
output.VERTEX_LIGHT_##index##_G = lightInfo.lightColor.g; \
|
||||
output.VERTEX_LIGHT_##index##_B = lightInfo.lightColor.b; \
|
||||
PACK_VERTEX_LIGHT_DIFFUSE(index, output, lightInfo); \
|
||||
}
|
||||
|
||||
#define ADD_VERTEX_LIGHT(index, input, viewNormal, diffuse) \
|
||||
{ \
|
||||
half3 lightViewDir = input.VERTEX_LIGHT_##index##_DIR; \
|
||||
fixed3 lightColor = fixed3(input.VERTEX_LIGHT_##index##_R, input.VERTEX_LIGHT_##index##_G, input.VERTEX_LIGHT_##index##_B); \
|
||||
ADD_VERTEX_LIGHT_DIFFUSE(index, diffuse, input, lightColor, viewNormal, lightViewDir) \
|
||||
}
|
||||
|
||||
#if defined(SPECULAR)
|
||||
|
||||
#define ADD_VERTEX_LIGHT_SPEC(index, input, viewNormal, specData, combinedLightData, indirectDiffuse, indirectSpecular) \
|
||||
{ \
|
||||
half3 lightViewDir = input.VERTEX_LIGHT_##index##_DIR; \
|
||||
fixed3 lightColor = fixed3(input.VERTEX_LIGHT_##index##_R, input.VERTEX_LIGHT_##index##_G, input.VERTEX_LIGHT_##index##_B); \
|
||||
SpecularLightData lightData = calculatePhysicsBasedSpecularLight(specData.specColor, specData.oneMinusReflectivity, specData.smoothness, viewNormal, fixed3(0,0,1), lightViewDir, lightColor, indirectDiffuse, indirectSpecular); \
|
||||
combinedLightData.lighting += lightData.lighting; \
|
||||
combinedLightData.specular += lightData.specular; \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#else //!PER_PIXEL_LIGHTING
|
||||
|
||||
////////////////////////////////////////
|
||||
// Vertex Only Functions
|
||||
//
|
||||
|
||||
inline fixed3 calculateLightDiffuse(int index, float3 viewPos, half3 viewNormal)
|
||||
{
|
||||
VertexLightInfo lightInfo = getVertexLightAttenuatedInfo(index, viewPos);
|
||||
float angleDot = max(0, dot(viewNormal, lightInfo.lightDirection));
|
||||
return lightInfo.lightColor * angleDot;
|
||||
}
|
||||
|
||||
#endif // !PER_PIXEL_LIGHTING
|
||||
|
||||
////////////////////////////////////////
|
||||
// Vertex program
|
||||
//
|
||||
|
||||
VertexOutput vert(VertexInput input)
|
||||
{
|
||||
VertexOutput output;
|
||||
|
||||
UNITY_SETUP_INSTANCE_ID(input);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(output);
|
||||
|
||||
output.pos = calculateLocalPos(input.vertex);
|
||||
output.color = calculateVertexColor(input.color);
|
||||
output.texcoord = float3(calculateTextureCoord(input.texcoord), 0);
|
||||
|
||||
float3 viewPos = UnityObjectToViewPos(input.vertex); //float3 viewPos = mul(UNITY_MATRIX_MV, input.vertex); //
|
||||
#if defined(FIXED_NORMALS_BACKFACE_RENDERING) || defined(_RIM_LIGHTING)
|
||||
float4 powWorld = calculateWorldPos(input.vertex);
|
||||
#endif
|
||||
|
||||
float backFaceSign = 1;
|
||||
#if defined(FIXED_NORMALS_BACKFACE_RENDERING)
|
||||
backFaceSign = calculateBackfacingSign(powWorld.xyz);
|
||||
#endif
|
||||
|
||||
#if defined(PER_PIXEL_LIGHTING)
|
||||
|
||||
#if defined(_RIM_LIGHTING)
|
||||
output.posWorld = powWorld;
|
||||
#endif
|
||||
|
||||
PACK_VERTEX_LIGHT(0, output, viewPos)
|
||||
PACK_VERTEX_LIGHT(1, output, viewPos)
|
||||
PACK_VERTEX_LIGHT(2, output, viewPos)
|
||||
PACK_VERTEX_LIGHT(3, output, viewPos)
|
||||
|
||||
output.normalWorld.xyz = calculateSpriteWorldNormal(input, backFaceSign);
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
output.tangentWorld.xyz = calculateWorldTangent(input.tangent);
|
||||
output.binormalWorld.xyz = calculateSpriteWorldBinormal(input, output.normalWorld, output.tangentWorld, backFaceSign);
|
||||
#endif
|
||||
|
||||
#else // !PER_PIXEL_LIGHTING
|
||||
|
||||
//Just pack full lighting
|
||||
float3 viewNormal = calculateSpriteViewNormal(input, backFaceSign);
|
||||
//Get Ambient diffuse
|
||||
float3 normalWorld = calculateSpriteWorldNormal(input, backFaceSign);
|
||||
fixed3 ambient = calculateAmbientLight(normalWorld);
|
||||
|
||||
fixed3 diffuse = calculateLightDiffuse(0, viewPos, viewNormal);
|
||||
diffuse += calculateLightDiffuse(1, viewPos, viewNormal);
|
||||
diffuse += calculateLightDiffuse(2, viewPos, viewNormal);
|
||||
diffuse += calculateLightDiffuse(3, viewPos, viewNormal);
|
||||
|
||||
output.FullLighting = ambient + diffuse;
|
||||
|
||||
#endif // !PER_PIXEL_LIGHTING
|
||||
|
||||
#if defined(_FOG)
|
||||
UNITY_TRANSFER_FOG(output, output.pos);
|
||||
#endif // _FOG
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
////////////////////////////////////////
|
||||
// Fragment program
|
||||
//
|
||||
fixed4 frag(VertexOutput input) : SV_Target
|
||||
{
|
||||
fixed4 texureColor = calculateTexturePixel(input.texcoord.xy);
|
||||
RETURN_UNLIT_IF_ADDITIVE_SLOT(texureColor, input.color) // shall be called before ALPHA_CLIP
|
||||
ALPHA_CLIP(texureColor, input.color)
|
||||
|
||||
#if defined(PER_PIXEL_LIGHTING)
|
||||
|
||||
#if defined(_NORMALMAP)
|
||||
half3 normalWorld = calculateNormalFromBumpMap(input.texcoord.xy, input.tangentWorld.xyz, input.binormalWorld.xyz, input.normalWorld.xyz);
|
||||
#else
|
||||
half3 normalWorld = input.normalWorld.xyz;
|
||||
#endif
|
||||
|
||||
//Get Ambient diffuse
|
||||
fixed3 ambient = calculateAmbientLight(normalWorld);
|
||||
|
||||
half3 normalView = normalize(mul((float3x3)UNITY_MATRIX_V, normalWorld));
|
||||
|
||||
#if defined(SPECULAR)
|
||||
|
||||
SpecularCommonData specData = getSpecularData(input.texcoord.xy, texureColor, input.color);
|
||||
|
||||
SpecularLightData combinedLightData = (SpecularLightData)0;
|
||||
ADD_VERTEX_LIGHT_SPEC(0, input, normalView, specData, combinedLightData, ambient, unity_IndirectSpecColor.rgb)
|
||||
ADD_VERTEX_LIGHT_SPEC(1, input, normalView, specData, combinedLightData, fixed3(0,0,0), fixed3(0,0,0))
|
||||
ADD_VERTEX_LIGHT_SPEC(2, input, normalView, specData, combinedLightData, fixed3(0,0,0), fixed3(0,0,0))
|
||||
ADD_VERTEX_LIGHT_SPEC(3, input, normalView, specData, combinedLightData, fixed3(0,0,0), fixed3(0,0,0))
|
||||
|
||||
fixed4 pixel = calculateLitPixel(fixed4(specData.diffColor, specData.alpha), combinedLightData.lighting);
|
||||
pixel.rgb += combinedLightData.specular * specData.alpha;
|
||||
|
||||
APPLY_EMISSION_SPECULAR(pixel, input.texcoord)
|
||||
|
||||
#else
|
||||
|
||||
//Find vertex light diffuse
|
||||
fixed3 diffuse = fixed3(0,0,0);
|
||||
|
||||
//Add each vertex light to diffuse
|
||||
ADD_VERTEX_LIGHT(0, input, normalView, diffuse)
|
||||
ADD_VERTEX_LIGHT(1, input, normalView, diffuse)
|
||||
ADD_VERTEX_LIGHT(2, input, normalView, diffuse)
|
||||
ADD_VERTEX_LIGHT(3, input, normalView, diffuse)
|
||||
|
||||
fixed3 lighting = ambient + diffuse;
|
||||
|
||||
APPLY_EMISSION(lighting, input.texcoord.xy)
|
||||
|
||||
fixed4 pixel = calculateLitPixel(texureColor, input.color, lighting);
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(_RIM_LIGHTING)
|
||||
pixel.rgb = applyRimLighting(input.posWorld, normalWorld, pixel);
|
||||
#endif
|
||||
|
||||
#else // !PER_PIXEL_LIGHTING
|
||||
|
||||
APPLY_EMISSION(input.FullLighting, input.texcoord.xy)
|
||||
|
||||
fixed4 pixel = calculateLitPixel(texureColor, input.color, input.FullLighting);
|
||||
|
||||
#endif // !PER_PIXEL_LIGHTING
|
||||
|
||||
COLORISE(pixel)
|
||||
APPLY_FOG(pixel, input)
|
||||
|
||||
return pixel;
|
||||
}
|
||||
|
||||
#endif // SPRITE_VERTEX_LIGHTING_INCLUDED
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c739dcf9dbcab944898d0b796e11afb9
|
||||
timeCreated: 1494092582
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,446 +0,0 @@
|
||||
Shader "Hidden/Internal-SpriteDepthNormalsTexture" {
|
||||
|
||||
// Use this shader to render a DepthNormals texture for a camera with correct sprite normals (using camera.RenderWithShader)
|
||||
|
||||
Properties {
|
||||
_MainTex ("", 2D) = "white" {}
|
||||
_Cutoff ("", Float) = 0.5
|
||||
_Color ("", Color) = (1,1,1,1)
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "RenderType"="Sprite" }
|
||||
Pass {
|
||||
Cull Off
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
|
||||
struct v2f {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 nz : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
uniform float4 _MainTex_ST;
|
||||
uniform float4 _FixedNormal;
|
||||
v2f vert( appdata_base v ) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.nz.xyz = _FixedNormal.xyz;
|
||||
#if UNITY_REVERSED_Z
|
||||
o.nz.z = -o.nz.z;
|
||||
#endif
|
||||
o.nz.w = COMPUTE_DEPTH_01;
|
||||
return o;
|
||||
}
|
||||
uniform sampler2D _MainTex;
|
||||
uniform fixed _Cutoff;
|
||||
uniform fixed4 _Color;
|
||||
fixed4 frag(v2f i) : SV_Target {
|
||||
fixed4 texcol = tex2D( _MainTex, i.uv );
|
||||
clip( texcol.a*_Color.a - _Cutoff );
|
||||
return EncodeDepthNormal (i.nz.w, i.nz.xyz);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "RenderType"="Opaque" }
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
struct v2f {
|
||||
float4 pos : SV_POSITION;
|
||||
float4 nz : TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
v2f vert( appdata_base v ) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.nz.xyz = COMPUTE_VIEW_NORMAL;
|
||||
o.nz.w = COMPUTE_DEPTH_01;
|
||||
return o;
|
||||
}
|
||||
fixed4 frag(v2f i) : SV_Target {
|
||||
return EncodeDepthNormal (i.nz.w, i.nz.xyz);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "RenderType"="TransparentCutout" }
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
struct v2f {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 nz : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
uniform float4 _MainTex_ST;
|
||||
v2f vert( appdata_base v ) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
|
||||
o.nz.xyz = COMPUTE_VIEW_NORMAL;
|
||||
o.nz.w = COMPUTE_DEPTH_01;
|
||||
return o;
|
||||
}
|
||||
uniform sampler2D _MainTex;
|
||||
uniform fixed _Cutoff;
|
||||
uniform fixed4 _Color;
|
||||
fixed4 frag(v2f i) : SV_Target {
|
||||
fixed4 texcol = tex2D( _MainTex, i.uv );
|
||||
clip( texcol.a*_Color.a - _Cutoff );
|
||||
return EncodeDepthNormal (i.nz.w, i.nz.xyz);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "RenderType"="TreeBark" }
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "UnityBuiltin3xTreeLibrary.cginc"
|
||||
struct v2f {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 nz : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
v2f vert( appdata_full v ) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
TreeVertBark(v);
|
||||
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
o.nz.xyz = COMPUTE_VIEW_NORMAL;
|
||||
o.nz.w = COMPUTE_DEPTH_01;
|
||||
return o;
|
||||
}
|
||||
fixed4 frag( v2f i ) : SV_Target {
|
||||
return EncodeDepthNormal (i.nz.w, i.nz.xyz);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "RenderType"="TreeLeaf" }
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#include "Lighting.cginc"
|
||||
#include "UnityBuiltin3xTreeLibrary.cginc"
|
||||
struct v2f {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 nz : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
v2f vert( appdata_full v ) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
TreeVertLeaf(v);
|
||||
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
o.nz.xyz = COMPUTE_VIEW_NORMAL;
|
||||
o.nz.w = COMPUTE_DEPTH_01;
|
||||
return o;
|
||||
}
|
||||
uniform sampler2D _MainTex;
|
||||
uniform fixed _Cutoff;
|
||||
fixed4 frag( v2f i ) : SV_Target {
|
||||
half alpha = tex2D(_MainTex, i.uv).a;
|
||||
|
||||
clip (alpha - _Cutoff);
|
||||
return EncodeDepthNormal (i.nz.w, i.nz.xyz);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "RenderType"="TreeOpaque" "DisableBatching"="True" }
|
||||
Pass {
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#include "TerrainEngine.cginc"
|
||||
struct v2f {
|
||||
float4 pos : SV_POSITION;
|
||||
float4 nz : TEXCOORD0;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
fixed4 color : COLOR;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
v2f vert( appdata v ) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
TerrainAnimateTree(v.vertex, v.color.w);
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.nz.xyz = COMPUTE_VIEW_NORMAL;
|
||||
o.nz.w = COMPUTE_DEPTH_01;
|
||||
return o;
|
||||
}
|
||||
fixed4 frag(v2f i) : SV_Target {
|
||||
return EncodeDepthNormal (i.nz.w, i.nz.xyz);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "RenderType"="TreeTransparentCutout" "DisableBatching"="True" }
|
||||
Pass {
|
||||
Cull Back
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#include "TerrainEngine.cginc"
|
||||
|
||||
struct v2f {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 nz : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
fixed4 color : COLOR;
|
||||
float4 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
v2f vert( appdata v ) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
TerrainAnimateTree(v.vertex, v.color.w);
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
o.nz.xyz = COMPUTE_VIEW_NORMAL;
|
||||
o.nz.w = COMPUTE_DEPTH_01;
|
||||
return o;
|
||||
}
|
||||
uniform sampler2D _MainTex;
|
||||
uniform fixed _Cutoff;
|
||||
fixed4 frag(v2f i) : SV_Target {
|
||||
half alpha = tex2D(_MainTex, i.uv).a;
|
||||
|
||||
clip (alpha - _Cutoff);
|
||||
return EncodeDepthNormal (i.nz.w, i.nz.xyz);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
Pass {
|
||||
Cull Front
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#include "TerrainEngine.cginc"
|
||||
|
||||
struct v2f {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 nz : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
struct appdata {
|
||||
float4 vertex : POSITION;
|
||||
float3 normal : NORMAL;
|
||||
fixed4 color : COLOR;
|
||||
float4 texcoord : TEXCOORD0;
|
||||
UNITY_VERTEX_INPUT_INSTANCE_ID
|
||||
};
|
||||
v2f vert( appdata v ) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
TerrainAnimateTree(v.vertex, v.color.w);
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
o.nz.xyz = -COMPUTE_VIEW_NORMAL;
|
||||
o.nz.w = COMPUTE_DEPTH_01;
|
||||
return o;
|
||||
}
|
||||
uniform sampler2D _MainTex;
|
||||
uniform fixed _Cutoff;
|
||||
fixed4 frag(v2f i) : SV_Target {
|
||||
fixed4 texcol = tex2D( _MainTex, i.uv );
|
||||
clip( texcol.a - _Cutoff );
|
||||
return EncodeDepthNormal (i.nz.w, i.nz.xyz);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "RenderType"="TreeBillboard" }
|
||||
Pass {
|
||||
Cull Off
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#include "TerrainEngine.cginc"
|
||||
struct v2f {
|
||||
float4 pos : SV_POSITION;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 nz : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
v2f vert (appdata_tree_billboard v) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
TerrainBillboardTree(v.vertex, v.texcoord1.xy, v.texcoord.y);
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv.x = v.texcoord.x;
|
||||
o.uv.y = v.texcoord.y > 0;
|
||||
o.nz.xyz = float3(0,0,1);
|
||||
o.nz.w = COMPUTE_DEPTH_01;
|
||||
return o;
|
||||
}
|
||||
uniform sampler2D _MainTex;
|
||||
fixed4 frag(v2f i) : SV_Target {
|
||||
fixed4 texcol = tex2D( _MainTex, i.uv );
|
||||
clip( texcol.a - 0.001 );
|
||||
return EncodeDepthNormal (i.nz.w, i.nz.xyz);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "RenderType"="GrassBillboard" }
|
||||
Pass {
|
||||
Cull Off
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#include "TerrainEngine.cginc"
|
||||
|
||||
struct v2f {
|
||||
float4 pos : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 nz : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert (appdata_full v) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
WavingGrassBillboardVert (v);
|
||||
o.color = v.color;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.texcoord.xy;
|
||||
o.nz.xyz = COMPUTE_VIEW_NORMAL;
|
||||
o.nz.w = COMPUTE_DEPTH_01;
|
||||
return o;
|
||||
}
|
||||
uniform sampler2D _MainTex;
|
||||
uniform fixed _Cutoff;
|
||||
fixed4 frag(v2f i) : SV_Target {
|
||||
fixed4 texcol = tex2D( _MainTex, i.uv );
|
||||
fixed alpha = texcol.a * i.color.a;
|
||||
clip( alpha - _Cutoff );
|
||||
return EncodeDepthNormal (i.nz.w, i.nz.xyz);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
SubShader {
|
||||
Tags { "RenderType"="Grass" }
|
||||
Pass {
|
||||
Cull Off
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
#include "UnityCG.cginc"
|
||||
#include "TerrainEngine.cginc"
|
||||
struct v2f {
|
||||
float4 pos : SV_POSITION;
|
||||
fixed4 color : COLOR;
|
||||
float2 uv : TEXCOORD0;
|
||||
float4 nz : TEXCOORD1;
|
||||
UNITY_VERTEX_OUTPUT_STEREO
|
||||
};
|
||||
|
||||
v2f vert (appdata_full v) {
|
||||
v2f o;
|
||||
UNITY_SETUP_INSTANCE_ID(v);
|
||||
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o);
|
||||
WavingGrassVert (v);
|
||||
o.color = v.color;
|
||||
o.pos = UnityObjectToClipPos(v.vertex);
|
||||
o.uv = v.texcoord;
|
||||
o.nz.xyz = COMPUTE_VIEW_NORMAL;
|
||||
o.nz.w = COMPUTE_DEPTH_01;
|
||||
return o;
|
||||
}
|
||||
uniform sampler2D _MainTex;
|
||||
uniform fixed _Cutoff;
|
||||
fixed4 frag(v2f i) : SV_Target {
|
||||
fixed4 texcol = tex2D( _MainTex, i.uv );
|
||||
fixed alpha = texcol.a * i.color.a;
|
||||
clip( alpha - _Cutoff );
|
||||
return EncodeDepthNormal (i.nz.w, i.nz.xyz);
|
||||
}
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
Fallback Off
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: abbda12fddbb0b048a842a3835470d30
|
||||
timeCreated: 1480325971
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,170 +0,0 @@
|
||||
Shader "Spine/Sprite/Pixel Lit"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Main Texture", 2D) = "white" {}
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
|
||||
_BumpScale("Scale", Float) = 1.0
|
||||
_BumpMap ("Normal Map", 2D) = "bump" {}
|
||||
|
||||
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
|
||||
|
||||
_EmissionColor("Color", Color) = (0,0,0,0)
|
||||
_EmissionMap("Emission", 2D) = "white" {}
|
||||
_EmissionPower("Emission Power", Float) = 2.0
|
||||
|
||||
_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5
|
||||
_GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0
|
||||
[Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
|
||||
_MetallicGlossMap("Metallic", 2D) = "white" {}
|
||||
|
||||
_DiffuseRamp ("Diffuse Ramp Texture", 2D) = "gray" {}
|
||||
|
||||
_FixedNormal ("Fixed Normal", Vector) = (0,0,1,1)
|
||||
_Cutoff ("Depth alpha cutoff", Range(0,1)) = 0.5
|
||||
_ShadowAlphaCutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
_CustomRenderQueue ("Custom Render Queue", Float) = 0.0
|
||||
|
||||
_OverlayColor ("Overlay Color", Color) = (0,0,0,0)
|
||||
_Hue("Hue", Range(-0.5,0.5)) = 0.0
|
||||
_Saturation("Saturation", Range(0,2)) = 1.0
|
||||
_Brightness("Brightness", Range(0,2)) = 1.0
|
||||
|
||||
_RimPower("Rim Power", Float) = 2.0
|
||||
_RimColor ("Rim Color", Color) = (1,1,1,1)
|
||||
|
||||
_BlendTex ("Blend Texture", 2D) = "white" {}
|
||||
_BlendAmount ("Blend", Range(0,1)) = 0.0
|
||||
|
||||
[HideInInspector] _SrcBlend ("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend ("__dst", Float) = 0.0
|
||||
[HideInInspector] _RenderQueue ("__queue", Float) = 0.0
|
||||
[HideInInspector] _Cull ("__cull", Float) = 0.0
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "RenderType"="Sprite" "AlphaDepth"="False" "CanUseSpriteAtlas"="True" "IgnoreProjector"="True" }
|
||||
LOD 200
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD"
|
||||
Tags { "LightMode" = "ForwardBase" }
|
||||
Blend [_SrcBlend] [_DstBlend]
|
||||
// Note: ZWrite needs to be enabled for following ForwardAdd pass, otherwise parts will look as if shining through by getting lit.
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
Cull [_Cull]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
|
||||
#pragma shader_feature _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
|
||||
#pragma shader_feature _ _FIXED_NORMALS_VIEWSPACE _FIXED_NORMALS_VIEWSPACE_BACKFACE _FIXED_NORMALS_MODELSPACE _FIXED_NORMALS_MODELSPACE_BACKFACE _FIXED_NORMALS_WORLDSPACE
|
||||
#pragma shader_feature _ _SPECULAR _SPECULAR_GLOSSMAP
|
||||
#pragma shader_feature _NORMALMAP
|
||||
#pragma shader_feature _ALPHA_CLIP
|
||||
#pragma shader_feature _EMISSION
|
||||
#pragma shader_feature _RIM_LIGHTING
|
||||
#pragma shader_feature _DIFFUSE_RAMP
|
||||
#pragma shader_feature _ _FULLRANGE_HARD_RAMP _FULLRANGE_SOFT_RAMP _OLD_HARD_RAMP _OLD_SOFT_RAMP
|
||||
#pragma shader_feature _COLOR_ADJUST
|
||||
#pragma shader_feature _TEXTURE_BLEND
|
||||
#pragma shader_feature _SPHERICAL_HARMONICS
|
||||
#pragma shader_feature _FOG
|
||||
|
||||
#pragma multi_compile_fwdbase
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile _ PIXELSNAP_ON
|
||||
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment fragBase
|
||||
|
||||
#include "CGIncludes/SpritePixelLighting.cginc"
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "FORWARD_DELTA"
|
||||
Tags { "LightMode" = "ForwardAdd" }
|
||||
Blend [_SrcBlend] One
|
||||
ZWrite Off
|
||||
ZTest LEqual
|
||||
Cull [_Cull]
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
|
||||
#pragma shader_feature _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
|
||||
#pragma shader_feature _ _FIXED_NORMALS_VIEWSPACE _FIXED_NORMALS_VIEWSPACE_BACKFACE _FIXED_NORMALS_MODELSPACE _FIXED_NORMALS_MODELSPACE_BACKFACE _FIXED_NORMALS_WORLDSPACE
|
||||
#pragma shader_feature _ _SPECULAR _SPECULAR_GLOSSMAP
|
||||
#pragma shader_feature _NORMALMAP
|
||||
#pragma shader_feature _ALPHA_CLIP
|
||||
#pragma shader_feature _DIFFUSE_RAMP
|
||||
#pragma shader_feature _ _FULLRANGE_HARD_RAMP _FULLRANGE_SOFT_RAMP _OLD_HARD_RAMP _OLD_SOFT_RAMP
|
||||
#pragma shader_feature _COLOR_ADJUST
|
||||
#pragma shader_feature _TEXTURE_BLEND
|
||||
#pragma shader_feature _FOG
|
||||
|
||||
#pragma multi_compile_fwdadd_fullshadows
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile _ PIXELSNAP_ON
|
||||
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment fragAdd
|
||||
|
||||
#include "CGIncludes/SpritePixelLighting.cginc"
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
Offset 1, 1
|
||||
|
||||
Fog { Mode Off }
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
Cull Off
|
||||
Lighting Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma multi_compile _ PIXELSNAP_ON
|
||||
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "CGIncludes/SpriteShadows.cginc"
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
FallBack "Spine/Sprite/Unlit"
|
||||
CustomEditor "SpineSpriteShaderGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6f7a5a97a82637f478494bc40ea8c8a2
|
||||
timeCreated: 1479457857
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,107 +0,0 @@
|
||||
Shader "Spine/Sprite/Unlit"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Main Texture", 2D) = "white" {}
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
|
||||
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
|
||||
|
||||
_ZWrite ("Depth Write", Float) = 0.0
|
||||
_Cutoff ("Depth alpha cutoff", Range(0,1)) = 0.0
|
||||
_ShadowAlphaCutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
_CustomRenderQueue ("Custom Render Queue", Float) = 0.0
|
||||
|
||||
_OverlayColor ("Overlay Color", Color) = (0,0,0,0)
|
||||
_Hue("Hue", Range(-0.5,0.5)) = 0.0
|
||||
_Saturation("Saturation", Range(0,2)) = 1.0
|
||||
_Brightness("Brightness", Range(0,2)) = 1.0
|
||||
|
||||
_BlendTex ("Blend Texture", 2D) = "white" {}
|
||||
_BlendAmount ("Blend", Range(0,1)) = 0.0
|
||||
|
||||
[HideInInspector] _SrcBlend ("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend ("__dst", Float) = 0.0
|
||||
[HideInInspector] _RenderQueue ("__queue", Float) = 0.0
|
||||
[HideInInspector] _Cull ("__cull", Float) = 0.0
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "RenderType"="Sprite" "AlphaDepth"="False" "CanUseSpriteAtlas"="True" "IgnoreProjector"="True" }
|
||||
LOD 100
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Normal"
|
||||
|
||||
Blend [_SrcBlend] [_DstBlend]
|
||||
Lighting Off
|
||||
ZWrite [_ZWrite]
|
||||
ZTest LEqual
|
||||
Cull [_Cull]
|
||||
Lighting Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma shader_feature _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
|
||||
#pragma shader_feature _ALPHA_CLIP
|
||||
#pragma shader_feature _TEXTURE_BLEND
|
||||
#pragma shader_feature _COLOR_ADJUST
|
||||
#pragma shader_feature _FOG
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile _ PIXELSNAP_ON
|
||||
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "CGIncludes/SpriteUnlit.cginc"
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
Offset 1, 1
|
||||
|
||||
Fog { Mode Off }
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
Cull Off
|
||||
Lighting Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma multi_compile _ PIXELSNAP_ON
|
||||
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "CGIncludes/SpriteShadows.cginc"
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
CustomEditor "SpineSpriteShaderGUI"
|
||||
}
|
||||
@@ -1,9 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64005298b9a80bb4899eabd5140dc4a8
|
||||
timeCreated: 1479457857
|
||||
licenseType: Free
|
||||
ShaderImporter:
|
||||
defaultTextures: []
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,136 +0,0 @@
|
||||
Shader "Spine/Sprite/Vertex Lit"
|
||||
{
|
||||
Properties
|
||||
{
|
||||
_MainTex ("Main Texture", 2D) = "white" {}
|
||||
_Color ("Color", Color) = (1,1,1,1)
|
||||
|
||||
_BumpScale("Scale", Float) = 1.0
|
||||
_BumpMap ("Normal Map", 2D) = "bump" {}
|
||||
|
||||
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
|
||||
|
||||
_EmissionColor("Color", Color) = (0,0,0,0)
|
||||
_EmissionMap("Emission", 2D) = "white" {}
|
||||
_EmissionPower("Emission Power", Float) = 2.0
|
||||
|
||||
_Glossiness("Smoothness", Range(0.0, 1.0)) = 0.5
|
||||
_GlossMapScale("Smoothness Scale", Range(0.0, 1.0)) = 1.0
|
||||
[Gamma] _Metallic("Metallic", Range(0.0, 1.0)) = 0.0
|
||||
_MetallicGlossMap("Metallic", 2D) = "white" {}
|
||||
|
||||
_DiffuseRamp ("Diffuse Ramp Texture", 2D) = "gray" {}
|
||||
|
||||
_FixedNormal ("Fixed Normal", Vector) = (0,0,1,1)
|
||||
_ZWrite ("Depth Write", Float) = 0.0
|
||||
_Cutoff ("Depth alpha cutoff", Range(0,1)) = 0.0
|
||||
_ShadowAlphaCutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
|
||||
_CustomRenderQueue ("Custom Render Queue", Float) = 0.0
|
||||
|
||||
_OverlayColor ("Overlay Color", Color) = (0,0,0,0)
|
||||
_Hue("Hue", Range(-0.5,0.5)) = 0.0
|
||||
_Saturation("Saturation", Range(0,2)) = 1.0
|
||||
_Brightness("Brightness", Range(0,2)) = 1.0
|
||||
|
||||
_RimPower("Rim Power", Float) = 2.0
|
||||
_RimColor ("Rim Color", Color) = (1,1,1,1)
|
||||
|
||||
_BlendTex ("Blend Texture", 2D) = "white" {}
|
||||
_BlendAmount ("Blend", Range(0,1)) = 0.0
|
||||
|
||||
[HideInInspector] _SrcBlend ("__src", Float) = 1.0
|
||||
[HideInInspector] _DstBlend ("__dst", Float) = 0.0
|
||||
[HideInInspector] _RenderQueue ("__queue", Float) = 0.0
|
||||
[HideInInspector] _Cull ("__cull", Float) = 0.0
|
||||
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
|
||||
[HideInInspector][Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
|
||||
|
||||
// Outline properties are drawn via custom editor.
|
||||
[HideInInspector] _OutlineWidth("Outline Width", Range(0,8)) = 3.0
|
||||
[HideInInspector] _OutlineColor("Outline Color", Color) = (1,1,0,1)
|
||||
[HideInInspector] _OutlineReferenceTexWidth("Reference Texture Width", Int) = 1024
|
||||
[HideInInspector] _ThresholdEnd("Outline Threshold", Range(0,1)) = 0.25
|
||||
[HideInInspector] _OutlineSmoothness("Outline Smoothness", Range(0,1)) = 1.0
|
||||
[HideInInspector][MaterialToggle(_USE8NEIGHBOURHOOD_ON)] _Use8Neighbourhood("Sample 8 Neighbours", Float) = 1
|
||||
[HideInInspector] _OutlineMipLevel("Outline Mip Level", Range(0,3)) = 0
|
||||
}
|
||||
|
||||
SubShader
|
||||
{
|
||||
Tags { "Queue"="Transparent" "RenderType"="Sprite" "AlphaDepth"="False" "CanUseSpriteAtlas"="True" "IgnoreProjector"="True" }
|
||||
LOD 150
|
||||
|
||||
Stencil {
|
||||
Ref[_StencilRef]
|
||||
Comp[_StencilComp]
|
||||
Pass Keep
|
||||
}
|
||||
|
||||
Pass
|
||||
{
|
||||
Name "Vertex"
|
||||
Tags { "LightMode" = "Vertex" }
|
||||
Blend [_SrcBlend] [_DstBlend]
|
||||
ZWrite [_ZWrite]
|
||||
ZTest LEqual
|
||||
Cull [_Cull]
|
||||
Lighting On
|
||||
|
||||
CGPROGRAM
|
||||
#pragma target 3.0
|
||||
|
||||
#pragma shader_feature _ _ALPHABLEND_ON _ALPHAPREMULTIPLY_ON _ADDITIVEBLEND _ADDITIVEBLEND_SOFT _MULTIPLYBLEND _MULTIPLYBLEND_X2
|
||||
#pragma shader_feature _ _FIXED_NORMALS_VIEWSPACE _FIXED_NORMALS_VIEWSPACE_BACKFACE _FIXED_NORMALS_MODELSPACE _FIXED_NORMALS_MODELSPACE_BACKFACE _FIXED_NORMALS_WORLDSPACE
|
||||
#pragma shader_feature _ _SPECULAR _SPECULAR_GLOSSMAP
|
||||
#pragma shader_feature _NORMALMAP
|
||||
#pragma shader_feature _ALPHA_CLIP
|
||||
#pragma shader_feature _EMISSION
|
||||
#pragma shader_feature _DIFFUSE_RAMP
|
||||
#pragma shader_feature _ _FULLRANGE_HARD_RAMP _FULLRANGE_SOFT_RAMP _OLD_HARD_RAMP _OLD_SOFT_RAMP
|
||||
#pragma shader_feature _COLOR_ADJUST
|
||||
#pragma shader_feature _RIM_LIGHTING
|
||||
#pragma shader_feature _TEXTURE_BLEND
|
||||
#pragma shader_feature _SPHERICAL_HARMONICS
|
||||
#pragma shader_feature _FOG
|
||||
|
||||
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_fog
|
||||
#pragma multi_compile _ PIXELSNAP_ON
|
||||
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "CGIncludes/SpriteVertexLighting.cginc"
|
||||
ENDCG
|
||||
}
|
||||
Pass
|
||||
{
|
||||
Name "ShadowCaster"
|
||||
Tags { "LightMode"="ShadowCaster" }
|
||||
Offset 1, 1
|
||||
|
||||
Fog { Mode Off }
|
||||
ZWrite On
|
||||
ZTest LEqual
|
||||
Cull Off
|
||||
Lighting Off
|
||||
|
||||
CGPROGRAM
|
||||
#pragma fragmentoption ARB_precision_hint_fastest
|
||||
#pragma multi_compile_shadowcaster
|
||||
#pragma multi_compile _ PIXELSNAP_ON
|
||||
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
|
||||
|
||||
#pragma vertex vert
|
||||
#pragma fragment frag
|
||||
|
||||
#include "CGIncludes/SpriteShadows.cginc"
|
||||
ENDCG
|
||||
}
|
||||
}
|
||||
|
||||
FallBack "Spine/Sprite/Unlit"
|
||||
CustomEditor "SpineSpriteShaderGUI"
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user