private static void DrawWindow(int id) { GUIStyle lineStyle = new GUIStyle("box"); lineStyle.border.top = lineStyle.border.bottom = 1; lineStyle.margin.top = lineStyle.margin.bottom = 1; lineStyle.padding.top = lineStyle.padding.bottom = 1; GUIStyle gridStyle = new GUIStyle("Button"); gridStyle.onNormal.background = Texture2D.whiteTexture; gridStyle.onNormal.textColor = Color.black; gridStyle.onHover.background = Texture2D.whiteTexture; gridStyle.onHover.textColor = Color.black; gridStyle.onActive.background = Texture2D.whiteTexture; gridStyle.onActive.textColor = Color.black; string[] characterNames = new string[AI_BetterHScenes.characters.Count]; string[] offsetNames = new string[] { "Whole Body", "Left Hand", "Right Hand", "Left Foot", "Right Foot" }; for (var charIndex = 0; charIndex < AI_BetterHScenes.characters.Count; charIndex++) { characterNames[charIndex] = AI_BetterHScenes.characters[charIndex].fileParam.fullname; } using (GUILayout.VerticalScope guiVerticalScope = new GUILayout.VerticalScope("box")) { selectedCharacter = GUILayout.SelectionGrid(selectedCharacter, characterNames, AI_BetterHScenes.characters.Count, gridStyle, GUILayout.Height(30)); GUILayout.Box(GUIContent.none, lineStyle, GUILayout.ExpandWidth(true), GUILayout.Height(1f)); selectedOffset = GUILayout.SelectionGrid(selectedOffset, offsetNames, offsetNames.Length, gridStyle, GUILayout.Height(30)); using (GUILayout.HorizontalScope linkScope = new GUILayout.HorizontalScope("box")) { GUILayout.Space((uiWidth / 5) - 10); if (GUILayout.Button("Mirror Active Limb")) { MirrorActiveLimb(); } } GUILayout.Box(GUIContent.none, lineStyle, GUILayout.ExpandWidth(true), GUILayout.Height(1f)); float sliderMaxRotation = AI_BetterHScenes.sliderMaxRotation.Value; float sliderMaxPosition = AI_BetterHScenes.sliderMaxPosition.Value; if (selectedOffset != 0) { sliderMaxRotation *= 2; sliderMaxPosition /= 2; } Vector3 lastPosition = new Vector3(0, 0, 0); Vector3 lastRotation = new Vector3(0, 0, 0); if (selectedOffset == (int)BodyPart.WholeBody) { lastPosition = new Vector3(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.x, characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.y, characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.z); lastRotation = new Vector3(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.x, characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.y, characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.z); } using (GUILayout.HorizontalScope positionScope = new GUILayout.HorizontalScope("box")) { using (GUILayout.VerticalScope verticalScopeX = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeX = new GUILayout.HorizontalScope()) { GUILayout.Label("Position X"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.x = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.x = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.x, -sliderMaxPosition, sliderMaxPosition); } using (GUILayout.VerticalScope verticalScopeY = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeY = new GUILayout.HorizontalScope()) { GUILayout.Label("Position Y"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.y = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.y = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.y, -sliderMaxPosition, sliderMaxPosition); } using (GUILayout.VerticalScope verticalScopeZ = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeZ = new GUILayout.HorizontalScope()) { GUILayout.Label("Position Z"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.z = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.z = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.z, -sliderMaxPosition, sliderMaxPosition); } } using (GUILayout.HorizontalScope rotationScope = new GUILayout.HorizontalScope("box")) { using (GUILayout.VerticalScope verticalScopeX = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeX = new GUILayout.HorizontalScope()) { GUILayout.Label("Rotation X"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.x = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.x = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.x, -sliderMaxRotation, sliderMaxRotation); } using (GUILayout.VerticalScope verticalScopeY = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeY = new GUILayout.HorizontalScope()) { GUILayout.Label("Rotation Y"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.y = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.y = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.y, -sliderMaxRotation, sliderMaxRotation); } using (GUILayout.VerticalScope verticalScopeZ = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeZ = new GUILayout.HorizontalScope()) { GUILayout.Label("Rotation Z"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.z = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.z = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.z, -sliderMaxRotation, sliderMaxRotation); } } if (selectedOffset != (int)BodyPart.WholeBody) { using (GUILayout.HorizontalScope rotationScope = new GUILayout.HorizontalScope("box")) { using (GUILayout.VerticalScope verticalScopeX = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeX = new GUILayout.HorizontalScope()) { GUILayout.Label("Hint X"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.x = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.x = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.x, -sliderMaxPosition, sliderMaxPosition); } using (GUILayout.VerticalScope verticalScopeY = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeY = new GUILayout.HorizontalScope()) { GUILayout.Label("Hint Y"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.y = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.y = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.y, -sliderMaxPosition, sliderMaxPosition); } using (GUILayout.VerticalScope verticalScopeZ = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeZ = new GUILayout.HorizontalScope()) { GUILayout.Label("Hint Z"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.z = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.z = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.z, -sliderMaxPosition, sliderMaxPosition); } } } else { if (lastPosition != characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position || lastRotation != characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation) { ApplyPositions(); } } using (GUILayout.HorizontalScope controlScope = new GUILayout.HorizontalScope("box")) { if (GUILayout.Button("Copy")) { CopyPositions(); } if (GUILayout.Button("Paste")) { PastePositions(); } if (GUILayout.Button("Reset All")) { ResetPositions(); } if (GUILayout.Button("Reload")) { HSceneOffset.ApplyCharacterOffsets(); } if (GUILayout.Button("Save This")) { SavePosition(AI_BetterHScenes.useOneOffsetForAllMotions.Value); } if (AI_BetterHScenes.useOneOffsetForAllMotions.Value == false && GUILayout.Button("Save Default")) { SavePosition(true); } } } GUI.DragWindow(); }
private static void DrawWindow(int id) { GUIStyle lineStyle = new GUIStyle("box"); lineStyle.border.top = lineStyle.border.bottom = 1; lineStyle.margin.top = lineStyle.margin.bottom = 1; lineStyle.padding.top = lineStyle.padding.bottom = 1; GUIStyle gridStyle = new GUIStyle("Button"); gridStyle.onNormal.background = Texture2D.whiteTexture; gridStyle.onNormal.textColor = Color.black; gridStyle.onHover.background = Texture2D.whiteTexture; gridStyle.onHover.textColor = Color.black; gridStyle.onActive.background = Texture2D.whiteTexture; gridStyle.onActive.textColor = Color.black; string[] characterNames = new string[AI_BetterHScenes.characters.Count]; string[] offsetNames = new string[] { "Whole Body", "Left Hand", "Right Hand", "Left Foot", "Right Foot" }; for (var charIndex = 0; charIndex < AI_BetterHScenes.characters.Count; charIndex++) { characterNames[charIndex] = AI_BetterHScenes.characters[charIndex].fileParam.fullname; } using (GUILayout.VerticalScope guiVerticalScope = new GUILayout.VerticalScope("box")) { selectedCharacter = GUILayout.SelectionGrid(selectedCharacter, characterNames, AI_BetterHScenes.characters.Count, gridStyle, GUILayout.Height(30)); GUILayout.Box(GUIContent.none, lineStyle, GUILayout.ExpandWidth(true), GUILayout.Height(1f)); using (GUILayout.HorizontalScope linkScope = new GUILayout.HorizontalScope("box")) { selectedOffset = GUILayout.SelectionGrid(selectedOffset, offsetNames, offsetNames.Length, gridStyle, GUILayout.Height(30)); } using (GUILayout.HorizontalScope linkScope = new GUILayout.HorizontalScope("box")) { if (selectedOffset == (int)BodyPart.WholeBody) { GUILayout.Label("Heel Offset: ", GUILayout.Width((2 * uiWidth / 15) - 10)); shoeOffsets[selectedCharacter] = Convert.ToSingle(GUILayout.TextField(shoeOffsets[selectedCharacter].ToString("0.000"), GUILayout.Width((2 * uiWidth / 15) - 10))); } else { if (GUILayout.Button("Mirror Limb")) { MirrorActiveLimb(); } bool[] lastCorrection = new bool[(int)BodyPart.BodyPartsCount]; for (var part = (int)BodyPart.LeftHand; part < (int)BodyPart.BodyPartsCount; part++) { lastCorrection[part] = characterOffsets[selectedCharacter].jointCorrection[part]; } characterOffsets[selectedCharacter].jointCorrection[(int)BodyPart.LeftHand] = GUILayout.Toggle(characterOffsets[selectedCharacter].jointCorrection[(int)BodyPart.LeftHand], " Correction"); characterOffsets[selectedCharacter].jointCorrection[(int)BodyPart.RightHand] = GUILayout.Toggle(characterOffsets[selectedCharacter].jointCorrection[(int)BodyPart.RightHand], " Correction"); characterOffsets[selectedCharacter].jointCorrection[(int)BodyPart.LeftFoot] = GUILayout.Toggle(characterOffsets[selectedCharacter].jointCorrection[(int)BodyPart.LeftFoot], " Correction"); characterOffsets[selectedCharacter].jointCorrection[(int)BodyPart.RightFoot] = GUILayout.Toggle(characterOffsets[selectedCharacter].jointCorrection[(int)BodyPart.RightFoot], " Correction"); bool correctionChanged = false; for (var part = (int)BodyPart.LeftHand; part < (int)BodyPart.BodyPartsCount; part++) { if (lastCorrection[part] == characterOffsets[selectedCharacter].jointCorrection[part]) { continue; } correctionChanged = true; break; } if (correctionChanged) { characterOffsets[selectedCharacter].ApplyJointCorrections(); } } } GUILayout.Box(GUIContent.none, lineStyle, GUILayout.ExpandWidth(true), GUILayout.Height(1f)); float sliderMaxRotation = AI_BetterHScenes.sliderMaxLimbRotation.Value; float sliderMaxPosition = AI_BetterHScenes.sliderMaxLimbPosition.Value; Vector3 lastPosition = Vector3.zero; Vector3 lastRotation = Vector3.zero; if (selectedOffset == (int)BodyPart.WholeBody) { sliderMaxRotation = AI_BetterHScenes.sliderMaxBodyRotation.Value; sliderMaxPosition = AI_BetterHScenes.sliderMaxBodyPosition.Value; lastPosition = new Vector3(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.x, characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.y, characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.z); lastRotation = new Vector3(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.x, characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.y, characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.z); } using (GUILayout.HorizontalScope positionScope = new GUILayout.HorizontalScope("box")) { using (GUILayout.VerticalScope verticalScopeX = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeX = new GUILayout.HorizontalScope()) { GUILayout.Label("Position X"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.x = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.x = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.x, -sliderMaxPosition, sliderMaxPosition); } using (GUILayout.VerticalScope verticalScopeY = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeY = new GUILayout.HorizontalScope()) { GUILayout.Label("Position Y"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.y = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.y = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.y, -sliderMaxPosition, sliderMaxPosition); } using (GUILayout.VerticalScope verticalScopeZ = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeZ = new GUILayout.HorizontalScope()) { GUILayout.Label("Position Z"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.z = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.z = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position.z, -sliderMaxPosition, sliderMaxPosition); } } using (GUILayout.HorizontalScope rotationScope = new GUILayout.HorizontalScope("box")) { using (GUILayout.VerticalScope verticalScopeX = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeX = new GUILayout.HorizontalScope()) { GUILayout.Label("Rotation X"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.x = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.x = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.x, -sliderMaxRotation, sliderMaxRotation); } using (GUILayout.VerticalScope verticalScopeY = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeY = new GUILayout.HorizontalScope()) { GUILayout.Label("Rotation Y"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.y = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.y = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.y, -sliderMaxRotation, sliderMaxRotation); } using (GUILayout.VerticalScope verticalScopeZ = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeZ = new GUILayout.HorizontalScope()) { GUILayout.Label("Rotation Z"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.z = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.z = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation.z, -sliderMaxRotation, sliderMaxRotation); } } if (selectedOffset != (int)BodyPart.WholeBody) { using (GUILayout.HorizontalScope rotationScope = new GUILayout.HorizontalScope("box")) { using (GUILayout.VerticalScope verticalScopeX = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeX = new GUILayout.HorizontalScope()) { GUILayout.Label("Hint X"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.x = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.x = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.x, -AI_BetterHScenes.sliderMaxHintPosition.Value, AI_BetterHScenes.sliderMaxHintPosition.Value); } using (GUILayout.VerticalScope verticalScopeY = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeY = new GUILayout.HorizontalScope()) { GUILayout.Label("Hint Y"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.y = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.y = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.y, -AI_BetterHScenes.sliderMaxHintPosition.Value, AI_BetterHScenes.sliderMaxHintPosition.Value); } using (GUILayout.VerticalScope verticalScopeZ = new GUILayout.VerticalScope("box")) { using (GUILayout.HorizontalScope horizontalScopeZ = new GUILayout.HorizontalScope()) { GUILayout.Label("Hint Z"); if (GUILayout.Button("Reset", GUILayout.MaxWidth(uiWidth / 12))) { characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.z = 0; } } characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.z = GUILayout.HorizontalSlider(characterOffsets[selectedCharacter].offsetVectors[selectedOffset].hintPosition.z, -AI_BetterHScenes.sliderMaxHintPosition.Value, AI_BetterHScenes.sliderMaxHintPosition.Value); } } } else { if (lastPosition != characterOffsets[selectedCharacter].offsetVectors[selectedOffset].position || lastRotation != characterOffsets[selectedCharacter].offsetVectors[selectedOffset].rotation) { ApplyPositionsAndCorrections(); } } using (GUILayout.HorizontalScope controlScope = new GUILayout.HorizontalScope("box")) { if (GUILayout.Button("Copy")) { CopyPositions(); } if (GUILayout.Button("Paste")) { PastePositions(); } if (GUILayout.Button("Reset All")) { ResetPositions(); } if (GUILayout.Button("Reload")) { HSceneOffset.ApplyCharacterOffsets(); } if (GUILayout.Button("Save This")) { SavePosition(AI_BetterHScenes.useOneOffsetForAllMotions.Value); } if (AI_BetterHScenes.useOneOffsetForAllMotions.Value == false && GUILayout.Button("Save Default")) { SavePosition(true); } } } GUI.DragWindow(); }