当前位置:网站首页>[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
}
}
边栏推荐
- 软件测试的培训机构靠谱吗
- 1.2-进制转换
- [阅读笔记]-2 通过朴素贝叶斯模型学习机器学习分类
- mmdetection3D---(1)
- 电工学数电部分自学笔记1.25
- Distinguish between the export of ES6 and the module.exports of nodejs
- [advanced C language] - Advanced pointer [i]
- 电工学自学笔记1.22
- [advanced C language] - function pointer
- [advanced C language] - analyze the storage of micro data in memory [i]
猜你喜欢
随机推荐
【p5.js学习笔记】鼠标交互事件
点云处理--voxel filter
Encapsulation, inheritance, polymorphism
[advanced C language] - Advanced pointer [i]
Interviewer: the actual record of algorithm question brushing.pdf I can't even answer it
[阅读笔记]-2 通过朴素贝叶斯模型学习机器学习分类
MySQL基本查询和运算符
Openpcd安装过程记录
On the non recursive and recursive implementation of finding the nth Fibonacci number respectively
【C语言笔记分享】字符函数和字符串函数(建议收藏)
电工学下册自学笔记1.23
电工学自学笔记1.22
【p5.js】实战练习——无规则对称
软件测试需求人才越来越多,走上测试道路的人却越来越少?
Complete MySQL interview questions (updated in succession)
ROS零散知识点及错误解决
小白如何零基础学习软件测试?
电工学自学笔记1.21
【p5.js】实战临摹——国际象棋盘
.net MVC的理解

![[advanced C language] - function pointer](/img/73/95380bb719f609e80de56985ed68fd.png)


![[C language note sharing] - dynamic memory management malloc, free, calloc, realloc, flexible array](/img/3f/35c9ff3be5c0ef781ffcb537287a20.png)



