0
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AnimationCamera : MonoBehaviour
{
public Camera animationCamera;
public Camera mainCamera;
Animator _anim;
List<string> animations = new List<string>();
private void Start()
{
animationCamera.enabled = false;
mainCamera.enabled = true;
_anim = GetComponent<Animator>();
foreach (AnimationClip ac in _anim.runtimeAnimatorController.animationClips)
{
animations.Add(ac.name + " " + ac.length.ToString());
}
int cliptoplay = animations[0].IndexOf(" ");
string clip = animations[0].Substring(0, cliptoplay);
}
最後在變量字符串剪輯我得到的名字。 而在列表動畫我有每個剪輯的長度。我如何讓List成爲屬性?
但我不知道我是否可以做這樣的事情,如果我只會在代碼中輸入visual studio:clip。 並在點(剪輯)後,我將有一個每個剪輯名稱的選項列表和它的長度。例如,如果我鍵入今天的動畫。我得到的屬性列表如下:動畫。添加或動畫。插入或動畫。索引
我想要做的是創建一些,所以如果我將鍵入剪輯。我將得到所有剪輯名稱和長度的列表,例如:Clip.anim_001_length_10或Clip.myanim_length_21
所以如果我想稍後使用它,將會更容易找到您要使用的剪輯。
答案是否定的,你不能,因爲剪輯是字符串類型,並且值來自'animations'這是一個字符串列表。此外,值不能成爲屬性。屬性只是包含這些值的變量。你的榜樣無法實現。你可以做的是將'動畫'的類型改爲'AnimationClip'的列表,而不是獲取一個'字符串剪輯',你可以獲取一個'AnimationClip剪輯'。通過這樣做,您可以訪問「名稱」和「長度」屬性。 –