Skip to content

Commit

Permalink
feat: UserLogicのユーザー変数 そのままキーに使うように変更
Browse files Browse the repository at this point in the history
  • Loading branch information
pspkurara committed Sep 9, 2020
1 parent 0d5c521 commit dd5adad
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 51 deletions.
14 changes: 7 additions & 7 deletions Packages/uGUI-Skinner/Runtime/SkinnerUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -119,37 +119,37 @@ internal static Dictionary<int, int> CreateVariableIdToIndexDictionary(IEnumerab
{
if (SkinnerSystemType.IsObjectReferenceValue(v.FieldType))
{
if (v.VariableId.HasValue) dic.Add(v.VariableId.Value, objectReferenceCount);
dic.Add(v.VariableId, objectReferenceCount);
objectReferenceCount++;
}
else if (SkinnerSystemType.IsColorValue(v.FieldType))
{
if (v.VariableId.HasValue) dic.Add(v.VariableId.Value, colorCount);
dic.Add(v.VariableId, colorCount);
colorCount++;
}
else if (SkinnerSystemType.IsBoolValue(v.FieldType))
{
if (v.VariableId.HasValue) dic.Add(v.VariableId.Value, boolCount);
dic.Add(v.VariableId, boolCount);
boolCount++;
}
else if (SkinnerSystemType.IsIntValue(v.FieldType))
{
if (v.VariableId.HasValue) dic.Add(v.VariableId.Value, intCount);
dic.Add(v.VariableId, intCount);
intCount++;
}
else if (SkinnerSystemType.IsFloatValue(v.FieldType))
{
if (v.VariableId.HasValue) dic.Add(v.VariableId.Value, floatCount);
dic.Add(v.VariableId, floatCount);
floatCount++;
}
else if (SkinnerSystemType.IsVector4Value(v.FieldType))
{
if (v.VariableId.HasValue) dic.Add(v.VariableId.Value, vector4Count);
dic.Add(v.VariableId, vector4Count);
vector4Count++;
}
else if (SkinnerSystemType.IsStringValue(v.FieldType))
{
if (v.VariableId.HasValue) dic.Add(v.VariableId.Value, stringCount);
dic.Add(v.VariableId, stringCount);
stringCount++;
}
}
Expand Down
4 changes: 2 additions & 2 deletions Packages/uGUI-Skinner/Runtime/UserLogic.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using UnityEngine;
using Type = System.Type;

Expand Down Expand Up @@ -96,9 +97,8 @@ public sealed class UserLogicVariable

/// <summary>
/// 変数ID
/// 指定しておくと<see cref="UserLogicExtension"/>の関数から値を取得できるようになる
/// </summary>
public int ? VariableId = null;
internal int VariableId { get { return RuntimeHelpers.GetHashCode(this); } }

/// <summary>
/// 変数の型
Expand Down
84 changes: 42 additions & 42 deletions Packages/uGUI-Skinner/Runtime/UserLogicExtension.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ internal static void ReleaseActiveUserLogic()
/// <see cref="SkinPartsPropertry.objectReferenceValues">を型変換して取得する
/// </summary>
/// <typeparam name="T">変換する型</typeparam>
/// <param name="variableId">ユーザー変数ID</param>
public static T GetObjectReference<T>(this SkinPartsPropertry property, int variableId) where T : Object
/// <param name="variable">ユーザー変数</param>
public static T GetObjectReference<T>(this SkinPartsPropertry property, UserLogicVariable variable) where T : Object
{
int valueIndex;
if (m_ActiveUserLogic.TryGetValueIndex(variableId, out valueIndex))
if (m_ActiveUserLogic.TryGetValueIndex(variable.VariableId, out valueIndex))
{
return property.objectReferenceValues[valueIndex] as T;
}
Expand All @@ -74,11 +74,11 @@ public static T GetObjectReference<T>(this SkinPartsPropertry property, int vari
/// <summary>
/// <see cref="SkinPartsPropertryWithoutObjectReference.boolValues">を取得する
/// </summary>
/// <param name="variableId">ユーザー変数ID</param>
public static bool GetBool(this SkinPartsPropertry property, int variableId)
/// <param name="variable">ユーザー変数</param>
public static bool GetBool(this SkinPartsPropertry property, UserLogicVariable variable)
{
int valueIndex;
if (m_ActiveUserLogic.TryGetValueIndex(variableId, out valueIndex))
if (m_ActiveUserLogic.TryGetValueIndex(variable.VariableId, out valueIndex))
{
return property.boolValues[valueIndex];
}
Expand All @@ -88,11 +88,11 @@ public static bool GetBool(this SkinPartsPropertry property, int variableId)
/// <summary>
/// <see cref="SkinPartsPropertryWithoutObjectReference.intValues">を取得する
/// </summary>
/// <param name="variableId">ユーザー変数ID</param>
public static int GetInt(this SkinPartsPropertry property, int variableId)
/// <param name="variable">ユーザー変数</param>
public static int GetInt(this SkinPartsPropertry property, UserLogicVariable variable)
{
int valueIndex;
if (m_ActiveUserLogic.TryGetValueIndex(variableId, out valueIndex))
if (m_ActiveUserLogic.TryGetValueIndex(variable.VariableId, out valueIndex))
{
return property.intValues[valueIndex];
}
Expand All @@ -102,11 +102,11 @@ public static int GetInt(this SkinPartsPropertry property, int variableId)
/// <summary>
/// <see cref="SkinPartsPropertryWithoutObjectReference.floatValues">を取得する
/// </summary>
/// <param name="variableId">ユーザー変数ID</param>
public static float GetFloat(this SkinPartsPropertry property, int variableId)
/// <param name="variable">ユーザー変数</param>
public static float GetFloat(this SkinPartsPropertry property, UserLogicVariable variable)
{
int valueIndex;
if (m_ActiveUserLogic.TryGetValueIndex(variableId, out valueIndex))
if (m_ActiveUserLogic.TryGetValueIndex(variable.VariableId, out valueIndex))
{
return property.floatValues[valueIndex];
}
Expand All @@ -116,11 +116,11 @@ public static float GetFloat(this SkinPartsPropertry property, int variableId)
/// <summary>
/// <see cref="SkinPartsPropertryWithoutObjectReference.colorValues">を取得する
/// </summary>
/// <param name="variableId">ユーザー変数ID</param>
public static Color GetColor(this SkinPartsPropertry property, int variableId)
/// <param name="variable">ユーザー変数</param>
public static Color GetColor(this SkinPartsPropertry property, UserLogicVariable variable)
{
int valueIndex;
if (m_ActiveUserLogic.TryGetValueIndex(variableId, out valueIndex))
if (m_ActiveUserLogic.TryGetValueIndex(variable.VariableId, out valueIndex))
{
return property.colorValues[valueIndex];
}
Expand All @@ -130,11 +130,11 @@ public static Color GetColor(this SkinPartsPropertry property, int variableId)
/// <summary>
/// <see cref="SkinPartsPropertryWithoutObjectReference.vector4Values">を取得する
/// </summary>
/// <param name="variableId">ユーザー変数ID</param>
public static Vector4 GetVector4(this SkinPartsPropertry property, int variableId)
/// <param name="variable">ユーザー変数</param>
public static Vector4 GetVector4(this SkinPartsPropertry property, UserLogicVariable variable)
{
int valueIndex;
if (m_ActiveUserLogic.TryGetValueIndex(variableId, out valueIndex))
if (m_ActiveUserLogic.TryGetValueIndex(variable.VariableId, out valueIndex))
{
return property.vector4Values[valueIndex];
}
Expand All @@ -144,11 +144,11 @@ public static Vector4 GetVector4(this SkinPartsPropertry property, int variableI
/// <summary>
/// <see cref="SkinPartsPropertryWithoutObjectReference.stringValues">を取得する
/// </summary>
/// <param name="variableId">ユーザー変数ID</param>
public static string GetString(this SkinPartsPropertry property, int variableId)
/// <param name="variable">ユーザー変数</param>
public static string GetString(this SkinPartsPropertry property, UserLogicVariable variable)
{
int valueIndex;
if (m_ActiveUserLogic.TryGetValueIndex(variableId, out valueIndex))
if (m_ActiveUserLogic.TryGetValueIndex(variable.VariableId, out valueIndex))
{
return property.stringValues[valueIndex];
}
Expand All @@ -163,11 +163,11 @@ public static string GetString(this SkinPartsPropertry property, int variableId)
/// <see cref="SkinPartsPropertry.objectReferenceValues">に値をセットする
/// </summary>
/// <typeparam name="T">変換する型</typeparam>
/// <param name="variableId">ユーザー変数ID</param>
public static void SetObjectReference(this SkinPartsPropertry property, int variableId, Object value)
/// <param name="variable">ユーザー変数</param>
public static void SetObjectReference(this SkinPartsPropertry property, UserLogicVariable variable, Object value)
{
int valueIndex;
if (m_ActiveUserLogic.TryGetValueIndex(variableId, out valueIndex))
if (m_ActiveUserLogic.TryGetValueIndex(variable.VariableId, out valueIndex))
{
property.objectReferenceValues[valueIndex] = value;
}
Expand All @@ -176,11 +176,11 @@ public static void SetObjectReference(this SkinPartsPropertry property, int vari
/// <summary>
/// <see cref="SkinPartsPropertryWithoutObjectReference.boolValues">に値をセットする
/// </summary>
/// <param name="variableId">ユーザー変数ID</param>
public static void SetBool(this SkinPartsPropertry property, int variableId, bool value)
/// <param name="variable">ユーザー変数</param>
public static void SetBool(this SkinPartsPropertry property, UserLogicVariable variable, bool value)
{
int valueIndex;
if (m_ActiveUserLogic.TryGetValueIndex(variableId, out valueIndex))
if (m_ActiveUserLogic.TryGetValueIndex(variable.VariableId, out valueIndex))
{
property.boolValues[valueIndex] = value;
}
Expand All @@ -189,11 +189,11 @@ public static void SetBool(this SkinPartsPropertry property, int variableId, boo
/// <summary>
/// <see cref="SkinPartsPropertryWithoutObjectReference.intValues">に値をセットする
/// </summary>
/// <param name="variableId">ユーザー変数ID</param>
public static void SetInt(this SkinPartsPropertry property, int variableId, int value)
/// <param name="variable">ユーザー変数</param>
public static void SetInt(this SkinPartsPropertry property, UserLogicVariable variable, int value)
{
int valueIndex;
if (m_ActiveUserLogic.TryGetValueIndex(variableId, out valueIndex))
if (m_ActiveUserLogic.TryGetValueIndex(variable.VariableId, out valueIndex))
{
property.intValues[valueIndex] = value;
}
Expand All @@ -202,11 +202,11 @@ public static void SetInt(this SkinPartsPropertry property, int variableId, int
/// <summary>
/// <see cref="SkinPartsPropertryWithoutObjectReference.floatValues">に値をセットする
/// </summary>
/// <param name="variableId">ユーザー変数ID</param>
public static void SetFloat(this SkinPartsPropertry property, int variableId, float value)
/// <param name="variable">ユーザー変数</param>
public static void SetFloat(this SkinPartsPropertry property, UserLogicVariable variable, float value)
{
int valueIndex;
if (m_ActiveUserLogic.TryGetValueIndex(variableId, out valueIndex))
if (m_ActiveUserLogic.TryGetValueIndex(variable.VariableId, out valueIndex))
{
property.floatValues[valueIndex] = value;
}
Expand All @@ -215,11 +215,11 @@ public static void SetFloat(this SkinPartsPropertry property, int variableId, fl
/// <summary>
/// <see cref="SkinPartsPropertryWithoutObjectReference.colorValues">に値をセットする
/// </summary>
/// <param name="variableId">ユーザー変数ID</param>
public static void SetColor(this SkinPartsPropertry property, int variableId, Color value)
/// <param name="variable">ユーザー変数</param>
public static void SetColor(this SkinPartsPropertry property, UserLogicVariable variable, Color value)
{
int valueIndex;
if (m_ActiveUserLogic.TryGetValueIndex(variableId, out valueIndex))
if (m_ActiveUserLogic.TryGetValueIndex(variable.VariableId, out valueIndex))
{
property.colorValues[valueIndex] = value;
}
Expand All @@ -228,11 +228,11 @@ public static void SetColor(this SkinPartsPropertry property, int variableId, Co
/// <summary>
/// <see cref="SkinPartsPropertryWithoutObjectReference.vector4Values">に値をセットする
/// </summary>
/// <param name="variableId">ユーザー変数ID</param>
public static void SetVector4(this SkinPartsPropertry property, int variableId, Vector4 value)
/// <param name="variable">ユーザー変数</param>
public static void SetVector4(this SkinPartsPropertry property, UserLogicVariable variable, Vector4 value)
{
int valueIndex;
if (m_ActiveUserLogic.TryGetValueIndex(variableId, out valueIndex))
if (m_ActiveUserLogic.TryGetValueIndex(variable.VariableId, out valueIndex))
{
property.vector4Values[valueIndex] = value;
}
Expand All @@ -241,11 +241,11 @@ public static void SetVector4(this SkinPartsPropertry property, int variableId,
/// <summary>
/// <see cref="SkinPartsPropertryWithoutObjectReference.stringValues">に値をセットする
/// </summary>
/// <param name="variableId">ユーザー変数ID</param>
public static void SetString(this SkinPartsPropertry property, int variableId, string value)
/// <param name="variable">ユーザー変数</param>
public static void SetString(this SkinPartsPropertry property, UserLogicVariable variable, string value)
{
int valueIndex;
if (m_ActiveUserLogic.TryGetValueIndex(variableId, out valueIndex))
if (m_ActiveUserLogic.TryGetValueIndex(variable.VariableId, out valueIndex))
{
property.stringValues[valueIndex] = value;
}
Expand Down

0 comments on commit dd5adad

Please sign in to comment.