mirror of
https://github.com/maxartz15/VertexAnimation.git
synced 2024-11-14 00:05:35 +01:00
50 lines
1.5 KiB
C#
50 lines
1.5 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace TAO.VertexAnimation
|
|
{
|
|
|
|
public class AnimatedPrefabSpawner : MonoBehaviour
|
|
{
|
|
public GameObject Prefab;
|
|
|
|
public Transform BottomLeftCorner;
|
|
|
|
public Transform Parent;
|
|
|
|
public int Width;
|
|
public int Height;
|
|
|
|
public float Distance;
|
|
|
|
[ContextMenu("Test")]
|
|
public void SetAllSeeds()
|
|
{
|
|
|
|
Vector3 currentPosition = BottomLeftCorner.position;
|
|
Vector3 startPosition = currentPosition;
|
|
for ( int i = 0; i < Width; i++ )
|
|
{
|
|
for ( int j = 0; j < Height; j++ )
|
|
{
|
|
GameObject instance = Instantiate( Prefab, Parent, true );
|
|
instance.transform.position = currentPosition;
|
|
currentPosition = new Vector3( currentPosition.x + Distance, currentPosition.y, currentPosition.z );
|
|
}
|
|
currentPosition = new Vector3( startPosition.x , currentPosition.y, currentPosition.z + Distance );
|
|
}
|
|
VA_AnimationLibraryComponentAuthoring[] vaAnimationLibraryComponentAuthorings = Parent.GetComponentsInChildren < VA_AnimationLibraryComponentAuthoring >();
|
|
|
|
foreach ( VA_AnimationLibraryComponentAuthoring authoring in vaAnimationLibraryComponentAuthorings )
|
|
{
|
|
var test = Guid.NewGuid().GetHashCode().ToString();
|
|
Debug.Log( test );
|
|
test = test.Substring( test.Length - 4 );
|
|
Debug.Log( UInt32.Parse( test ) );
|
|
authoring.Seed = UInt32.Parse( test );
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|