UI HUGE UPDATE
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using UnityEngine;
|
||||
using System.Collections.Generic;
|
||||
using Spine.Unity;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
#endif
|
||||
@@ -46,6 +47,12 @@ public class AllyHero_SO : ScriptableObject
|
||||
[Header("Inspector")]
|
||||
public Sprite ally_hero_squareProfile;
|
||||
|
||||
[Header("spine")]
|
||||
public SkeletonDataAsset ally_heroSpineData;
|
||||
|
||||
[Header("Skins")]
|
||||
public string selectedSkinId;
|
||||
|
||||
[Header("Inspector")]
|
||||
public Color ally_heroThemeColor;
|
||||
|
||||
@@ -494,6 +501,11 @@ public class AllyHero_SO : ScriptableObject
|
||||
return "ally_equippedEquipment_" + ally_heroID;
|
||||
}
|
||||
|
||||
private string GetSelectedSkinPrefsKey()
|
||||
{
|
||||
return "ally_selectedSkin_" + ally_heroID;
|
||||
}
|
||||
|
||||
public void SaveEquippedSkillsToLocal()
|
||||
{
|
||||
var payload = new EquippedSkillGroupIDsPayload { equippedSkillGroupIDs = equippedSkillGroupIDs ?? new int[0] };
|
||||
@@ -622,15 +634,6 @@ public class AllyHero_SO : ScriptableObject
|
||||
}
|
||||
#endif
|
||||
|
||||
equipmentSO[] runtimeEquipments = Resources.LoadAll<equipmentSO>("so/uEquip");
|
||||
for (int i = 0; i < runtimeEquipments.Length; i++)
|
||||
{
|
||||
if (runtimeEquipments[i] != null && runtimeEquipments[i].name == equipmentId)
|
||||
{
|
||||
return runtimeEquipments[i];
|
||||
}
|
||||
}
|
||||
|
||||
var generatedEquipments = Bansonic.equipmentGenerator.GetRuntimeGeneratedEquipments();
|
||||
for (int i = 0; i < generatedEquipments.Count; i++)
|
||||
{
|
||||
@@ -640,6 +643,15 @@ public class AllyHero_SO : ScriptableObject
|
||||
}
|
||||
}
|
||||
|
||||
equipmentSO[] runtimeEquipments = Resources.LoadAll<equipmentSO>("so/uEquip");
|
||||
for (int i = 0; i < runtimeEquipments.Length; i++)
|
||||
{
|
||||
if (runtimeEquipments[i] != null && runtimeEquipments[i].name == equipmentId)
|
||||
{
|
||||
return runtimeEquipments[i];
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -693,6 +705,73 @@ public class AllyHero_SO : ScriptableObject
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
public List<HeroSkinResolvedData> GetResolvedSkinSet(bool includeBaseSkin = true)
|
||||
{
|
||||
return HeroSkinResolver.GetSkinSet(this, includeBaseSkin);
|
||||
}
|
||||
|
||||
public HeroSkinResolvedData GetResolvedSelectedSkin(bool fallbackToBase = true)
|
||||
{
|
||||
return HeroSkinResolver.GetSkinById(this, selectedSkinId, fallbackToBase);
|
||||
}
|
||||
|
||||
public void SetSelectedSkin(string skinId, bool persist = true)
|
||||
{
|
||||
selectedSkinId = string.IsNullOrWhiteSpace(skinId) ? HeroSkinResolver.BuildBaseSkinId(ally_heroID) : skinId.Trim();
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
UnityEditor.EditorUtility.SetDirty(this);
|
||||
if (persist)
|
||||
{
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (persist)
|
||||
{
|
||||
SaveSelectedSkinToLocal();
|
||||
}
|
||||
}
|
||||
|
||||
public void SaveSelectedSkinToLocal()
|
||||
{
|
||||
string safeSkinId = string.IsNullOrWhiteSpace(selectedSkinId) ? HeroSkinResolver.BuildBaseSkinId(ally_heroID) : selectedSkinId.Trim();
|
||||
PlayerPrefs.SetString(GetSelectedSkinPrefsKey(), safeSkinId);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
public void LoadSelectedSkinFromLocal()
|
||||
{
|
||||
string key = GetSelectedSkinPrefsKey();
|
||||
if (!PlayerPrefs.HasKey(key))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
selectedSkinId = PlayerPrefs.GetString(key, HeroSkinResolver.BuildBaseSkinId(ally_heroID));
|
||||
if (string.IsNullOrWhiteSpace(selectedSkinId))
|
||||
{
|
||||
selectedSkinId = HeroSkinResolver.BuildBaseSkinId(ally_heroID);
|
||||
}
|
||||
}
|
||||
|
||||
public void ClearSelectedSkin()
|
||||
{
|
||||
selectedSkinId = HeroSkinResolver.BuildBaseSkinId(ally_heroID);
|
||||
PlayerPrefs.DeleteKey(GetSelectedSkinPrefsKey());
|
||||
PlayerPrefs.Save();
|
||||
#if UNITY_EDITOR
|
||||
if (!Application.isPlaying)
|
||||
{
|
||||
UnityEditor.EditorUtility.SetDirty(this);
|
||||
UnityEditor.AssetDatabase.SaveAssets();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
public void SetUnlocked(bool value)
|
||||
{
|
||||
if (isUnlocked == value) return;
|
||||
|
||||
Reference in New Issue
Block a user