OnionLayer GetOnionLayer(int frame, AnimationClip clip) { OnionLayer l_onionLayer = null; if (!m_OnionLayers.TryGetValue(frame, out l_onionLayer)) { l_onionLayer = m_OnionLayerPool.Get(); if (!l_onionLayer.previewInstance) { l_onionLayer.previewInstance = m_GameObjectPool.Get(); } l_onionLayer.previewInstance.transform.position = source.transform.position; l_onionLayer.previewInstance.transform.rotation = source.transform.rotation; l_onionLayer.previewInstance.transform.localScale = source.transform.localScale; l_onionLayer.previewInstance.SetActive(true); l_onionLayer.SetFrame(frame, clip); m_OnionLayers.Add(frame, l_onionLayer); } return(l_onionLayer); }
void ReturnOnionLayers(int minFrame, int maxFrame, int step) { List <KeyValuePair <int, OnionLayer> > l_returnOnionLayers = new List <KeyValuePair <int, OnionLayer> >(); if (minFrame <= maxFrame && step > 0) { foreach (KeyValuePair <int, OnionLayer> pair in m_OnionLayers) { if (pair.Key < minFrame || pair.Key > maxFrame || pair.Key % step != 0) { l_returnOnionLayers.Add(pair); } } foreach (KeyValuePair <int, OnionLayer> pair in l_returnOnionLayers) { OnionLayer onionLayer = pair.Value; int frame = pair.Key; onionLayer.previewInstance.SetActive(false); m_OnionLayerPool.Return(onionLayer); m_OnionLayers.Remove(frame); } } }
public void ResampleOnionLayers(AnimationClip clip) { if (!AnimationMode.InAnimationMode()) { return; } foreach (KeyValuePair <int, OnionLayer> pair in m_OnionLayers) { OnionLayer onionLayer = pair.Value; int frame = pair.Key; onionLayer.previewInstance.transform.position = source.transform.position; onionLayer.previewInstance.transform.rotation = source.transform.rotation; onionLayer.previewInstance.transform.localScale = source.transform.localScale; pair.Value.SetFrame(frame, clip); } }