///<summary>全パーツ選択</summary> void SelectPartsAll() { if (Event.current.type != EventType.KeyDown) { return; } var keycode = Event.current.keyCode; if (keycode == KeyCode.A) { List <enPartsType> drawList = BasePosition.GenGetZSortList(sendMotion_.stPassive.isLeft, sendMotion_.stPassive.isBack); bool isAllSelect = isMultiParts_.Where(p => p.Value == false).Any(); foreach (var item in drawList) { var editParts = PartsConverter.Convert(item); isMultiParts_[editParts] = (isAllSelect) ? true : !isMultiParts_[editParts]; multiOffset_[editParts] = Vector2Int.zero; } isRepaint_ = true; } }
// ファイルで出力 void CreateAniBaseScript() { AniBasePosObject obj = CreateInstance(typeof(AniBasePosObject)) as AniBasePosObject; //obj.aniBasePos = new AniBasePos(); obj.aniBasePos.FRONTDEPTH = BasePosition.OutputDepth(false); obj.aniBasePos.BACKDEPTH = BasePosition.OutputDepth(true); obj.aniBasePos.BODY_BASE = BasePosition.BODY_BASE; obj.aniBasePos.HEAD_BASE = BasePosition.HEAD_BASE; obj.aniBasePos.L_ARM_BASE = BasePosition.L_ARM_BASE; obj.aniBasePos.R_ARM_BASE = BasePosition.R_ARM_BASE; obj.aniBasePos.L_HAND_BASE = BasePosition.L_HAND_BASE; obj.aniBasePos.R_HAND_BASE = BasePosition.R_HAND_BASE; obj.aniBasePos.L_LEG_BASE = BasePosition.L_LEG_BASE; obj.aniBasePos.R_LEG_BASE = BasePosition.R_LEG_BASE; obj.aniBasePos.L_FOOT_BASE = BasePosition.L_FOOT_BASE; obj.aniBasePos.R_FOOT_BASE = BasePosition.R_FOOT_BASE; obj.aniBasePos.ANT_BASE = BasePosition.ANT_BASE; //obj.aniBasePos.LOOKDEPTH = BasePosition.OutputDepth(enPartsAngle.Look); //obj.aniBasePos.SIDEDEPTH = BasePosition.OutputDepth(enPartsAngle.Side); //obj.aniBasePos.REARDEPTH = BasePosition.OutputDepth(enPartsAngle.Rear); AssetDatabase.CreateAsset(obj, GetPackPath("AniBasePos")); Debug.Log("CreateAniBaseScript:" + selectedDir_ + ".asset"); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); // 完了ポップアップ EditorUtility.DisplayDialog("CreateAniBaseScript", "AniBasePosを保存しました。", "ok"); }
///<summary>パーツラベル描画</summary> void DrawPartsLabel() { List <enPartsType> drawList = BasePosition.GenGetZSortList(sendMotion_.stPassive.isLeft, sendMotion_.stPassive.isBack); foreach (var item in drawList) { DrawParts(item, false); } const int MAG = 5; foreach (var item in drawList) { PartsObject partsObject = GetPartsObject(item); Vector2 pos = partsObject.pos; pos.y = -pos.y; //上下反転 //bool mirror = partsObject.partsTransform.mirror; Sprite sp = parent_.GetSprite(item, sendMotion_.stPassive.isBack, sendMotion_.stPassive.faceNo); if (sp == null) { break; } Vector2 basepos = new Vector2(-sp.pivot.x, +sp.pivot.y - sp.rect.height); //Vector2 size = new Vector2(sp.rect.width, sp.rect.height); Vector2 labelpos = new Vector2(128, 256) / MAG; Vector2 drawPos = (basepos + labelpos + pos); // GUIの見た目を変える。 GUIStyle guiStyle = new GUIStyle(); GUIStyleState styleState = new GUIStyleState(); string vecstr = ""; if (isSabunPos_) { // テキストの色を設定 styleState.textColor = Color.yellow; vecstr = "(" + ((int)(sendMotion_.stPos.GetPos(item).x)).ToString() + "," + ((int)(sendMotion_.stPos.GetPos(item).y)).ToString() + ")"; } else { // テキストの色を設定 styleState.textColor = Color.white; vecstr = "(" + ((int)(drawPos.x)).ToString() + "," + ((int)(drawPos.y)).ToString() + ")"; } // スタイルの設定。 guiStyle.normal = styleState; guiStyle.alignment = TextAnchor.MiddleCenter; Vector2 labelPos = new Vector2(drawPos.x, drawPos.y); Rect labelRect = new Rect(labelPos * MAG, new Vector2(sp.rect.width, sp.rect.height) * MAG); GUI.Label(labelRect, vecstr, guiStyle); } }
///<summary>全パーツ描画</summary> void DrawPartsAll() { try { List <enPartsType> drawList = BasePosition.GenGetZSortList(sendMotion_.stPassive.isLeft, sendMotion_.stPassive.isBack); if (focusObject_ == enFocusObject.focusTack) { foreach (var item in drawList) { //非選択 if (!isMultiParts_[PartsConverter.Convert(item)]) { DrawParts(item, false); } } foreach (var item in drawList) { if (isMultiParts_[PartsConverter.Convert(item)]) { DrawParts(item, false); } } } else { foreach (var item in drawList) { DrawParts(item, false); } } //パーツギズモ foreach (var item in drawList) { DrawPartsGizmoPoint(item); } //パーツギズモ DrawPartsGizmoLine(drawList); } catch { } }
void StateToPartsObject() { foreach (enPartsType item in Enum.GetValues(typeof(enPartsType))) { GetPartsObject(item).pos = sendMotion_.stPos.GetPos(item) + BasePosition.GetPosEdit(item, false); GetPartsObject(item).partsTransform = sendMotion_.stTransform.GetTransform(item); } }
///<summary>キーによる位置移動</summary> void ChangePosKey() { if (Event.current.type != EventType.KeyDown) { return; } var keycode = Event.current.keyCode; if ((keycode == KeyCode.UpArrow) || (keycode == KeyCode.DownArrow) || (keycode == KeyCode.LeftArrow) || (keycode == KeyCode.RightArrow) || (keycode == KeyCode.KeypadMinus)) { Undo.RecordObject(parent_, "ChangePartsPosKey"); List <Action> cmdDo = new List <Action>(); List <Action> cmdUndo = new List <Action>(); string id = MethodBase.GetCurrentMethod().Name; foreach (enPartsType item in Enum.GetValues(typeof(enPartsType))) { var editParts = PartsConverter.Convert(item); if (!isMultiParts_[editParts]) { continue; } Vector2Int movePos = GetPartsObject(item).pos; switch (keycode) { case KeyCode.UpArrow: movePos.y += 1; break; case KeyCode.DownArrow: movePos.y -= 1; break; case KeyCode.LeftArrow: movePos.x -= 1; break; case KeyCode.RightArrow: movePos.x += 1; break; case KeyCode.KeypadMinus: movePos = BasePosition.GetPosEdit(item, false); break; //元の位置に戻す } Vector2Int newPos = RoundPosVector(movePos); // GetNewPos(item, RoundPosVector(movePos)); var activeTack = parent_.GetActiveScore().GetActiveTackPoint(); var lastPos = activeTack.motionData_.mPos.GetPos(editParts); var partsType = item; //コマンドPos cmdDo.Add(() => activeTack.motionData_.mPos.SetPos(editParts, newPos)); cmdUndo.Add(() => activeTack.motionData_.mPos.SetPos(editParts, lastPos)); id += partsType; } if (cmdDo.Any()) { ARIMotionMainWindow.tackCmd_.Do(new MotionCommand(id, () => { foreach (var cmd in cmdDo) { cmd(); } }, () => { foreach (var cmd in cmdUndo) { cmd(); } })); } SetupPartsData(true); } }
//Pos--------------- ///<summary>マウスによる位置移動</summary> void ChangePos() { if (Event.current.button != 0) { return; } if (!IsSelectedParts()) { return; } Vector2 mousePos = (Event.current.mousePosition / mag_); //ドラッグ if (Event.current.type == EventType.MouseDrag) { List <Action> cmdDo = new List <Action>(); List <Action> cmdUndo = new List <Action>(); string id = MethodBase.GetCurrentMethod().Name; //コア以外 foreach (enPartsType item in Enum.GetValues(typeof(enPartsType))) { var editParts = PartsConverter.Convert(item); if (!isMultiParts_[editParts]) { continue; } Vector2Int basePos = BasePosition.GetPosEdit(item, false); //コアは左右両方でやるとおかしくなるので、片方だけ if ((editParts == enEditPartsType.Arm) || (editParts == enEditPartsType.Leg)) { if ((item == enPartsType.RightArm) || (item == enPartsType.RightLeg)) { continue; } //基礎位置なし basePos = Vector2Int.zero; } Vector2 movePos = new Vector2( mousePos.x - camPos_.x - multiOffset_[editParts].x, -mousePos.y + camPos_.y - multiOffset_[editParts].y); Undo.RecordObject(parent_, "ChangePartsPos"); Vector2Int newPos = RoundPosVector(movePos) - basePos; var activeTack = parent_.GetActiveScore().GetActiveTackPoint(); var lastPos = activeTack.motionData_.mPos.GetPos(editParts); var partsType = editParts; id += partsType; //コマンドPos cmdDo.Add(() => activeTack.motionData_.mPos.SetPos(editParts, newPos)); cmdUndo.Add(() => activeTack.motionData_.mPos.SetPos(editParts, lastPos)); } // //コア // if (isMultiParts_[enEditPartsType.Core]) // { // var editParts = enEditPartsType.Core; // Vector2 movePos = new Vector2( // mousePos.x - camPos_.x - multiOffset_[editParts].x, -mousePos.y + camPos_.y - multiOffset_[editParts].y); // Undo.RecordObject(parent_, "ChangePartsPos"); // Vector2Int newPos = RoundPosVector(movePos); // // GetNewPos(editParts, RoundPosVector(movePos)); // var activeTack = parent_.GetActiveScore().GetActiveTackPoint(); // var lastPos = activeTack.motionData_.mPos.GetPos(editParts); // // var partsType = item; // id += editParts; // //コマンドPos // cmdDo.Add(() => activeTack.motionData_.mPos.SetPos(editParts, newPos)); // cmdUndo.Add(() => activeTack.motionData_.mPos.SetPos(editParts, lastPos)); // } if (cmdDo.Any()) { ARIMotionMainWindow.tackCmd_.Do(new MotionCommand(id, () => { foreach (var cmd in cmdDo) { cmd(); } }, () => { foreach (var cmd in cmdUndo) { cmd(); } })); } SetupPartsData(true); } }
///<summary>キーパーツ選択</summary> void SelectPartsKey() { if (Event.current.type != EventType.KeyDown) { return; } var keycode = Event.current.keyCode; var isCtrl = Event.current.control; if ((keycode == KeyCode.Keypad1) || (keycode == KeyCode.Keypad2) || (keycode == KeyCode.Keypad3) || (keycode == KeyCode.Keypad4) || (keycode == KeyCode.Keypad5) || (keycode == KeyCode.Keypad6) || (keycode == KeyCode.Keypad7) || (keycode == KeyCode.Keypad8) || (keycode == KeyCode.Keypad9) || (keycode == KeyCode.Keypad0) || (keycode == KeyCode.KeypadPeriod) ) { List <enPartsType> drawList = BasePosition.GenGetZSortList(sendMotion_.stPassive.isLeft, sendMotion_.stPassive.isBack); enPartsType partsType = enPartsType.Body; switch (keycode) { case KeyCode.Keypad8: partsType = enPartsType.Ant; break; case KeyCode.Keypad5: partsType = enPartsType.Head; break; case KeyCode.Keypad2: partsType = enPartsType.Body; break; case KeyCode.Keypad7: partsType = enPartsType.RightArm; break; case KeyCode.Keypad4: partsType = enPartsType.RightHand; break; case KeyCode.Keypad9: partsType = enPartsType.LeftArm; break; case KeyCode.Keypad6: partsType = enPartsType.LeftHand; break; case KeyCode.Keypad1: partsType = enPartsType.RightLeg; break; case KeyCode.Keypad0: partsType = enPartsType.RightFoot; break; case KeyCode.Keypad3: partsType = enPartsType.LeftLeg; break; case KeyCode.KeypadPeriod: partsType = enPartsType.LeftFoot; break; default: return; } if (isCtrl) { foreach (var item in drawList) { if (partsType != item) { continue; } var editParts = PartsConverter.Convert(item); isMultiParts_[editParts] = !isMultiParts_[editParts]; multiOffset_[editParts] = Vector2Int.zero; } } else { foreach (var item in drawList) { var editParts = PartsConverter.Convert(item); isMultiParts_[editParts] = (partsType != item) ? false : !isMultiParts_[editParts]; multiOffset_[editParts] = Vector2Int.zero; } } isRepaint_ = true; } }