36 lines
922 B
C#
36 lines
922 B
C#
|
using System;
|
||
|
using System.Collections;
|
||
|
using System.Collections.Generic;
|
||
|
using Dreamteck.Splines.Primitives;
|
||
|
using UnityEngine;
|
||
|
using Object = System.Object;
|
||
|
using Random = UnityEngine.Random;
|
||
|
|
||
|
namespace Net.Like.Xue.Tokyo
|
||
|
{
|
||
|
public class ReplaceModel : MonoBehaviour
|
||
|
{
|
||
|
[SerializeField] private Animator animator;
|
||
|
[SerializeField] private Transform[] models;
|
||
|
|
||
|
private void Start()
|
||
|
{
|
||
|
for (var i = 0; i < transform.childCount; i++)
|
||
|
{
|
||
|
DestroyImmediate(transform.GetChild(0));
|
||
|
}
|
||
|
|
||
|
var index = Random.Range(0, transform.childCount);
|
||
|
var newModel =models[index];
|
||
|
newModel = Instantiate(newModel, transform);
|
||
|
if (newModel.TryGetComponent<Animator>(out var x))
|
||
|
{
|
||
|
DestroyImmediate(x);
|
||
|
}
|
||
|
|
||
|
animator.Rebind();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|