11
This commit is contained in:
35
Assets/Artists/Scripts/ReplaceModel.cs
Normal file
35
Assets/Artists/Scripts/ReplaceModel.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user