Skip to content

Commit 40ccab3

Browse files
SpriteLibrary Export, ScriptableObject(UnityClonkActMap) export, Example ScriptBased Animation Player, Example Animator Controller, Simple Demo Clonk Controller
1 parent 55846ce commit 40ccab3

File tree

84 files changed

+40222
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

84 files changed

+40222
-0
lines changed

GithubResources/Screenshot_01.png

100 KB
Loading

Mono.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Mono/UnityClonkAnimation.cs

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
2+
using UnityEngine;
3+
4+
5+
namespace UnityClonk
6+
{
7+
[RequireComponent(typeof(SpriteRenderer))]
8+
public class UnityClonkAnimation : MonoBehaviour
9+
{
10+
private SpriteRenderer spriteRenderer;
11+
public UnityClonkActMap actMap;
12+
public float speed = 1f;
13+
public string action;
14+
private float frame;
15+
16+
public string fallback = "Walk";
17+
18+
19+
20+
21+
private string prevAction = null;
22+
private float prevFrame = -1000;
23+
private void Awake()
24+
{
25+
spriteRenderer= GetComponent<SpriteRenderer>();
26+
}
27+
private void Update()
28+
{
29+
if(speed != 0)
30+
{
31+
frame += Time.deltaTime * speed;
32+
}
33+
34+
35+
36+
SetSprite(action, frame, fallback);
37+
38+
}
39+
private void OnValidate()
40+
{ if (Application.isPlaying) return;
41+
SetSprite(action, frame, fallback);
42+
}
43+
44+
public void SetSprite(string name, int frame, string fallbackName = "Walk")
45+
{
46+
spriteRenderer = GetComponent<SpriteRenderer>();
47+
if (actMap.Actions.ContainsKey(name) && actMap != null)
48+
{
49+
int frameIndex = Mathf.Abs(frame % actMap.Actions[name].Length);
50+
spriteRenderer.sprite = actMap.Actions[name][frameIndex];
51+
}
52+
else
53+
{
54+
int frameIndex = Mathf.Abs(frame % actMap.Actions[fallbackName].Length);
55+
spriteRenderer.sprite = actMap.Actions[fallbackName][frameIndex];
56+
}
57+
}
58+
public void SetSprite(string name, float time, string fallbackName = "Walk")
59+
{
60+
spriteRenderer = GetComponent<SpriteRenderer>();
61+
if (actMap.Actions.ContainsKey(name) && actMap != null)
62+
{
63+
int frame = Mathf.RoundToInt(actMap.Actions[name].Length * time);
64+
65+
int frameIndex = Mathf.Abs(frame % actMap.Actions[name].Length);
66+
spriteRenderer.sprite = actMap.Actions[name][frameIndex];
67+
}
68+
else
69+
{
70+
int frame = Mathf.RoundToInt(actMap.Actions[fallbackName].Length * time);
71+
int frameIndex = Mathf.Abs(frame % actMap.Actions[fallbackName].Length);
72+
spriteRenderer.sprite = actMap.Actions[fallbackName][frameIndex];
73+
}
74+
}
75+
}
76+
}

Mono/UnityClonkAnimation.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ScriptableObjects.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
using System.Collections;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
using Sirenix.OdinInspector;
5+
6+
namespace UnityClonk
7+
{
8+
[CreateAssetMenu(fileName = "UnityClonk ActMap", menuName = "UnityClonk/UnityClonk ActMap", order = 1)]
9+
public class UnityClonkActMap : SerializedScriptableObject
10+
{
11+
public Dictionary<string, Sprite[]> Actions = new Dictionary<string, Sprite[]>();
12+
}
13+
}

ScriptableObjects/UnityClonkActMap.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Shader.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Shader/Clonk.mat

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
%YAML 1.1
2+
%TAG !u! tag:unity3d.com,2011:
3+
--- !u!21 &2100000
4+
Material:
5+
serializedVersion: 8
6+
m_ObjectHideFlags: 0
7+
m_CorrespondingSourceObject: {fileID: 0}
8+
m_PrefabInstance: {fileID: 0}
9+
m_PrefabAsset: {fileID: 0}
10+
m_Name: Clonk
11+
m_Shader: {fileID: -6465566751694194690, guid: 547428c4be9223b4cab7b3997922538f, type: 3}
12+
m_ValidKeywords: []
13+
m_InvalidKeywords: []
14+
m_LightmapFlags: 4
15+
m_EnableInstancingVariants: 0
16+
m_DoubleSidedGI: 0
17+
m_CustomRenderQueue: -1
18+
stringTagMap: {}
19+
disabledShaderPasses: []
20+
m_SavedProperties:
21+
serializedVersion: 3
22+
m_TexEnvs:
23+
- _AlphaTex:
24+
m_Texture: {fileID: 0}
25+
m_Scale: {x: 1, y: 1}
26+
m_Offset: {x: 0, y: 0}
27+
- _Graphics:
28+
m_Texture: {fileID: 2800000, guid: 74ded4e27abda974a8bab805621928b4, type: 3}
29+
m_Scale: {x: 1, y: 1}
30+
m_Offset: {x: 0, y: 0}
31+
- _MainTex:
32+
m_Texture: {fileID: 0}
33+
m_Scale: {x: 1, y: 1}
34+
m_Offset: {x: 0.5, y: 1}
35+
- _MaskTex:
36+
m_Texture: {fileID: 0}
37+
m_Scale: {x: 1, y: 1}
38+
m_Offset: {x: 0, y: 0}
39+
- _NormalMap:
40+
m_Texture: {fileID: 0}
41+
m_Scale: {x: 1, y: 1}
42+
m_Offset: {x: 0, y: 0}
43+
- _Overlay:
44+
m_Texture: {fileID: 2800000, guid: bec7d0d1d8255b845b88a7cde61d0d3d, type: 3}
45+
m_Scale: {x: 1, y: 1}
46+
m_Offset: {x: 0, y: 0}
47+
- unity_Lightmaps:
48+
m_Texture: {fileID: 0}
49+
m_Scale: {x: 1, y: 1}
50+
m_Offset: {x: 0, y: 0}
51+
- unity_LightmapsInd:
52+
m_Texture: {fileID: 0}
53+
m_Scale: {x: 1, y: 1}
54+
m_Offset: {x: 0, y: 0}
55+
- unity_ShadowMasks:
56+
m_Texture: {fileID: 0}
57+
m_Scale: {x: 1, y: 1}
58+
m_Offset: {x: 0, y: 0}
59+
m_Ints: []
60+
m_Floats:
61+
- _EnableExternalAlpha: 0
62+
- _QueueControl: 0
63+
- _QueueOffset: 0
64+
m_Colors:
65+
- _Color: {r: 0.8667352, g: 1, b: 0, a: 1}
66+
- _Flip: {r: 1, g: 1, b: 1, a: 1}
67+
- _RendererColor: {r: 1, g: 1, b: 1, a: 1}
68+
- _UV: {r: 0, g: 0, b: 0, a: 0}
69+
m_BuildTextureStacks: []

Shader/Clonk.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)