//Replace internal frame public MaterialFrame SetFrame(MaterialFrame frame, bool inflate) { if (frame == null) { return(null); } var anchoredPosition = frame.transform is RectTransform ? (frame.transform as RectTransform).anchoredPosition3D : frame.transform.localPosition; var localScale = frame.transform.localScale; var localRotation = frame.transform.localRotation; //Is a prefab if (!frame.transform.root.gameObject.scene.IsValid()) { frame = GameObject.Instantiate(frame); } //Delete Default Frame if (m_Frame != null && m_Frame != frame) { GameObject.Destroy(m_Frame.gameObject); } //MaterialDialogActivity does not support activities in same object as the frame added var frameActivity = frame.GetComponent <MaterialActivity>(); if (frameActivity != null) { Component.DestroyImmediate(frameActivity); } frame.transform.SetParent(this.transform, false); m_Frame = frame; if (frame is MaterialDialogFrame) { (frame as MaterialDialogFrame).activity = this; } if (inflate) { Inflate(frame.transform as RectTransform, false); } else { if (frame.transform is RectTransform) { (frame.transform as RectTransform).anchoredPosition3D = anchoredPosition; } else { frame.transform.localPosition = anchoredPosition; } frame.transform.localScale = localScale; frame.transform.localRotation = localRotation; } m_Frame.transform.SetAsLastSibling(); return(frame); }
public MaterialFrame SetFrame(MaterialFrame frame) { if (frame == null) { return(null); } //Is a prefab if (!frame.transform.root.gameObject.scene.IsValid()) { frame = GameObject.Instantiate(frame); } //Delete Default Frame if (m_Frame != null && m_Frame != frame) { GameObject.Destroy(m_Frame.gameObject); } //MaterialDialogActivity does not support activities in same object as the frame added var frameActivity = frame.GetComponent <MaterialActivity>(); if (frameActivity != null) { Component.DestroyImmediate(frameActivity); } frame.transform.SetParent(this.transform, false); m_Frame = frame; if (frame is MaterialDialogFrame) { (frame as MaterialDialogFrame).activity = this; } m_Frame.transform.SetAsLastSibling(); return(frame); }