private void GeneratePreview(int count, string previewLabel = "", T previewContent = default) { DestroyPreviews(); clone = Instantiate(renderer.gameObject, renderer.transform.parent); clone.name = $"{renderer.gameObject.name} Preview"; if (disposablePreview) { clone.hideFlags = HideFlags.HideInHierarchy; } DiskBase <T> cloneRenderer = clone.GetComponent <DiskBase <T> >(); cloneRenderer.SetContentDictionary(new UnitContentDictionary <T>(previewContent)); Model.Wheel wheel = Model.Wheel.Create(); for (int i = 0; i < count; i++) { string label = previewLabel == "" ? Lipsum.Next : previewLabel; wheel.AddSlot(Model.Wheel.Create(name: label)); } cloneRenderer.SetWheel(wheel); }
private void Awake() { renderer = target as DiskBase <T>; Undo.undoRedoPerformed += () => { DestroyPreviews(); renderer.SetPegTransform(); renderer.SetPegSize(); }; }
protected override Int32 Execute() { try { var fileName = _commandLineParser.GetOptionString("o", "output", null); var firstSector = (UInt64)_commandLineParser.GetOptionInt("s", -1); var numberOfSectors = (UInt32)_commandLineParser.GetOptionInt("n", 1); if (firstSector < 0) { Help(); } String deviceName = null; if (1 == _commandLineParser.FileNames.Length) { deviceName = _commandLineParser.FileNames[0]; } else if (_commandLineParser.OptionHasValue("p")) { deviceName = _commandLineParser.GetOptionString("p"); } else if (_commandLineParser.OptionHasValue("l")) { deviceName = _commandLineParser.GetOptionString("l"); } else { return(Help()); } var disk = DiskBase.GetDisk(deviceName, true); disk.ReadDiskInformation(); Byte[] buffer = new Byte[65536]; // 64KB at once var fullSize = numberOfSectors * disk.BytesPerSector; var numberOfFullChunks = fullSize / buffer.Length; var offset = disk.SectorToOffset(firstSector); using (Stream stream = GetStream(fileName, buffer.Length, offset)) { for (int i = 0; i < numberOfFullChunks; i++) { disk.Read(offset, (UInt32)buffer.Length, ref buffer, true); stream.Write(buffer, 0, buffer.Length); offset += buffer.Length; } var size = fullSize % buffer.Length; // remaining part if (size > 0) { disk.Read(offset, (UInt32)size, ref buffer, true); stream.Write(buffer, 0, (Int32)size); } } return(0); } catch (Exception ex) { Print("Error reading sectors: {0}", ex.Message); return(1); } }