Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. [ExecuteInEditMode]
  6. public class PieceSpriteRandomiser : MonoBehaviour {
  7.  
  8.     public List<Transform> ObjectPieces = new List<Transform>();
  9.  
  10.     void Awake()
  11.     {
  12.  
  13.     }
  14.  
  15.     void OnEnable()
  16.     {
  17.         foreach (var item in ObjectPieces)
  18.         {
  19.             var otherRandomPiece = ObjectPieces[Random.Range (0, ObjectPieces.Count - 1)];
  20.             var currentPiecePrevPosition = item.position;
  21.             item.position = otherRandomPiece.position;
  22.             otherRandomPiece.position = currentPiecePrevPosition;
  23.         }
  24.     }
  25. }