写了一个SpriteAniationpro在communal的ui里,可以选择image播放帧动画,存储个不同状态的动画,通过指定,播放指定的图集,在代码销毁时会自带消除

This commit is contained in:
wulongxiao 2024-11-15 15:21:16 +08:00
parent 66a9acc373
commit 0514fe07ec
6 changed files with 353 additions and 57 deletions

View File

@ -331,6 +331,42 @@ CanvasRenderer:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 41418333}
m_CullTransparentMesh: 1
--- !u!1 &56576994
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 56576995}
m_Layer: 5
m_Name: endpos
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &56576995
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 56576994}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 767448255}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 556, y: 100}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &264538203
GameObject:
m_ObjectHideFlags: 0
@ -919,15 +955,18 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e14236262b3cead4597580fdb841652f, type: 3}
m_Name:
m_EditorClassIdentifier:
fishManPrefab: {fileID: 0}
fishManPrefab: {fileID: 9027535534103199909, guid: 930941387799a9d479889a373bafdc8e, type: 3}
listItem: []
startPos: {fileID: 0}
endPos: {fileID: 0}
startPos: {fileID: 2026870705}
endPos: {fileID: 56576995}
type: 0
ActivateValue: 0
Num: 0
Type: 0
paths: []
paths:
- pathPoints:
- {fileID: 2026870705}
- {fileID: 56576995}
pathsNeedTimer: 30
fishingNeedTimer: 30
restTimer: 5
@ -1089,6 +1128,44 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &767448254
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 767448255}
m_Layer: 5
m_Name: path
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &767448255
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 767448254}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children:
- {fileID: 2026870705}
- {fileID: 56576995}
m_Father: {fileID: 1432362433}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1 &773813746
GameObject:
m_ObjectHideFlags: 0
@ -1302,8 +1379,7 @@ GameObject:
- component: {fileID: 813379044}
- component: {fileID: 813379043}
- component: {fileID: 813379042}
- component: {fileID: 813379041}
- component: {fileID: 813379040}
- component: {fileID: 813379046}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
@ -1311,54 +1387,6 @@ GameObject:
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &813379040
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 813379039}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a24cdfad8fc45d94dbc2008e72816ca9, type: 3}
m_Name:
m_EditorClassIdentifier:
iconS:
- {fileID: 21300000, guid: 9aaf93beba8dd1a4797b67dee38c97e4, type: 3}
- {fileID: 21300000, guid: b87eb5ed7d0f2864d9223218fadf02ef, type: 3}
- {fileID: 21300000, guid: 38e6b85e401c08f4eb5938aa19e72515, type: 3}
lands:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
Generate1: 0
Generate2: 0
Generate3: 0
--- !u!114 &813379041
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 813379039}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a48788a64136b294b8e996807b88dad1, type: 3}
m_Name:
m_EditorClassIdentifier:
iconS:
- {fileID: 21300000, guid: 9aaf93beba8dd1a4797b67dee38c97e4, type: 3}
- {fileID: 21300000, guid: b87eb5ed7d0f2864d9223218fadf02ef, type: 3}
- {fileID: 21300000, guid: 38e6b85e401c08f4eb5938aa19e72515, type: 3}
number: 1
max: 10
minerjiage: 0
type: 0
lands:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
lishiid: 0
--- !u!114 &813379042
MonoBehaviour:
m_ObjectHideFlags: 0
@ -1446,6 +1474,29 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!114 &813379046
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 813379039}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a24cdfad8fc45d94dbc2008e72816ca9, type: 3}
m_Name:
m_EditorClassIdentifier:
iconS:
- {fileID: 21300000, guid: 9aaf93beba8dd1a4797b67dee38c97e4, type: 3}
- {fileID: 21300000, guid: b87eb5ed7d0f2864d9223218fadf02ef, type: 3}
- {fileID: 21300000, guid: 38e6b85e401c08f4eb5938aa19e72515, type: 3}
lands:
- {fileID: 510804174}
- {fileID: 568510979}
- {fileID: 322667943}
Generate1: 0
Generate2: 0
Generate3: 0
--- !u!1001 &834538087
PrefabInstance:
m_ObjectHideFlags: 0
@ -2146,7 +2197,7 @@ PrefabInstance:
- target: {fileID: 2013356390253994791, guid: 44f8c7a70b8d4c54983e81548e983557, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_Target
value:
objectReference: {fileID: 813379040}
objectReference: {fileID: 813379046}
- target: {fileID: 2013356390253994791, guid: 44f8c7a70b8d4c54983e81548e983557, type: 3}
propertyPath: m_OnClick.m_PersistentCalls.m_Calls.Array.data[0].m_CallState
value: 2
@ -2866,6 +2917,7 @@ GameObject:
m_Component:
- component: {fileID: 1293246372}
- component: {fileID: 1293246371}
- component: {fileID: 1293246373}
m_Layer: 0
m_Name: -------------------- (1)
m_TagString: Untagged
@ -2927,6 +2979,20 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1293246373
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1293246370}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ea8231e49b8e6c440b4ede383765832d, type: 3}
m_Name:
m_EditorClassIdentifier:
PromptPrefab: {fileID: 0}
canvs: {fileID: 813379039}
--- !u!1 &1341130021
GameObject:
m_ObjectHideFlags: 0
@ -3376,6 +3442,8 @@ RectTransform:
- {fileID: 2072244184}
- {fileID: 41418334}
- {fileID: 307679580}
- {fileID: 767448255}
- {fileID: 2053001691}
m_Father: {fileID: 510804175}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
@ -4453,6 +4521,42 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2026870704
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2026870705}
m_Layer: 5
m_Name: startpos
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2026870705
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2026870704}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_ConstrainProportionsScale: 0
m_Children: []
m_Father: {fileID: 767448255}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 233, y: -241}
m_SizeDelta: {x: 100, y: 100}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!1001 &2045818102
PrefabInstance:
m_ObjectHideFlags: 0
@ -4555,6 +4659,119 @@ RectTransform:
m_CorrespondingSourceObject: {fileID: 3229315116778200709, guid: c5e8245d9cbdb3e4087ffdb8a6161e5a, type: 3}
m_PrefabInstance: {fileID: 2045818102}
m_PrefabAsset: {fileID: 0}
--- !u!1 &2053001690
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2053001691}
- component: {fileID: 2053001693}
- component: {fileID: 2053001694}
- component: {fileID: 2053001695}
m_Layer: 5
m_Name: jiashadao_fishMan1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &2053001691
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2053001690}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.2, y: 0.2, z: 0.2}
m_ConstrainProportionsScale: 1
m_Children: []
m_Father: {fileID: 1432362433}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 49, y: -50}
m_SizeDelta: {x: 2565, y: 1703.3202}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &2053001693
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2053001690}
m_CullTransparentMesh: 1
--- !u!114 &2053001694
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2053001690}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
m_Maskable: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_Sprite: {fileID: 21300000, guid: 65d012f41d509b5409ca161dc951db7f, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
m_UseSpriteMesh: 0
m_PixelsPerUnitMultiplier: 1
--- !u!114 &2053001695
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2053001690}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 4c6b440cf0a9d9b45bcb433ce72d557b, type: 3}
m_Name:
m_EditorClassIdentifier:
sprites:
- mysprites:
- {fileID: 21300000, guid: f5519e7426bdd9c4cad6bff3cf1cf8ea, type: 3}
- {fileID: 21300000, guid: 8ad840428d8880244b91fd3b4a9361d8, type: 3}
- {fileID: 21300000, guid: a549000bf49bea448a4ef7974dae0f77, type: 3}
- {fileID: 21300000, guid: ae6b707e6923db740bf951402be1f5b9, type: 3}
- {fileID: 21300000, guid: 19d82f4067d1af1408de81f955cbe089, type: 3}
- {fileID: 21300000, guid: 44a2dff2c17135548ab8f0f8a27f713a, type: 3}
- {fileID: 21300000, guid: 61fe923eb9a3dbd429100d52c6e25412, type: 3}
- {fileID: 21300000, guid: de05799b2b519514b873749f148df741, type: 3}
- {fileID: 21300000, guid: 49bbc088dd4ea8549902cb8c521ea1aa, type: 3}
- {fileID: 21300000, guid: eb32b8d3f2dc0c548980cd3ebb450a91, type: 3}
- {fileID: 21300000, guid: ef1220cfe5112214f876393e53e43c3f, type: 3}
- {fileID: 21300000, guid: fccff18ac2374f44abac11d709f5bb88, type: 3}
- {fileID: 21300000, guid: 5667e143a45d4c34e9b6466f5669fd5d, type: 3}
- {fileID: 21300000, guid: 00aa36c6e2ce34e4ebc2f819846d4d37, type: 3}
- {fileID: 21300000, guid: 280297d5aee7ee6499e888369caf526b, type: 3}
- {fileID: 21300000, guid: 2ca75f9185b832b49b47c9959f09e821, type: 3}
- {fileID: 21300000, guid: 70d80d7cc3e8cec48b0e74a9e5f6f174, type: 3}
- {fileID: 21300000, guid: 7bbd3a5d04044434196fd8800fd32fe6, type: 3}
- {fileID: 21300000, guid: e5ec8f85fdfbff24aa1478cd96df5213, type: 3}
image: {fileID: 2053001694}
Aintime: 50
myspritesIndex: 0
--- !u!1 &2064797687
GameObject:
m_ObjectHideFlags: 0

View File

@ -3,6 +3,8 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
//one sprites
public class SpriteAniation : MonoBehaviour
{
[Header("帧动画的图")]

View File

@ -0,0 +1,66 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[System.Serializable]
public class Mysprites
{
public List<Sprite> mysprites = new List<Sprite>();
}
public class SpriteAniationpro : MonoBehaviour
{
[Header("帧动画的图")]
public List<Mysprites> sprites;
[Header("播放动画的image")]
public Image image;
[Header("帧时间,单位毫秒默认100")]
public float Aintime=100f;
[Header("播放动画的编号")]
public int myspritesIndex=0;
private int index=0;
private Mysprites mysprites;
// Start is called before the first frame update
void Start()
{
if (image==null)
{
Debug.LogError("image is null");
}
if (sprites.Count==0)
{
Debug.LogError("sprites is not");
}
SetAni(myspritesIndex);
InvokeRepeating("ainstart", 0f,(Aintime / 1000));
}
public void SetAni(int Index)
{
//Debug.Log(Index);
mysprites = sprites[Index];
index = 0;
}
void ainstart()
{
Debug.Log(index);
image.overrideSprite = mysprites.mysprites[index];
index++;
if (index > mysprites.mysprites.Count - 1)
{
index = 0;
}
}
private void OnDestroy()
{
sprites = null;
mysprites = null;
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 4c6b440cf0a9d9b45bcb433ce72d557b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -13,7 +13,7 @@ public class Path
public class landContorl : MonoBehaviour
{
public GameObject fishManPrefab;
private GameObject fishMan;
public GameObject fishMan;
private shipcontorl fishManShipContorl;
public Transform startPos;
public Transform endPos;

View File

@ -148,7 +148,7 @@ public class landContorl_jinsha : MonoBehaviour
return;
}
Debug.Log(fishMan);
if (fishMan != null)
{
Promptmgr.Instance.PromptBubble("已经有船了", Color.black, Color.red);