Initial commit

This commit is contained in:
AbstractConcept 2022-09-13 00:36:34 -05:00
commit 3c7cc0c973
8391 changed files with 704313 additions and 0 deletions

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 290d2a9589a61f44a8efad4e3e75155e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,24 @@
using System.IO;
using UnityEditor;
namespace Unity.U2D.Animation.Sample
{
// ensure class initializer is called whenever scripts recompile
[InitializeOnLoadAttribute]
internal static class BuildAssetBundle
{
// register an event handler when the class is initialized
static BuildAssetBundle()
{
EditorApplication.playModeStateChanged += PlayModeStateChange;
}
private static void PlayModeStateChange(PlayModeStateChange state)
{
if (state == UnityEditor.PlayModeStateChange.ExitingEditMode)
{
LoadSwapDLC.BuildAssetBundles();
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e174580fa8885d948b2444d9f28a0a42
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,21 @@
{
"name": "Unity.2D.Animation.Samples.Editor",
"references": [
"UnityEditor.UI",
"UnityEngine.UI",
"Unity.2D.Animation.Editor",
"Unity.2D.Animation.Runtime",
"Unity.2D.Animation.Samples.Runtime"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: da3c53b869fb6d54db6c4cc838632d66
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8aad5cf35c32aa94f8103a94f3a3d078
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,74 @@
using System.IO;
using System.Linq;
using UnityEngine;
using UnityEngine.Experimental.U2D.Animation;
#if UNITY_EDITOR
using UnityEditor;
#endif
namespace Unity.U2D.Animation.Sample
{
public class LoadSwapDLC : MonoBehaviour
{
const string k_AssetBundleName = "2DAnimationSampleAssetBundles";
public SwapFullSkin[] swapFullSkin;
public void LoadAssetBundle()
{
var assetBundlePath = Path.Combine(Application.streamingAssetsPath, k_AssetBundleName);
var bundle = AssetBundle.LoadFromFile(Path.Combine(assetBundlePath, k_AssetBundleName));
if (bundle == null)
{
Debug.LogWarning("AssetBundle not found");
return;
}
var manifest = bundle.LoadAsset<AssetBundleManifest>("AssetBundleManifest");
if (manifest == null)
{
Debug.LogWarning("Unable to load manifest");
return;
}
foreach (var assetBundleName in manifest.GetAllAssetBundles())
{
var subBundle = AssetBundle.LoadFromFile(Path.Combine(assetBundlePath, assetBundleName));
var assets = subBundle.LoadAllAssets();
foreach (var asset in assets)
{
if (asset is SpriteLibraryAsset)
{
var sla = (SpriteLibraryAsset)asset;
foreach (var sfs in swapFullSkin)
{
var list = sfs.spriteLibraries.ToList();
list.Add(sla);
sfs.spriteLibraries = list.ToArray();
}
}
}
}
foreach (var sfs in swapFullSkin)
{
sfs.UpdateSelectionChoice();
}
}
#if UNITY_EDITOR
[ContextMenu("Build Asset Bundles")]
void BuildBundles()
{
BuildAssetBundles();
}
public static void BuildAssetBundles()
{
string assetBundleDirectory = Path.Combine(Application.streamingAssetsPath, "2DAnimationSampleAssetBundles");
if (!Directory.Exists(assetBundleDirectory))
{
Directory.CreateDirectory(assetBundleDirectory);
}
BuildPipeline.BuildAssetBundles(assetBundleDirectory, BuildAssetBundleOptions.None, EditorUserBuildSettings.activeBuildTarget);
}
#endif
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: db5dd3ca3a4e1944bb86b0768715466e
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,40 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Experimental.U2D.Animation;
using UnityEngine.UI;
namespace Unity.U2D.Animation.Sample
{
public class SwapFullSkin : MonoBehaviour
{
public SpriteLibraryAsset[] spriteLibraries;
public SpriteLibrary spriteLibraryTarget;
public Dropdown dropDownSelection;
// Start is called before the first frame update
void Start()
{
UpdateSelectionChoice();
}
void OnDropDownValueChanged(int value)
{
spriteLibraryTarget.spriteLibraryAsset = spriteLibraries[value];
}
internal void UpdateSelectionChoice()
{
dropDownSelection.ClearOptions();
var options = new List<Dropdown.OptionData>(spriteLibraries.Length);
for (int i = 0; i < spriteLibraries.Length; ++i)
{
options.Add(new Dropdown.OptionData(spriteLibraries[i].name));
}
dropDownSelection.options = options;
dropDownSelection.onValueChanged.AddListener(OnDropDownValueChanged);
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 17ccce387fbc2a64a90ae83539e4afc3
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,45 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.Experimental.U2D.Animation;
using UnityEngine.UI;
namespace Unity.U2D.Animation.Sample
{
[Serializable]
public struct SwapOptionData
{
public Dropdown dropdown;
public SpriteResolver spriteResolver;
public string category;
}
public class SwapPart : MonoBehaviour
{
public SpriteLibraryAsset spriteLibraryAsset;
public SwapOptionData[] swapOptionData;
// Start is called before the first frame update
void Start()
{
foreach (var swapOption in swapOptionData)
{
swapOption.dropdown.ClearOptions();
var labels = spriteLibraryAsset.GetCategoryLabelNames(swapOption.category);
var dropDownOption = new List<Dropdown.OptionData>(labels.Count());
foreach (var label in labels)
{
dropDownOption.Add(new Dropdown.OptionData(label));
}
swapOption.dropdown.options = dropDownOption;
swapOption.dropdown.onValueChanged.AddListener((x)=>
{
swapOption.spriteResolver.SetCategoryAndLabel(swapOption.category, swapOption.dropdown.options[x].text);
});
}
}
}
}

View file

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 580a66ff8fa584a42812990cccd3c52c
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View file

@ -0,0 +1,17 @@
{
"name": "Unity.2D.Animation.Samples.Runtime",
"references": [
"UnityEngine.UI",
"Unity.2D.Animation.Runtime",
"Unity.2D.IK.Runtime"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View file

@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: d6d31008b62a0a04e96e897fe1381b63
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: