当前位置:网站首页>[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
}
}
边栏推荐
- [阅读笔记]-2 通过朴素贝叶斯模型学习机器学习分类
- 电脑充不进去电的解决方法
- 软件测试和软件开发应该怎么选择?
- .net MVC的理解
- Database optimization -- deeply understand the underlying data structure and algorithm of MySQL index
- 电工学自学笔记1.20
- The difference between using switch in a loop and using break and continue after executing a condition
- mmdetection3d(3)---网络输出
- mmdetection3D---(1)
- QT编写串口助手
猜你喜欢
![[untitled]](/img/86/d284eec4eda6a41676d7455b7ea70b.png)
[untitled]

JVM performance tuning
![[C language must see] yo, writing bugs, I'm sure you've stepped on the pit](/img/0b/6f0faeb6896824ca94ce7ca983065a.jpg)
[C language must see] yo, writing bugs, I'm sure you've stepped on the pit

Collection collection

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

编译原理学习笔记1(编译原理概述与词法分析)

Database performance analysis and optimization (internal training materials of Aite future team)

R language drawing / drawing / drawing 2

In depth sharing of Ali (ant financial) technical interview process, with preliminary preparation and learning direction

2021 National Undergraduate data statistics and Analysis Competition
随机推荐
【C语言笔记分享】自定义类型:结构体,枚举,联合(建议收藏)
【Unity】Sprite九宫格到底怎么玩?
如何看软件测试未来的发展?
电工学数电部分自学笔记1.25
电工学自学笔记1.20
Factor in R
IDEA报错Error running ‘Application‘ Command line is too long解决方案
Technical aspects passed easily, HR: those with only three years of experience in large factories are not worth 20K
有奖征文 | 2022 云原生编程挑战赛征稿活动开启!
Database optimization -- deeply understand the underlying data structure and algorithm of MySQL index
电工学自学笔记1.21
Students' 20 R language exercises
ROS system installation
.net MVC understanding
leetcode系统性刷题(四)-----哈希表与字符串
【p5.js实战】我的自画像
电工学自学笔记1.22
ps快速制作全屏水印
[阅读笔记] For Paper:R-CNN系列的三篇论文总结
[C language note sharing] - dynamic memory management malloc, free, calloc, realloc, flexible array