public static Cursor GetCursorForTransformHandle(TransformHandle handle) { switch (handle) { case TransformHandle.None: return(Cursors.Default); case TransformHandle.TopLeft: return(Cursors.SizeNWSE); case TransformHandle.TopCenter: return(Cursors.SizeNS); case TransformHandle.TopRight: return(Cursors.SizeNESW); case TransformHandle.Left: return(Cursors.SizeWE); case TransformHandle.Right: return(Cursors.SizeWE); case TransformHandle.BottomLeft: return(Cursors.SizeNESW); case TransformHandle.BottomCenter: return(Cursors.SizeNS); case TransformHandle.BottomRight: return(Cursors.SizeNWSE); default: return(Cursors.Default); } }
public static void TransformGetWorldPosition(TransformHandle handle, ref Vector3 pos) { fixed(Vector3 *native_pos = &pos) { TransformGetWorldPosition(handle, native_pos); } }
internal virtual async Task <MediaPacket> ApplyAsync(MediaPacket source) { using (TransformHandle handle = CreateHandle()) { Configure(handle); return(await RunAsync(handle, source)); } }
private void DoCutObjectPicking() { var mousePos = Event.current.mousePosition; Ray CameraRay = Camera.main.ScreenPointToRay(new Vector3(mousePos.x, Screen.height - mousePos.y, 0)); RaycastHit hit; // If we hit an object if (Physics.Raycast(CameraRay, out hit, 1000)) { var cutObject = hit.collider.gameObject.GetComponent <CutObject>(); var transformHandle = hit.collider.gameObject.GetComponent <TransformHandle>(); // If we hit a new selectable object if (cutObject && transformHandle && transformHandle != _selectedTransformHandle) { if (_selectedTransformHandle != null) { //Debug.Log("Reset"); _selectedTransformHandle.Disable(); } Debug.Log("Selected transform: " + transformHandle.gameObject.name); if (SelectionGameObject && SelectionGameObject.GetComponent <TransformHandle>()) { SelectionGameObject.GetComponent <TransformHandle>().Disable(); } transformHandle.Enable(); transformHandle.SetSelectionState(_currentState); _selectedTransformHandle = transformHandle; if (_mainCameraController == null) { _mainCameraController = GameObject.FindObjectOfType <MainCameraController>(); } _mainCameraController.TargetTransform = hit.collider.gameObject.transform; //MainCamera.main.GetComponent<NavigateCamera>().TargetGameObject = hit.collider.gameObject; } // If we hit a non-selectable object else if (transformHandle == null && _selectedTransformHandle != null) { //Debug.Log("Missed hit"); _selectedTransformHandle.Disable(); _selectedTransformHandle = null; } } // If we miss a hit else if (_selectedTransformHandle != null) { //Debug.Log("Missed hit"); _selectedTransformHandle.Disable(); _selectedTransformHandle = null; } }
public static string TransformGetName(TransformHandle handle) { var name = TransformGetNameNative(handle); string namestr; unsafe { namestr = new string((sbyte *)name); } return(namestr); }
public static void SizeElement(LayoutElement layoutElement, TransformHandle transformHandle, Point interactionLocation, Size interactionSize, Point viewportLocation, Point designAreaDownLocation, Point designAreaMoveLocation) { switch (transformHandle) { case TransformHandle.None: break; case TransformHandle.TopLeft: break; case TransformHandle.TopCenter: break; case TransformHandle.TopRight: break; case TransformHandle.Left: break; case TransformHandle.Right: break; case TransformHandle.BottomLeft: break; case TransformHandle.BottomCenter: break; case TransformHandle.BottomRight: layoutElement.Size = new Size(viewportLocation.X - designAreaMoveLocation.X - interactionLocation.X, viewportLocation.Y - designAreaMoveLocation.Y - interactionLocation.Y); break; default: break; } }
internal async Task <MediaPacket> RunAsync(TransformHandle handle, MediaPacket source) { Debug.Assert(source.Format is VideoMediaFormat); ValidateFormat(source.Format as VideoMediaFormat); var tcs = new TaskCompletionSource <MediaPacket>(); using (var cbKeeper = ObjectKeeper.Get(GetCallback(tcs, source))) { var result = NativeTransform.Run(handle, source.GetHandle(), cbKeeper.Target); if (result == ImageUtilError.NotSupportedFormat) { throw new NotSupportedException( GenerateNotSupportedErrorMessage(source.Format as VideoMediaFormat)); } result.ThrowIfFailed("Failed to transform given packet with " + GetType()); return(await tcs.Task); } }
internal override async Task <MediaPacket> ApplyAsync(MediaPacket source) { using (TransformHandle handle = CreateHandle()) { if (Flip.HasFlag(Flips.Vertical | Flips.Horizontal)) { var flipped = await ApplyAsync(handle, source, ImageRotation.FlipHorizontal); try { return(await ApplyAsync(handle, flipped, ImageRotation.FlipVertical)); } finally { flipped.Dispose(); } } return(await ApplyAsync(handle, source, Flip.HasFlag(Flips.Horizontal)? ImageRotation.FlipHorizontal : ImageRotation.FlipVertical)); } }
public void SetSelectedObject(int instanceID) { if (!ValidateInstanceID(_selectedObjectID)) return; Debug.Log("Selected element id: " + instanceID); if (instanceID > 0) Debug.Log("Selected element type: " + SceneManager.Get.ProteinInstanceInfos[instanceID].x); if (instanceID >= SceneManager.Get.ProteinInstancePositions.Count) return; // If element id is different than the currently selected element if (_selectedObjectID != instanceID) { // if new selected element is greater than one update set and set position to game object if (instanceID > -1 ) { if (_ctrlKeyFlag) { float radius = SceneManager.Get.ProteinRadii[(int)SceneManager.Get.ProteinInstanceInfos[instanceID].x] * PersistantSettings.Instance.Scale; SelectionGameObject.GetComponent<SphereCollider>().radius = radius; SelectionGameObject.transform.position = SceneManager.Get.ProteinInstancePositions[instanceID] * PersistantSettings.Instance.Scale; SelectionGameObject.transform.rotation = MyUtility.Vector4ToQuaternion(SceneManager.Get.ProteinInstanceRotations[instanceID]); // Enable handle SelectionGameObject.GetComponent<TransformHandle>().Enable(); //Camera.main.GetComponent<NavigateCamera>().TargetGameObject = SelectionGameObject; if (controller == null) { controller = GameObject.FindObjectOfType<CameraController>(); } controller.TargetTransform = SelectionGameObject.transform; if (_selectedTransformHandle) { _selectedTransformHandle.Disable(); _selectedTransformHandle = null; } _ctrlKeyFlag = false; _selectedObjectID = instanceID; _selectedTransformHandle = SelectionGameObject.GetComponent<TransformHandle>(); #if UNITY_EDITOR Selection.activeGameObject = SelectionGameObject; #endif } } else { // Disable handle SelectionGameObject.GetComponent<TransformHandle>().Disable(); _selectedObjectID = instanceID; } } }
public void SetHandleSelected(TransformHandle handle) { handle.Enable(); handle.SetSelectionState(_currentState); _selectedTransformHandle = handle; }
internal static extern ImageUtilError SetCropArea(TransformHandle handle, int startX, int startY, int endX, int endY);
internal static extern ImageUtilError SetResolution(TransformHandle handle, uint width, uint height);
internal static extern ImageUtilError SetHardwareAcceleration(TransformHandle handle, bool mode);
internal static extern ImageUtilError SetRotation(TransformHandle handle, ImageRotation rotation);
public static extern void TransformGetWorldPosition(TransformHandle handle, Vector3 *pos);
internal abstract void Configure(TransformHandle handle);
internal override void Configure(TransformHandle handle) { // intended blank }
// This gets called from CutObject.SetHidden() so that's why you need to keep _currentState and _selectedTransformHandle updated in here (it's kinda stupid...) public void SetHandleSelected(TransformHandle handle) { handle.Enable(); handle.SetSelectionState(_currentState); _selectedTransformHandle = handle; }
internal override void Configure(TransformHandle handle) { SetColorspace(handle, _imageColorSpace); }
public static extern IntPtr TransformGetNativeByHandle(TransformHandle handle);
public static extern byte *TransformGetNameNative(TransformHandle handle);
private void DoCutObjectPicking() { var mousePos = Event.current.mousePosition; Ray CameraRay = Camera.main.ScreenPointToRay(new Vector3(mousePos.x, Screen.height - mousePos.y, 0)); RaycastHit hit; // If we hit an object if (Physics.Raycast(CameraRay, out hit, 1000)) { var cutObject = hit.collider.gameObject.GetComponent<CutObject>(); var transformHandle = hit.collider.gameObject.GetComponent<TransformHandle>(); // If we hit a new selectable object if (cutObject && transformHandle && transformHandle != _selectedTransformHandle) { if (_selectedTransformHandle != null) { //Debug.Log("Reset"); _selectedTransformHandle.Disable(); } Debug.Log("Selected transform: " + transformHandle.gameObject.name); if (SelectionGameObject && SelectionGameObject.GetComponent<TransformHandle>()) { SelectionGameObject.GetComponent<TransformHandle>().Disable(); } transformHandle.Enable(); transformHandle.SetSelectionState(_currentState); _selectedTransformHandle = transformHandle; if (_cameraController == null) _cameraController = GameObject.FindObjectOfType<CameraController>(); _cameraController.TargetTransform = hit.collider.gameObject.transform; //Camera.main.GetComponent<NavigateCamera>().TargetGameObject = hit.collider.gameObject; } // If we hit a non-selectable object else if (transformHandle == null && _selectedTransformHandle != null) { //Debug.Log("Missed hit"); _selectedTransformHandle.Disable(); _selectedTransformHandle = null; } } // If we miss a hit else if (_selectedTransformHandle != null) { //Debug.Log("Missed hit"); _selectedTransformHandle.Disable(); _selectedTransformHandle = null; } }
public static extern TransformHandle TransformFindChildByIndex(TransformHandle handle, int index);
public void SetSelectedObject(int instanceID) { if (instanceID >= CPUBuffers.Get.ProteinInstancePositions.Count) { return; } Debug.Log("*****"); //if (!ValidateInstanceID(_selectedObjectID)) return; Debug.Log("Selected element id: " + instanceID); if (instanceID >= CPUBuffers.Get.ProteinInstancePositions.Count) { return; } if (instanceID > 0) { Debug.Log("Selected element type: " + CPUBuffers.Get.ProteinInstanceInfos[instanceID].x); } if (instanceID > 0) { Debug.Log("Selected element name: " + SceneManager.Get.ProteinIngredientNames[(int)CPUBuffers.Get.ProteinInstanceInfos[instanceID].x]); } // If element id is different than the currently selected element if (_selectedObjectID != instanceID) { // if new selected element is greater than one update set and set position to game object if (instanceID > -1) { if (_ctrlKeyFlag) { float radius = CPUBuffers.Get.ProteinIngredientsRadii[(int)CPUBuffers.Get.ProteinInstanceInfos[instanceID].x] * GlobalProperties.Get.Scale; SelectionGameObject.GetComponent <SphereCollider>().radius = radius; SelectionGameObject.transform.position = CPUBuffers.Get.ProteinInstancePositions[instanceID] * GlobalProperties.Get.Scale; SelectionGameObject.transform.rotation = MyUtility.Vector4ToQuaternion(CPUBuffers.Get.ProteinInstanceRotations[instanceID]); // Enable handle SelectionGameObject.GetComponent <TransformHandle>().Enable(); //MainCamera.main.GetComponent<NavigateCamera>().TargetGameObject = SelectionGameObject; if (controller == null) { controller = GameObject.FindObjectOfType <MainCameraController>(); } controller.TargetTransform = SelectionGameObject.transform; if (_selectedTransformHandle) { _selectedTransformHandle.Disable(); _selectedTransformHandle = null; } _ctrlKeyFlag = false; _selectedObjectID = instanceID; _selectedTransformHandle = SelectionGameObject.GetComponent <TransformHandle>(); #if UNITY_EDITOR Selection.activeGameObject = SelectionGameObject; #endif } } else { // Disable handle SelectionGameObject.GetComponent <TransformHandle>().Disable(); _selectedObjectID = instanceID; } } }
public static extern void TransformSetActive(TransformHandle handle, string name);
internal override void Configure(TransformHandle handle) { NativeTransform.SetCropArea(handle, Region.Left, Region.Top, Region.Right, Region.Bottom); }
public static extern SceneNative.ActiveOption TransformGetActive(TransformHandle handle);
private async Task <MediaPacket> ApplyAsync(TransformHandle handle, MediaPacket source, ImageRotation rotation) { SetRotation(handle, rotation); return(await RunAsync(handle, source)); }
internal static extern ImageUtilError Run(TransformHandle handle, IntPtr srcPacket, TransformCompletedCallback callback, IntPtr userData = default(IntPtr));
internal override void Configure(TransformHandle handle) { NativeTransform.SetResolution(handle, (uint)Size.Width, (uint)Size.Height); }
internal static extern ImageUtilError Create(out TransformHandle handle);
internal static extern ImageUtilError SetColorspace(TransformHandle handle, ImageColorSpace colorspace);
public static extern void TransformMove(TransformHandle who, TransformHandle to);