1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
using System; using UnityEngine; using System.Collections; using System.Collections.Generic; using SimpleJSON; namespace tomotomo { public class SwapATOM : MVRScript { #region PluginInfo public string pluginAuthor = "tomotomo"; public string pluginName = "SwapAtomPositionRotation"; public string pluginVersion = "0.1"; public string pluginDate = "2019/12/12"; public string pluginDescription = @" This plugin allows you to swap the position and rotation of selected 2 ATOMs."; #endregion #region Vars protected JSONStorableString cstring; protected JSONStorableString pstring; private Vector3 CurrentPosition; private Quaternion CurrentRotation; protected FreeControllerV3 CurrentController; protected FreeControllerV3 ControllerA; protected FreeControllerV3 ControllerB; protected Atom CurrentAtom; #endregion #region Init public override void Init() { try { pluginLabelJSON.val = "Swap ATOMs"; cstring = new JSONStorableString("Selected", ""); UIDynamic dtext = CreateTextField(cstring); dtext.height = 50f; JSONStorableString istring = new JSONStorableString("Instructions", "INSTRUCTIONS:\nSelect an ATOM and [Ctrl] + [J]." + "\nSelect another ATOM and [Ctrl] + [K]." + "\nand [Ctrl] + [L]\nThen the position and rotation of 2 ATOMs are swapped."); UIDynamic itext = CreateTextField(istring, true); itext.height = 220f; pstring = new JSONStorableString("Current Atom", ""); //UIDynamic atext = CreateTextField(pstring, true); UIDynamic atext = CreateTextField(pstring); atext.height = 50f; } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } } #endregion #region Update void Update() { try { AtomSelected(); if ((Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl)) && CurrentController != null) { if (Input.GetKeyDown(KeyCode.J) ) { ControllerA = SuperController.singleton.GetSelectedController(); CurrentAtom = SuperController.singleton.GetSelectedAtom(); pstring.val = CurrentAtom.name.ToString() + " (" + CurrentController.name.ToString() + ")\nSelected by [Ctrl] + [J]"; } if (Input.GetKeyDown(KeyCode.K) ) { ControllerB = SuperController.singleton.GetSelectedController(); CurrentAtom = SuperController.singleton.GetSelectedAtom(); cstring.val = CurrentAtom.name.ToString() + " (" + CurrentController.name.ToString() + ")\nSelected by [Ctrl] + [K]"; } if (Input.GetKeyDown(KeyCode.L) ) { CurrentPosition = ControllerA.transform.position; CurrentRotation = ControllerA.transform.rotation; ControllerA.transform.position = ControllerB.transform.position; ControllerA.transform.rotation = ControllerB.transform.rotation; ControllerB.transform.position = CurrentPosition; ControllerB.transform.rotation = CurrentRotation; } } } catch (Exception e) { SuperController.LogError("Exception caught: " + e); } } #endregion #region UI Functions private void AtomSelected() { CurrentController = SuperController.singleton.GetSelectedController(); if (CurrentController == null) { pstring.val = ""; return; } else { CurrentAtom = SuperController.singleton.GetSelectedAtom(); } } #endregion } } |
この記事のコピーは以下のサイトで販売している場合があります。
また、未販売の記事のリクエストをお受けしています。
https://neo-sahara.booth.pm/
販売開始リクエスト受付