Initial Commit
This commit is contained in:
commit
ee5c2f922d
2255 changed files with 547750 additions and 0 deletions
10
Assets/Scripts/UI/Tilemap/Tiles/Animated Tile/Scripts.meta
Normal file
10
Assets/Scripts/UI/Tilemap/Tiles/Animated Tile/Scripts.meta
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d8f0a7d912b6f424aa0e09f8597dd2df
|
||||
folderAsset: yes
|
||||
timeCreated: 1499149343
|
||||
licenseType: Pro
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
|
|
@ -0,0 +1,126 @@
|
|||
using System;
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
|
||||
#endif
|
||||
|
||||
namespace UnityEngine.Tilemaps
|
||||
{
|
||||
[Serializable]
|
||||
public class AnimatedTile : TileBase
|
||||
{
|
||||
public Sprite[] m_AnimatedSprites;
|
||||
public float m_AnimationStartTime;
|
||||
public float m_MaxSpeed = 1f;
|
||||
public float m_MinSpeed = 1f;
|
||||
public Tile.ColliderType m_TileColliderType;
|
||||
|
||||
public override void GetTileData(Vector3Int location, ITilemap tileMap, ref TileData tileData)
|
||||
{
|
||||
tileData.transform = Matrix4x4.identity;
|
||||
tileData.color = Color.white;
|
||||
if (m_AnimatedSprites != null && m_AnimatedSprites.Length > 0)
|
||||
{
|
||||
tileData.sprite = m_AnimatedSprites[m_AnimatedSprites.Length - 1];
|
||||
tileData.colliderType = m_TileColliderType;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool GetTileAnimationData(Vector3Int location, ITilemap tileMap, ref TileAnimationData tileAnimationData)
|
||||
{
|
||||
if (m_AnimatedSprites.Length > 0)
|
||||
{
|
||||
tileAnimationData.animatedSprites = m_AnimatedSprites;
|
||||
tileAnimationData.animationSpeed = Random.Range(m_MinSpeed, m_MaxSpeed);
|
||||
tileAnimationData.animationStartTime = m_AnimationStartTime;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[MenuItem("Assets/Create/Animated Tile")]
|
||||
public static void CreateAnimatedTile()
|
||||
{
|
||||
var path = EditorUtility.SaveFilePanelInProject("Save Animated Tile", "New Animated Tile", "asset", "Save Animated Tile", "Assets");
|
||||
if (path == "")
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AssetDatabase.CreateAsset(CreateInstance<AnimatedTile>(), path);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
[CustomEditor(typeof(AnimatedTile))]
|
||||
public class AnimatedTileEditor : Editor
|
||||
{
|
||||
private AnimatedTile tile => target as AnimatedTile;
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
EditorGUI.BeginChangeCheck();
|
||||
var count = EditorGUILayout.DelayedIntField(
|
||||
"Number of Animated Sprites",
|
||||
tile.m_AnimatedSprites != null ? tile.m_AnimatedSprites.Length : 0);
|
||||
if (count < 0)
|
||||
{
|
||||
count = 0;
|
||||
}
|
||||
|
||||
if (tile.m_AnimatedSprites == null || tile.m_AnimatedSprites.Length != count)
|
||||
{
|
||||
Array.Resize(ref tile.m_AnimatedSprites, count);
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
EditorGUILayout.LabelField("Place sprites shown based on the order of animation.");
|
||||
EditorGUILayout.Space();
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
tile.m_AnimatedSprites[i] = (Sprite)EditorGUILayout.ObjectField(
|
||||
"Sprite " + (i + 1),
|
||||
tile.m_AnimatedSprites[i],
|
||||
typeof(Sprite),
|
||||
false,
|
||||
null);
|
||||
}
|
||||
|
||||
var minSpeed = EditorGUILayout.FloatField("Minimum Speed", tile.m_MinSpeed);
|
||||
var maxSpeed = EditorGUILayout.FloatField("Maximum Speed", tile.m_MaxSpeed);
|
||||
if (minSpeed < 0.0f)
|
||||
{
|
||||
minSpeed = 0.0f;
|
||||
}
|
||||
|
||||
if (maxSpeed < 0.0f)
|
||||
{
|
||||
maxSpeed = 0.0f;
|
||||
}
|
||||
|
||||
if (maxSpeed < minSpeed)
|
||||
{
|
||||
maxSpeed = minSpeed;
|
||||
}
|
||||
|
||||
tile.m_MinSpeed = minSpeed;
|
||||
tile.m_MaxSpeed = maxSpeed;
|
||||
|
||||
tile.m_AnimationStartTime = EditorGUILayout.FloatField("Start Time", tile.m_AnimationStartTime);
|
||||
tile.m_TileColliderType = (Tile.ColliderType)EditorGUILayout.EnumPopup("Collider Type", tile.m_TileColliderType);
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
EditorUtility.SetDirty(tile);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
|
@ -0,0 +1,12 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 13b75c95f34a00d4e8c04f76b73312e6
|
||||
timeCreated: 1464531813
|
||||
licenseType: Pro
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Add table
Add a link
Reference in a new issue