Объявление
public bool Connect(U source, int sourceOutputPort, V destination, int destinationInputPort);Параметры
source | Исходный playable или его дескриптор. |
sourceOutputPort | Порт, используемый в исходном воспроизводимом файле. |
destination | Пункт назначения playable или его дескриптор. |
destinationInputPort | Порт, используемый в целевом воспроизводимом файле. |
Возвращает
bool возвращает значение true, если соединение установлено успешно.
Описание
Соединяет два экземпляра Playable.
Соединения определяют топологию PlayableGraph и способ ее оценки.
Игровые объекты можно объединять в древовидную структуру. Каждый Playable имеет набор входов и набор выходов. Их можно рассматривать как «слоты», к которым можно прикреплять другие Playables.
Когда Playable создается впервые, его счетчик входных данных сбрасывается до 0, что означает, что к нему не подключены дочерние Playable. Выходы ведут себя немного по-другому — каждый Playable имеет выход по умолчанию, созданный при первом создании.
Вы соединяете Playables вместе, используя метод PlayableGraph.Connect, и вы можете отключить их друг от друга, используя PlayableGraph.Disconnect.
There is no limit set on the amount of inputs a Playable can have.
using UnityEngine;
using UnityEngine.Animations;
using UnityEngine.Playables;
public class GraphCreationSample : MonoBehaviour
{
PlayableGraph m_Graph;
public AnimationClip clipA;
public AnimationClip clipB;
void Start()
{
// Create the PlayableGraph.
m_Graph = PlayableGraph.Create();
// Add an AnimationPlayableOutput to the graph.
var animOutput = AnimationPlayableOutput.Create(m_Graph, "AnimationOutput", GetComponent<Animator>());
// Add an AnimationMixerPlayable to the graph.
var mixerPlayable = AnimationMixerPlayable.Create(m_Graph, 2, false);
// Add two AnimationClipPlayable to the graph.
var clipPlayableA = AnimationClipPlayable.Create(m_Graph, clipA);
var clipPlayableB = AnimationClipPlayable.Create(m_Graph, clipB);
// Create the topology, connect the AnimationClipPlayable to the
// AnimationMixerPlayable.
m_Graph.Connect(clipPlayableA, 0, mixerPlayable, 0);
m_Graph.Connect(clipPlayableB, 0, mixerPlayable, 1);
// Use the AnimationMixerPlayable as the source for the AnimationPlayableOutput.
animOutput.SetSourcePlayable(mixerPlayable);
// Set the weight for both inputs of the mixer.
mixerPlayable.SetInputWeight(0, 1);
mixerPlayable.SetInputWeight(1, 1);
// Play the graph.
m_Graph.Play();
}
private void OnDestroy()
{
// Destroy the graph once done with it.
m_Graph.Destroy();
}
}