当前位置:网站首页>[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
}
}
边栏推荐
猜你喜欢

Technical aspects passed easily, HR: those with only three years of experience in large factories are not worth 20K

【p5.js学习笔记】局部变量(let)与全局变量(var)声明

MySQL的安装

【C语言笔记分享】自定义类型:结构体,枚举,联合(建议收藏)
![[untitled]](/img/86/d284eec4eda6a41676d7455b7ea70b.png)
[untitled]

2021 National Undergraduate data statistics and Analysis Competition

Encapsulation, inheritance, polymorphism

内部类、常用类

MySQL面试题大全(陆续更新)

如何安装ps的滤镜插件
随机推荐
ROS零散知识点及错误解决
禅道项目管理软件,敏捷开发团队不可或缺的工具
[阅读笔记] For:Object Detection with Deep Learning: The Definitive Guide
PyTorch中grid_sample的使用方法
软件测试的培训机构靠谱吗
QT编写串口助手
2.2-数据类型
[advanced C language] - function pointer
Vscode intranet access server
An article takes you closer to the overview and principle of kubernetes
【p5.js实战】我的自画像
es6 Promise
如何使用IDEA将项目上传到码云
2021 National Undergraduate data statistics and Analysis Competition
1.2-进制转换
R language sub() usage
[C language must see] yo, writing bugs, I'm sure you've stepped on the pit
MySQL面试题大全(陆续更新)
DOS command Daquan basic command + network common command
内部类、常用类