当前位置:网站首页>[unity] timeline learning notes (VII): Custom clip
[unity] timeline learning notes (VII): Custom clip
2022-07-28 17:48:00 【Zhigan doctrine circle Maojun】
One // Inherit PlayableAsset class , Realization ITimelineClipAsset Interface
just as Custom track (Track) Need to inherit TrackAsset Class like that , Custom clips (Clip) Also follow certain templates : Inherit PlayableAsset class , And realize ITimelineClipAsset Interface .
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
public class LearnClip : PlayableAsset, ITimelineClipAsset
{
}After writing the head of the class , There will be Red corrugated line Prompt us to make mistakes .
Shortcut key Alt + Enter After fixing the error , There will be one more attribute in the code (Property) And methods (Function).
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
public class LearnClip : PlayableAsset, ITimelineClipAsset
{
public ClipCaps clipCaps
{// ITimelineClipAsset Implementation requirements of the interface
get
{
throw new System.NotImplementedException();
}
}
public override Playable CreatePlayable(PlayableGraph graph, GameObject owner)
{// PlayableAsset Class inheritance requirements
throw new System.NotImplementedException();
}
}
Two // ClipsCaps attribute
Don't panic when you meet a strange name , To look at first ClipCaps Of file .

You can see ,ClipCaps The content in is And Clip Related operations , Friends who are not impressed can see This article .
When we write
when ,
The content of the clip in the inspector is like this ——

【 Add a very important point , Because these parameters need to be adjustable in the inspection window , So it should be Add... To this class Serializable attribute 】
And when we write
when ,
The content of the inspection window is much less ——

therefore ClipCaps Is that : The allowed functions will be available in Inspector Edited , These functions are related to Clip Related operations .
3、 ... and // CreatPlayable Method
\
CreatePlayable Methods cannot be seen alone , But its general meaning is Create a Playable, Then insert into PlayableGraph.
It has two parameters :graph Indicates what to insert Graph;owner Is created Playable The source of the .
Four // PlayableBehaviour And ScriptPlayable
All user-defined Playable Must inherit from PlayableBehaviour class , In the script of the custom fragment , It needs to go with ScriptPlayable Use .
So a custom Clip The framework of the script is basically like the following code :
using System;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
[Serializable] // serialize
public class DialogueClip : PlayableAsset, ITimelineClipAsset
{
public DialogueBehaviour template = new DialogueBehaviour (); // Generally, variables are named template
public ClipCaps clipCaps
{// The adjustable function of the inspection window
get { return ClipCaps.None; }
}
public override Playable CreatePlayable (PlayableGraph graph, GameObject owner)
{// establish Playable
var playable = ScriptPlayable<DialogueBehaviour>.Create (graph, template); // Really used to create Playable The sentence of
//... There can also be some assignment operations ...//
return playable; // Return to the created Playable,Clip Script task completed
}
}
边栏推荐
猜你喜欢

PCA reports error in eigen (crossprod (t (x), t (x)), symmetric = true): 'x' has infinite value or missing value

【C语言必看】哟写BUG呢,我敢保证你踩过坑

JVM performance tuning

Collection collection

Sql Server STUFF与FOR XML PATH
@RequestMapping详解

R language drawing / drawing / drawing 2

Encapsulation, inheritance, polymorphism
![[untitled]](/img/86/d284eec4eda6a41676d7455b7ea70b.png)
[untitled]

关于非递归和递归分别实现求第n个斐波那契数
随机推荐
点云处理---kd-tree
Collection collection
编译原理学习笔记3(自上而下语法分析)
怎样将IDEA与码云进行绑定
域名解析问题记录
Alibaba P8 architect talk: seven knowledge points (including interview questions) that must be learned well to become an architect
图像处理代码整理
ROS零散知识点及错误解决
Map R language
The difference between using switch in a loop and using break and continue after executing a condition
软件测试培训需要多久?
Jerry ac692x --- matrix keyboard addition
2022 IDEA (学生邮箱认证)安装使用教程以及基础配置教程
软件测试就业前景怎么样?
Use of multithreading
Ros自定义消息及使用
ROS系统安装
abstract、static、final
【C语言进阶】——指针进阶[Ⅰ]
1.2-进制转换