예제 #1
0
        public void DestroyPreviewPrefab()
        {
            if (previewPrefab == null)
            {
                return;
            }

            PrefabPainter.DestroyImmediate(previewPrefab.prefabInstance);

            previewPrefab.prefabInstance = null;
            previewPrefab.prefabSettings = null;
            previewPrefab = null;
        }
예제 #2
0
        public void CreatePreviewPrefab()
        {
            if (!this.editorTarget.HasPrefab())
            {
                return;
            }

            if (previewPrefab != null)
            {
                DestroyPreviewPrefab();
            }

            previewPrefab = new PreviewPrefab();

            previewPrefab.prefabSettings = this.editorTarget.CreatePrefabSettings();
            previewPrefab.prefabInstance = PrefabUtility.InstantiatePrefab(previewPrefab.prefabSettings.prefab) as GameObject;

            // attach as root
            // as child of container it would be removed on "clear"
            // as child of editortarget it would show navigation handles
            // => root it is
            previewPrefab.prefabInstance.transform.parent = null;

            // move to bottom
            previewPrefab.prefabInstance.transform.SetAsLastSibling();

            // hide in hierarchy
            // TODO: activate. leaving it visible for the time being
            // previewPrefab.prefabInstance.hideFlags = HideFlags.HideInHierarchy;

            previewPrefab.prefabInstance.name = "Preview Prefab [Yapp Temp]";

            // set the layer index for the preview prefab. we need to ignore it in the brush raycast or else there'd be an endless loop
            // with the preview prefab coming close to the camera consistently
            LayerUtils.SetLayer(previewPrefab.prefabInstance.transform, (int)LayerUtils.LayerIndex.IgnoreRaycast);
        }