You've already forked UniversalViewer
Eversoul support WIP
Updated line renderer material for handles Handle fixes Fixes
This commit is contained in:
8
Assets/Eversoul/Scripts/AstarPathfindingProject.meta
Normal file
8
Assets/Eversoul/Scripts/AstarPathfindingProject.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7687c4936e390ea4eac4a390cbf62305
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pathfinding
|
||||
{
|
||||
public class AIDestinationSetter : MonoBehaviour
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 47de6a8c3e0ddba4da0208c384fbe9aa
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pathfinding
|
||||
{
|
||||
public class AIPath : MonoBehaviour
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5902a9699d7e98447a066f5a5013ca36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "AstarPathfindingProject"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e606303b7150ca498867dc02cdd3621
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pathfinding
|
||||
{
|
||||
public class FunnelModifier : MonoBehaviour
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 46cb11d99d6bd9a49b8bd347ffca42ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Pathfinding
|
||||
{
|
||||
public class Seeker : MonoBehaviour
|
||||
{
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6ecf065a825ce97498178124d6e2c8cf
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/Eversoul/Scripts/CharacterAsset.cs
Normal file
19
Assets/Eversoul/Scripts/CharacterAsset.cs
Normal file
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
[Serializable]
|
||||
public class CharacterAsset : AssetSpawnData
|
||||
{
|
||||
public string Name;
|
||||
public string Prefab;
|
||||
|
||||
public CharacterAsset(string assetName)
|
||||
{
|
||||
var split = assetName.Split(new char[] { '/', '.' });
|
||||
|
||||
ResourceName = assetName;
|
||||
AssetType = AssetTypes.Character;
|
||||
Prefab = Path.GetFileNameWithoutExtension(assetName);
|
||||
Name = split[split.Length - 4];
|
||||
}
|
||||
}
|
||||
11
Assets/Eversoul/Scripts/CharacterAsset.cs.meta
Normal file
11
Assets/Eversoul/Scripts/CharacterAsset.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2a4a399198c639146ae7a44e9b70ca02
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
19
Assets/Eversoul/Scripts/Eversoul.asmdef
Normal file
19
Assets/Eversoul/Scripts/Eversoul.asmdef
Normal file
@@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "Eversoul",
|
||||
"rootNamespace": "",
|
||||
"references": [
|
||||
"GUID:1f135e4ce2898524aa1e81c5cd7f1242",
|
||||
"GUID:24ad1c085c49dc34dbe16c3d92c6f299",
|
||||
"GUID:6055be8ebefd69e48b49212b09b47b2f",
|
||||
"GUID:605c065ed537aa34fa525e662cb3d117"
|
||||
],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
||||
7
Assets/Eversoul/Scripts/Eversoul.asmdef.meta
Normal file
7
Assets/Eversoul/Scripts/Eversoul.asmdef.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2a41aa13ffd78e344858175ae3227e72
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
71
Assets/Eversoul/Scripts/EversoulAssetLibrary.cs
Normal file
71
Assets/Eversoul/Scripts/EversoulAssetLibrary.cs
Normal file
@@ -0,0 +1,71 @@
|
||||
using Newtonsoft.Json.Linq;
|
||||
using SFB;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
|
||||
public class EversoulAssetLibrary : AssetLibrary
|
||||
{
|
||||
public static EversoulAssetLibrary Instance => GetInstance<EversoulAssetLibrary>();
|
||||
|
||||
private List<string> assets = new List<string>();
|
||||
private Dictionary<string, string> hashDirectories = new Dictionary<string, string>();
|
||||
private Dictionary<string, string> hashAssets = new Dictionary<string, string>();
|
||||
private Dictionary<string, string> assetHashes = new Dictionary<string, string>();
|
||||
|
||||
public List<string> CharacterAssets = new List<string>();
|
||||
public List<string> AnimationAssets = new List<string>();
|
||||
|
||||
public List<CharacterAsset> Characters;
|
||||
|
||||
IEnumerator Start()
|
||||
{
|
||||
var selectedFilePath = new string[0];
|
||||
|
||||
while (true)
|
||||
{
|
||||
Debug.LogError("IMPLEMENT SETTINGS!");
|
||||
selectedFilePath = StandaloneFileBrowser.OpenFilePanel("Select catalog_eversoul.json", "", "json", false);
|
||||
if(selectedFilePath.Length > 0 && !string.IsNullOrEmpty(selectedFilePath[0]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
yield return new WaitForSeconds(5);
|
||||
}
|
||||
|
||||
string catalogPath = selectedFilePath[0];
|
||||
|
||||
selectedFilePath = new string[0];
|
||||
while (true)
|
||||
{
|
||||
Debug.LogError("IMPLEMENT SETTINGS!");
|
||||
selectedFilePath = StandaloneFileBrowser.OpenFolderPanel("Select folder with assets", "", false);
|
||||
if (selectedFilePath.Length > 0 && !string.IsNullOrEmpty(selectedFilePath[0]))
|
||||
{
|
||||
break;
|
||||
}
|
||||
yield return new WaitForSeconds(5);
|
||||
}
|
||||
|
||||
LocalFilesPath = selectedFilePath[0] + "\\";
|
||||
|
||||
yield return LoadAddressableCatalog(catalogPath);
|
||||
|
||||
var keys = GetAddressableKeys();
|
||||
var charas = keys.Where(k => k.Contains("Character") && k.Contains("/Prefabs/") && k.EndsWith(".prefab")).ToList();
|
||||
|
||||
foreach(var chara in charas)
|
||||
{
|
||||
Characters.Add(new CharacterAsset(chara));
|
||||
}
|
||||
|
||||
CharacterAssets = charas;
|
||||
|
||||
EversoulInterface.Instance.CharacterSelection.SetData(Characters);
|
||||
|
||||
yield break;
|
||||
}
|
||||
}
|
||||
11
Assets/Eversoul/Scripts/EversoulAssetLibrary.cs.meta
Normal file
11
Assets/Eversoul/Scripts/EversoulAssetLibrary.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9a3fe97e0d74524448796020eedb40c5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
212
Assets/Eversoul/Scripts/EversoulCharacterContainer.cs
Normal file
212
Assets/Eversoul/Scripts/EversoulCharacterContainer.cs
Normal file
@@ -0,0 +1,212 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using UnityEditor.VersionControl;
|
||||
using UnityEngine;
|
||||
|
||||
public class EversoulCharacterContainer : ObjectContainer, IAnimated
|
||||
{
|
||||
public CharacterAsset Data;
|
||||
public string AnimationSet;
|
||||
public string Animation;
|
||||
|
||||
public List<AnimationClip> Animations;
|
||||
private Animator _animator;
|
||||
private AnimatorOverrideController _animatorController;
|
||||
private Dictionary<HumanBodyBones, Transform> _humanBones = new Dictionary<HumanBodyBones, Transform>();
|
||||
|
||||
public override void Select()
|
||||
{
|
||||
}
|
||||
|
||||
public override void Deselect()
|
||||
{
|
||||
}
|
||||
|
||||
public IEnumerator Build(CharacterAsset model)
|
||||
{
|
||||
Data = model;
|
||||
var path = EversoulAssetLibrary.Instance.GetResourcePath(model.ResourceName, out var dependencies);
|
||||
var modelPath = EversoulAssetLibrary.Instance.LocalFilesPath + path;
|
||||
var dependencyPaths = dependencies.Select(path => EversoulAssetLibrary.Instance.LocalFilesPath + path).ToList();
|
||||
|
||||
yield return EversoulAssetLibrary.Instance.LoadAssets(dependencyPaths);
|
||||
|
||||
var bundle = AssetLibrary.LoadFromFile(modelPath);
|
||||
var asset = bundle.LoadAsset<GameObject>(model.ResourceName);
|
||||
var go = Instantiate(asset, this.transform);
|
||||
|
||||
EversoulAssetLibrary.Instance.UnloadAssets(dependencyPaths);
|
||||
EversoulAssetLibrary.Instance.UnloadAsset(modelPath);
|
||||
|
||||
SetDefaultMaterials(transform);
|
||||
|
||||
Init();
|
||||
}
|
||||
|
||||
public void Init()
|
||||
{
|
||||
_animator = GetComponentInChildren<Animator>();
|
||||
_animator.applyRootMotion = false;
|
||||
_animator.runtimeAnimatorController = _animatorController = Instantiate(SharedResources.Instance.GenericAnimatorController);
|
||||
SetBones();
|
||||
}
|
||||
|
||||
public void PlayAnimation(AnimationClip anim)
|
||||
{
|
||||
if (anim == null)
|
||||
{
|
||||
Animation = "";
|
||||
_animator.enabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Animation = anim.name;
|
||||
_animator.enabled = true;
|
||||
_animatorController["Anim"] = anim;
|
||||
}
|
||||
}
|
||||
|
||||
public void SetDefaultMaterials(Transform t)
|
||||
{
|
||||
List<Material> materials = new List<Material>();
|
||||
foreach (var renderer in t.GetComponentsInChildren<Renderer>())
|
||||
{
|
||||
foreach (var material in renderer.sharedMaterials)
|
||||
{
|
||||
if (materials.Contains(material)) continue;
|
||||
materials.Add(material);
|
||||
switch (material.shader.name)
|
||||
{
|
||||
case "NineArk/Character/PC_Basic_Body":
|
||||
material.shader = Shader.Find("Eversoul/Lit");
|
||||
break;
|
||||
case "NineArk/Character/PC_Basic_Body_Transparent":
|
||||
material.shader = Shader.Find("Eversoul/Lit Transparent");
|
||||
break;
|
||||
case "NineArk/Character/PC_Basic_Face":
|
||||
material.shader = Shader.Find("Eversoul/Unlit");
|
||||
break;
|
||||
case "NineArk/Outline/PC_Outline":
|
||||
material.shader = Shader.Find("Eversoul/Outline");
|
||||
break;
|
||||
case "NineArk/Outline/PC_Outline_Transparent":
|
||||
material.shader = Shader.Find("Eversoul/Outline Transparent");
|
||||
break;
|
||||
default:
|
||||
Debug.Log("Shader not found: " + material.shader.name);
|
||||
//material.shader = Shader.Find("Eversoul/Lit");
|
||||
break;
|
||||
}
|
||||
Debug.Log(material.shader);
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void SetBones()
|
||||
{
|
||||
var humanBones = new Dictionary<HumanBodyBones, Transform>();
|
||||
var allBones = _animator.transform.GetComponentsInChildren<Transform>().ToDictionary(b => b.name, b => b);
|
||||
humanBones.Add(HumanBodyBones.Hips, TryGet(allBones, "Bip001 Pelvis"));
|
||||
humanBones.Add(HumanBodyBones.Spine, TryGet(allBones, "Bip001 Spine"));
|
||||
humanBones.Add(HumanBodyBones.RightUpperLeg, TryGet(allBones, "Bip001 R Thigh"));
|
||||
humanBones.Add(HumanBodyBones.RightLowerLeg, TryGet(allBones, "Bip001 R Calf"));
|
||||
humanBones.Add(HumanBodyBones.RightFoot, TryGet(allBones, "Bip001 R Foot"));
|
||||
humanBones.Add(HumanBodyBones.RightToes, TryGet(allBones, "Bip001 R Toe0"));
|
||||
humanBones.Add(HumanBodyBones.LeftUpperLeg, TryGet(allBones, "Bip001 L Thigh"));
|
||||
humanBones.Add(HumanBodyBones.LeftLowerLeg, TryGet(allBones, "Bip001 L Calf"));
|
||||
humanBones.Add(HumanBodyBones.LeftFoot, TryGet(allBones, "Bip001 L Foot"));
|
||||
humanBones.Add(HumanBodyBones.LeftToes, TryGet(allBones, "Bip001 L Toe0"));
|
||||
humanBones.Add(HumanBodyBones.Chest, TryGet(allBones, "Bip001 Spine1"));
|
||||
humanBones.Add(HumanBodyBones.Neck, TryGet(allBones, "Bip001 Neck"));
|
||||
humanBones.Add(HumanBodyBones.Head, TryGet(allBones, "Bip001 Head"));
|
||||
humanBones.Add(HumanBodyBones.RightShoulder, TryGet(allBones, "Bip001 R Clavicle"));
|
||||
humanBones.Add(HumanBodyBones.RightUpperArm, TryGet(allBones, "Bip001 R UpperArm"));
|
||||
humanBones.Add(HumanBodyBones.RightLowerArm, TryGet(allBones, "Bip001 R Forearm"));
|
||||
humanBones.Add(HumanBodyBones.RightHand, TryGet(allBones, "Bip001 R Hand"));
|
||||
humanBones.Add(HumanBodyBones.RightIndexProximal, TryGet(allBones, "Bip001 R Finger1"));
|
||||
humanBones.Add(HumanBodyBones.RightIndexIntermediate, TryGet(allBones, "Bip001 R Finger11"));
|
||||
humanBones.Add(HumanBodyBones.RightMiddleProximal, TryGet(allBones, "Bip001 R Finger2"));
|
||||
humanBones.Add(HumanBodyBones.RightMiddleIntermediate, TryGet(allBones, "Bip001 R Finger21"));
|
||||
humanBones.Add(HumanBodyBones.RightRingProximal, TryGet(allBones, "Bip001 R Finger3"));
|
||||
humanBones.Add(HumanBodyBones.RightRingIntermediate, TryGet(allBones, "Bip001 R Finger31"));
|
||||
humanBones.Add(HumanBodyBones.RightLittleProximal, TryGet(allBones, "Bip001 R Finger4"));
|
||||
humanBones.Add(HumanBodyBones.RightLittleIntermediate, TryGet(allBones, "Bip001 R Finger41"));
|
||||
humanBones.Add(HumanBodyBones.RightThumbProximal, TryGet(allBones, "Bip001 R Finger0"));
|
||||
humanBones.Add(HumanBodyBones.RightThumbIntermediate, TryGet(allBones, "Bip001 R Finger01"));
|
||||
humanBones.Add(HumanBodyBones.LeftShoulder, TryGet(allBones, "Bip001 L Clavicle"));
|
||||
humanBones.Add(HumanBodyBones.LeftUpperArm, TryGet(allBones, "Bip001 L UpperArm"));
|
||||
humanBones.Add(HumanBodyBones.LeftLowerArm, TryGet(allBones, "Bip001 L Forearm"));
|
||||
humanBones.Add(HumanBodyBones.LeftHand, TryGet(allBones, "Bip001 L Hand"));
|
||||
humanBones.Add(HumanBodyBones.LeftIndexProximal, TryGet(allBones, "Bip001 L Finger1"));
|
||||
humanBones.Add(HumanBodyBones.LeftIndexIntermediate, TryGet(allBones, "Bip001 L Finger11"));
|
||||
humanBones.Add(HumanBodyBones.LeftMiddleProximal, TryGet(allBones, "Bip001 L Finger2"));
|
||||
humanBones.Add(HumanBodyBones.LeftMiddleIntermediate, TryGet(allBones, "Bip001 L Finger21"));
|
||||
humanBones.Add(HumanBodyBones.LeftRingProximal, TryGet(allBones, "Bip001 L Finger3"));
|
||||
humanBones.Add(HumanBodyBones.LeftRingIntermediate, TryGet(allBones, "Bip001 L Finger31"));
|
||||
humanBones.Add(HumanBodyBones.LeftLittleProximal, TryGet(allBones, "Bip001 L Finger4"));
|
||||
humanBones.Add(HumanBodyBones.LeftLittleIntermediate, TryGet(allBones, "Bip001 L Finger41"));
|
||||
humanBones.Add(HumanBodyBones.LeftThumbProximal, TryGet(allBones, "Bip001 L Finger0"));
|
||||
humanBones.Add(HumanBodyBones.LeftThumbIntermediate, TryGet(allBones, "Bip001 L Finger01"));
|
||||
foreach (var bone in humanBones)
|
||||
{
|
||||
if (bone.Value != null)
|
||||
{
|
||||
var tags = new List<SerializableBone.BoneTags>() { SerializableBone.BoneTags.Humanoid };
|
||||
if (bone.Value.name.Contains(" L "))
|
||||
{
|
||||
tags.Add(SerializableBone.BoneTags.Left);
|
||||
}
|
||||
else if (bone.Value.name.Contains(" R "))
|
||||
{
|
||||
tags.Add(SerializableBone.BoneTags.Right);
|
||||
}
|
||||
if ((bone.Key >= HumanBodyBones.LeftThumbProximal && bone.Key <= HumanBodyBones.LeftLittleDistal)
|
||||
|| (bone.Key >= HumanBodyBones.RightThumbProximal && bone.Key <= HumanBodyBones.RightLittleDistal))
|
||||
{
|
||||
tags.Add(SerializableBone.BoneTags.Finger);
|
||||
}
|
||||
UIHandle.CreateAsChild<UIHandleBone>(bone.Value).Init(this, tags).WithLineRenderer(); ;
|
||||
}
|
||||
}
|
||||
foreach (var bone in allBones.Values.Except(humanBones.Values))
|
||||
{
|
||||
var tags = new List<SerializableBone.BoneTags>();
|
||||
UIHandle.CreateAsChild<UIHandleBone>(bone).Init(this, tags).WithLineRenderer(); ;
|
||||
}
|
||||
|
||||
_humanBones = humanBones;
|
||||
}
|
||||
|
||||
public T TryGet<T>(Dictionary<string, T> dict, string key)
|
||||
{
|
||||
if (dict.ContainsKey(key))
|
||||
{
|
||||
return dict[key];
|
||||
}
|
||||
return default(T);
|
||||
}
|
||||
|
||||
public override Vector3 GetCenter()
|
||||
{
|
||||
if (_humanBones.ContainsKey(HumanBodyBones.Hips))
|
||||
{
|
||||
return _humanBones[HumanBodyBones.Hips].position;
|
||||
}
|
||||
return base.GetCenter();
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
{
|
||||
if (_applicationQuitting) return;
|
||||
base.OnDestroy();
|
||||
}
|
||||
|
||||
public Animator GetAnimator()
|
||||
{
|
||||
return _animator;
|
||||
}
|
||||
}
|
||||
11
Assets/Eversoul/Scripts/EversoulCharacterContainer.cs.meta
Normal file
11
Assets/Eversoul/Scripts/EversoulCharacterContainer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3622e2dc0c9881b4b87e74ba76f78a30
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
10
Assets/Eversoul/Scripts/EversoulInterface.cs
Normal file
10
Assets/Eversoul/Scripts/EversoulInterface.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EversoulInterface : ModelViewerInterface
|
||||
{
|
||||
public static EversoulInterface Instance => GetInstance<EversoulInterface>();
|
||||
|
||||
public EversoulCharacterDropdown CharacterSelection;
|
||||
}
|
||||
11
Assets/Eversoul/Scripts/EversoulInterface.cs.meta
Normal file
11
Assets/Eversoul/Scripts/EversoulInterface.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7f4a84e77c5798348ae47eea0f9b5866
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Eversoul/Scripts/EversoulMain.cs
Normal file
8
Assets/Eversoul/Scripts/EversoulMain.cs
Normal file
@@ -0,0 +1,8 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class EversoulMain : ModelViewerMain
|
||||
{
|
||||
public static EversoulMain Instance => GetInstance<EversoulMain>();
|
||||
}
|
||||
11
Assets/Eversoul/Scripts/EversoulMain.cs.meta
Normal file
11
Assets/Eversoul/Scripts/EversoulMain.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fe89d0059f151d3419097989e3ab1a8d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
21
Assets/Eversoul/Scripts/EversoulModelBuilder.cs
Normal file
21
Assets/Eversoul/Scripts/EversoulModelBuilder.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using UnityEngine;
|
||||
|
||||
public class EversoulModelBuilder : ModelBuilder
|
||||
{
|
||||
public static EversoulModelBuilder Instance => GetInstance<EversoulModelBuilder>();
|
||||
|
||||
public ObjectContainer SpawnCharacter(CharacterAsset asset)
|
||||
{
|
||||
EversoulMain.Instance.PrepareForLoad();
|
||||
var container = ObjectContainer.Create<EversoulCharacterContainer>("Character");
|
||||
var handle = UIHandle.CreateAsChild<UIHandleMain>(container.transform).Init(container);
|
||||
StartCoroutine(container.Build(asset));
|
||||
return container;
|
||||
}
|
||||
}
|
||||
11
Assets/Eversoul/Scripts/EversoulModelBuilder.cs.meta
Normal file
11
Assets/Eversoul/Scripts/EversoulModelBuilder.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1830b139865203d438294245dcc0fea1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Eversoul/Scripts/ParticleImage.meta
Normal file
8
Assets/Eversoul/Scripts/ParticleImage.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dee50cfbe0c1bae409c0563bc60c6891
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,3 @@
|
||||
{
|
||||
"name": "ParticleImage"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52b1de94b6247034eac9abce73da52b2
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
22
Assets/Eversoul/Scripts/ParticleImage/ParticleImage.cs
Normal file
22
Assets/Eversoul/Scripts/ParticleImage/ParticleImage.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace AssetKits.ParticleImage
|
||||
{
|
||||
public class ParticleImage : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
11
Assets/Eversoul/Scripts/ParticleImage/ParticleImage.cs.meta
Normal file
11
Assets/Eversoul/Scripts/ParticleImage/ParticleImage.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b54c20244825d7d48b445415c8db1a6d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Eversoul/Scripts/UI.meta
Normal file
8
Assets/Eversoul/Scripts/UI.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95eea1888cdedff438424111300f0883
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
131
Assets/Eversoul/Scripts/UI/EversoulCharacterDropdown.cs
Normal file
131
Assets/Eversoul/Scripts/UI/EversoulCharacterDropdown.cs
Normal file
@@ -0,0 +1,131 @@
|
||||
using TMPro;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
public class EversoulCharacterDropdown : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Dropdown MainDropdown;
|
||||
[SerializeField] private TMP_InputField MainLabel;
|
||||
public List<string> DropdownLabels = new List<string>() { "Character", "Costume" };
|
||||
public List<TMP_Dropdown> Dropdowns = new List<TMP_Dropdown>();
|
||||
public List<TMP_InputField> Labels = new List<TMP_InputField>();
|
||||
private bool _awake;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (_awake) return;
|
||||
_awake = true;
|
||||
Rebuild();
|
||||
}
|
||||
|
||||
private void Rebuild()
|
||||
{
|
||||
var labelParent = MainLabel.transform.parent;
|
||||
var dropdownParent = MainDropdown.transform.parent;
|
||||
|
||||
MainDropdown.ClearOptions();
|
||||
Dropdowns.Clear();
|
||||
Dropdowns.Add(MainDropdown);
|
||||
|
||||
foreach (var child in dropdownParent.GetComponentsInChildren<TMP_Dropdown>())
|
||||
{
|
||||
if (child != MainDropdown) Destroy(child);
|
||||
}
|
||||
foreach (var child in labelParent.GetComponentsInChildren<TMP_Dropdown>())
|
||||
{
|
||||
if (child != MainLabel) Destroy(child);
|
||||
}
|
||||
|
||||
MainDropdown.name = DropdownLabels[0];
|
||||
MainLabel.text = DropdownLabels[0];
|
||||
|
||||
foreach (var label in DropdownLabels.Skip(1))
|
||||
{
|
||||
var dd = Instantiate(MainDropdown, dropdownParent);
|
||||
dd.name = "dropdown_" + label;
|
||||
var ll = Instantiate(MainLabel, labelParent);
|
||||
ll.name = label + " (TMP)";
|
||||
ll.text = label;
|
||||
Dropdowns.Add(dd);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetData(List<CharacterAsset> characters)
|
||||
{
|
||||
Awake();
|
||||
SetDropdownData(0, characters.Select(c => c.Name).Distinct().ToList(), true, true);
|
||||
|
||||
UnityAction<int> groupCallback = (index) =>
|
||||
{
|
||||
if (index == 0) return;
|
||||
|
||||
var name = GetOption(0);
|
||||
SetDropdownData(1, characters.Where(c => c.Name == name).Select(c => c.Prefab).Distinct().ToList(), true, true);
|
||||
//SetDropdownData(2, new List<string>(), true, true);
|
||||
};
|
||||
|
||||
UnityAction<int> charaCallback = (index) =>
|
||||
{
|
||||
if (index == 0) return;
|
||||
|
||||
var name = GetOption(0);
|
||||
var prefab = GetOption(1);
|
||||
var costume = characters.First(c => c.Name == name && c.Prefab == prefab);
|
||||
EversoulModelBuilder.Instance.SpawnCharacter(costume);
|
||||
};
|
||||
|
||||
SetCallbacks(new List<UnityAction<int>>()
|
||||
{
|
||||
groupCallback,
|
||||
charaCallback
|
||||
});
|
||||
}
|
||||
|
||||
public void SetCallbacks(List<UnityAction<int>> callbacks)
|
||||
{
|
||||
if (callbacks.Count < Dropdowns.Count)
|
||||
{
|
||||
Error.Log(Color.red, $"Incorrect number of callbacks for dropdowns. Got {callbacks.Count}, required {Dropdowns.Count}");
|
||||
}
|
||||
|
||||
for (int i = 0; i < Dropdowns.Count; i++)
|
||||
{
|
||||
Dropdowns[i].onValueChanged.RemoveAllListeners();
|
||||
Dropdowns[i].onValueChanged.AddListener(callbacks[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public void OnDropdownSelected(int selection)
|
||||
{
|
||||
if (selection == 0)
|
||||
{
|
||||
Debug.LogError("Delete Current");
|
||||
}
|
||||
StartCoroutine(ModelBuilder.GetInstance().SpawnAsset(AssetTypes.Character, MainDropdown.options[selection].text));
|
||||
}
|
||||
|
||||
public void SetDropdownData(string label, List<string> options, bool nullValue = false, bool sortValues = false)
|
||||
{
|
||||
var depth = DropdownLabels.IndexOf(label);
|
||||
SetDropdownData(depth, options, nullValue, sortValues);
|
||||
}
|
||||
|
||||
public string GetOption(int depth)
|
||||
{
|
||||
if (Dropdowns[depth].value == 0) return null;
|
||||
return Dropdowns[depth].options[Dropdowns[depth].value].text;
|
||||
}
|
||||
|
||||
public void SetDropdownData(int depth, List<string> options, bool nullValue = false, bool sortValues = false)
|
||||
{
|
||||
if (depth >= Dropdowns.Count || depth < 0)
|
||||
{
|
||||
Error.Log(Color.red, $"Dropdown {depth} out of range");
|
||||
return;
|
||||
}
|
||||
ModelViewerInterface.SetDropdownData(Dropdowns[depth], options, nullValue, sortValues);
|
||||
}
|
||||
}
|
||||
11
Assets/Eversoul/Scripts/UI/EversoulCharacterDropdown.cs.meta
Normal file
11
Assets/Eversoul/Scripts/UI/EversoulCharacterDropdown.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0cae67f461265ba41a969d8db4bc6093
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user