public static void Reconstruct(Object psdFile, ImportUserData importSettings, ImportLayerData reconstructRoot, Vector2 documentPivot, IReconstructor reconstructor) { string psdPath = GetPsdFilepath(psdFile); if (string.IsNullOrEmpty(psdPath)) { return; } using (var psdDoc = PsdDocument.Create(psdPath)) { ReconstructData data = GetReconstructData(psdDoc, psdPath, documentPivot, importSettings, reconstructRoot); var GO = reconstructor.Reconstruct(reconstructRoot, data, Selection.activeGameObject); if (GO != null) { EditorGUIUtility.PingObject(GO); Selection.activeGameObject = GO; } } }
public void Initialise_capture(Device device) { this.device = device; var capturers = this.GetComponents<Capturer>(); if(capturers.Any()) { foreach(var capturer in capturers) { Destroy (capturer); } } switch(this.device) { case Device.MULTI_KINECT_WIMUS: this.capturer = this.gameObject.AddComponent<Kinect2Managing>(); this.calibrator = this.capturer is ICalibrator ? this.capturer as ICalibrator : null; this.syncer = this.capturer is ISyncer ? this.capturer as ISyncer : null; this.reconstructor = this.capturer is IReconstructor ? this.capturer as IReconstructor : null; this.recorder = CompositeRecorder.FromRecorders(this.capturer);//TODO: fusion capturer to be added here this.skeletonCapturer = new NoneSkeletonCapturer();//TODO: add fusion here break; case Device.SINGLE_KINECT_2: var k2controller = this.gameObject.AddComponent<Kinect2Controlling>(); k2controller.Streams = KinectStreams.Skeleton; k2controller.enabled = false;// re-enable k2controller.enabled = true; this.capturer = k2controller; this.exporter = GetComponent<SkeletonExporting>(); this.recorder = CompositeRecorder.FromRecorders(this.capturer); this.skeletonCapturer = FindObjectsOfType<Capturer>().First((cap) => cap is ISkeletonGenerator<SkeletonFrame>) as ISkeletonGenerator<SkeletonFrame>; break; } }
private void DrawReconstructor() { if (importSettings == null) { return; } EditorGUILayout.LabelField(labelUseConstructor, EditorStyles.boldLabel); ImportLayerData reconstructLayer = null; if (lastSelectedLayer != null) { reconstructLayer = GetLayerData(lastSelectedLayer); if (reconstructLayer != null && reconstructLayer.Childs.Count == 0) { reconstructLayer = null; } } selectedReconstructor = EditorGUILayout.Popup(labelSelConstructor, selectedReconstructor, dropdownReconstruct); SpriteAlignUI.DrawGUILayout(labelDocAlign, importSettings.DocAlignment, alignment => { importSettings.DocAlignment = alignment; if (alignment != SpriteAlignment.Custom) { importSettings.DocPivot = PsdImporter.AlignmentToPivot(alignment); } Repaint(); }); if (importSettings.DocAlignment == SpriteAlignment.Custom) { EditorGUI.indentLevel++; importSettings.DocPivot = EditorGUILayout.Vector2Field(labelDocPivot, importSettings.DocPivot); EditorGUI.indentLevel--; } bool canReconstruct = reconstructLayer != null; IReconstructor reconstructorInstance = null; if (canReconstruct) { if (selectedReconstructor > -1 && selectedReconstructor < reconstructors.Length) { reconstructorInstance = reconstructors[selectedReconstructor]; canReconstruct = reconstructorInstance.CanReconstruct(Selection.activeGameObject); } else { canReconstruct = false; } } if (canReconstruct) { string strButton = string.Format("Build {0} as {1}", reconstructLayer.name, reconstructorInstance.DisplayName); if (GUILayout.Button(strButton, bigButton)) { GetLayerData(lastSelectedLayer); PsdImporter.Reconstruct(importFile, importSettings, reconstructLayer, importSettings.DocPivot, reconstructorInstance); } } else { string helpMessage = "Select a layer group"; if (reconstructLayer != null && reconstructorInstance != null) { helpMessage = reconstructorInstance.HelpMessage; } EditorGUILayout.HelpBox(helpMessage, MessageType.Info); } }