override public GrabWidget Clone() { StencilWidget clone = Instantiate(WidgetManager.m_Instance.GetStencilPrefab(this.Type)); clone.transform.position = transform.position; clone.transform.rotation = transform.rotation; clone.m_SkipIntroAnim = true; // We want to lie about our intro transition amount. clone.m_ShowTimer = clone.m_ShowDuration; clone.transform.parent = transform.parent; clone.Show(true, false); clone.SetSignedWidgetSize(this.m_Size); clone.CloneInitialMaterials(this); clone.Extents = this.Extents; HierarchyUtils.RecursivelySetLayer(clone.transform, gameObject.layer); CanvasScript canvas = transform.parent.GetComponent <CanvasScript>(); if (canvas != null) { var materials = clone.GetComponentsInChildren <Renderer>().SelectMany(x => x.materials); foreach (var material in materials) { foreach (string keyword in canvas.BatchManager.MaterialKeywords) { material.EnableKeyword(keyword); } } } return(clone); }
public static void FromGuideIndex(Guides guide) { StencilType stencilType = guide.Type; foreach (var state in guide.States) { StencilWidget stencil = Instantiate( WidgetManager.m_Instance.GetStencilPrefab(stencilType)); stencil.m_SkipIntroAnim = true; stencil.transform.parent = App.Instance.m_CanvasTransform; try { stencil.SaveState = state; } catch (ArgumentException e) { Debug.LogException(e, stencil); } stencil.Show(true, false); } }