public override void PreviewTimeInternal(MovieCurveClip clip, float sampleTime) { if (this.target == null) { this.target = GameObject.Find(this.targetName); if (this.target == null) { Debug.LogWarning(Translation.GetText("Warnings", "objectNotFound")); this.enabled = false; return; } this.component = null; } if (this.component == null) { // Debug.Log("Attempting to reattach " + this.componentTypeName); Type type = typeof(UnityEngine.Component).Assembly.GetType(this.componentTypeName); this.component = this.target.GetComponent(type); } for (int i = 0; i < propsToChange.Count; i++) { List <int> curveIdxes = this.propIdxToCurveIdxes[i]; float[] values = curveIdxes.Select(idx => clip.curves[idx].Evaluate(sampleTime)).ToArray(); this.propsToChange[i].SetValue(this.component, values); } }
public void Set(Vector2 p, float fWidth, int iFontSize, Component component, Action <PropertyInfo, FieldInfo> f) { rect = new Rect(p.x - fWidth, p.y, fWidth, 0f); fRightPos = p.x + fWidth; fUpPos = p.y; gsLabel = new GUIStyle("label"); gsLabel.fontSize = iFontSize; gsLabel.alignment = TextAnchor.MiddleLeft; gsButton = new GUIStyle("button"); gsButton.fontSize = iFontSize; gsButton.alignment = TextAnchor.MiddleCenter; fMargin = iFontSize * 0.3f; func = f; show = true; isField = false; this.propertyBox = new CustomComboBox(); this.propertyBox.Text = Translation.GetText("PropertyPicker", "property"); this.fieldBox = new CustomComboBox(); this.fieldBox.Text = Translation.GetText("PropertyPicker", "field"); this.okButton = new CustomButton(); this.okButton.Text = Translation.GetText("UI", "ok"); this.okButton.Click = this.Ok; this.cancelButton = new CustomButton(); this.cancelButton.Text = Translation.GetText("UI", "cancel"); this.cancelButton.Click = this.Cancel; this.LoadProperties(component); }
public override void PreviewTimeInternal(MovieCurveClip clip, float sampleTime) { if (this.maid == null || !this.maid.Visible) { Debug.LogWarning(Translation.GetText("Warnings", "maidNotFound")); this.enabled = false; return; } if (this.targetMorph == null) { this.targetMorph = maid.body0.Face.morph; } maid.boMabataki = false; maid.boFaceAnime = false; for (int i = 0; i < clip.curves.Count; i++) { String key = faceVals[i, 0]; if (targetMorph.Contains(key)) { // if (bd.key == "nosefook") // maid.boNoseFook = bd.val > 0f ? true : false; // else if (bd.key == "hitomih") // morph.BlendValues[(int)morph.hash[bd.key]] = bd.val * 3; // else targetMorph.BlendValues[(int)targetMorph.hash[key]] = clip.curves[i].Evaluate(sampleTime); } } targetMorph.FixBlendValues_Face(); }
override public void Awake() { try { this.playButton = new Plugin.CustomButton(); this.playButton.Text = "▶"; this.playButton.Click += this.Play; this.ChildControls.Add(this.playButton); this.stopButton = new Plugin.CustomButton(); this.stopButton.Text = "■"; this.stopButton.Click += this.Stop; this.ChildControls.Add(this.stopButton); this.addButton = new Plugin.CustomButton(); this.addButton.Text = Translation.GetText("Timeline", "addTrack"); this.addButton.Click += this.Add; this.ChildControls.Add(this.addButton); this.copyClipButton = new Plugin.CustomButton(); this.copyClipButton.Text = Translation.GetText("Timeline", "copyClip"); this.copyClipButton.Click += this.CopyClip; this.ChildControls.Add(this.copyClipButton); this.deleteClipButton = new Plugin.CustomButton(); this.deleteClipButton.Text = Translation.GetText("Timeline", "deleteClip"); this.deleteClipButton.Click += this.DeleteClip; this.ChildControls.Add(this.deleteClipButton); this.curvePane = new CurvePane(); this.ChildControls.Add(this.curvePane); this.maidLoader = new MaidLoader(); } catch (Exception e) { Debug.LogError(e.ToString()); } }
public override void PreviewTimeInternal(MovieCurveClip clip, float sampleTime) { if (this.maid == null || !this.maid.Visible) { Debug.LogWarning(Translation.GetText("Warnings", "maidNotFound")); this.enabled = false; return; } if (this.animationTarget == null) { this.animationTarget = maid.body0.m_Bones.GetComponent <Animation>(); } animationTarget.Play(this.animationName.ToLower()); float totalLength = this.animationTarget[this.animationName].length; float sampleLength = sampleTime * totalLength; animationTarget[animationName.ToLower()].time = sampleLength; animationTarget[animationName.ToLower()].enabled = true; animationTarget.Sample(); animationTarget[animationName.ToLower()].enabled = false; }
public override void PreviewTimeInternal(MovieCurveClip clip, float sampleTime) { if (this.maid == null || !this.maid.Visible) { Debug.LogWarning(Translation.GetText("Warnings", "maidNotFound")); this.enabled = false; return; } int i = 0; foreach (string targetName in TARGET_NAMES) { Transform target = this.targets[targetName]; float[] values = clip.curves.Skip(i * 6).Take(6).Select(c => c.Evaluate(sampleTime)).ToArray(); Vector3 rot = new Vector3(values[0], values[1], values[2]); Vector3 pos = new Vector3(values[3], values[4], values[5]); target.eulerAngles = rot; target.position = pos; i += 1; } }
public override string GetName() => Translation.GetText("UI", "animation") + ": " + this.maid.name;
override public void ShowPane() { try { GUI.enabled = this.GuiEnabled; if (!this.maidLoader.IsInitted) { this.maidLoader.Init(); } float seek = this.seekerPos + PANEL_WIDTH - this.scrollPosition.x; Rect seekerRect = new Rect(ControlBase.FixedMargin + seek, 0, 20, 40); Rect labelRect = new Rect(seekerRect.x + seekerRect.width + 5, seekerRect.y, 100, 40); GUI.Label(labelRect, Translation.GetText("Timeline", "frame") + " " + this.currentFrame); if (GUI.RepeatButton(seekerRect, "") || (draggingSeeker && Input.GetMouseButton(0))) { draggingSeeker = true; this.seekerPos = Input.mousePosition.x - this.ScreenPos.x + this.scrollPosition.x - 10 - PANEL_WIDTH; this.updated = true; } else { draggingSeeker = false; } Rect trackPanelRect = new Rect(0, ControlBase.FixedMargin + 20, PANEL_WIDTH, 400 - ControlBase.FixedMargin * 4); GUILayout.BeginArea(trackPanelRect); for (int i = 0; i < this.take.tracks.Count; i++) { MovieTrack track = this.take.tracks[i]; Rect panel = new Rect(0, this.scrollPosition.y + (this.ControlHeight * 2 * i), PANEL_WIDTH - 150, this.ControlHeight * 2); GUILayout.BeginArea(panel); track.DrawPanel(this.currentFrame / framesPerSecond); if (track.inserted) { this.updated = true; } GUILayout.EndArea(); GUIStyle style = new GUIStyle("label"); style.alignment = TextAnchor.MiddleLeft; panel.x = PANEL_WIDTH - 150 + ControlBase.FixedMargin; panel.width = 150 - ControlBase.FixedMargin * 2; GUI.Label(panel, this.take.tracks[i].GetName(), style); } GUILayout.EndArea(); Rect rectScroll = new Rect(PANEL_WIDTH, ControlBase.FixedMargin + 20, this.rectGui.width - ControlBase.FixedMargin - PANEL_WIDTH, 400 - ControlBase.FixedMargin * 4); Rect rectScrollView = new Rect(0, 0, guiScrollWidth, guiScrollHeight); this.scrollPosition = GUI.BeginScrollView(rectScroll, this.scrollPosition, rectScrollView); for (int i = this.take.tracks.Count - 1; i >= 0; i--) { if (this.take.tracks[i].wantsDelete) { // reset to the value at the beginning of the track, instead of in the middle this.take.tracks[i].PreviewTime(0f); this.take.tracks.RemoveAt(i); } } for (int i = 0; i < this.take.tracks.Count; i++) { this.drawTrack(i); } guiScrollHeight = (this.take.tracks.Count) * this.ControlHeight * 2; GUI.EndScrollView(); Rect lineRect = new Rect(ControlBase.FixedMargin + seek, 0, 1, 400); GUI.DrawTexture(lineRect, this.lineTexture); this.playButton.Left = this.Left + ControlBase.FixedMargin; this.playButton.Top = rectScroll.yMax + ControlBase.FixedMargin; this.playButton.Width = 50; this.playButton.Height = this.ControlHeight; this.playButton.Visible = true; this.playButton.OnGUI(); this.stopButton.Left = this.playButton.Left + this.playButton.Width; this.stopButton.Top = this.playButton.Top; this.stopButton.Width = this.playButton.Width; this.stopButton.Height = this.ControlHeight; this.stopButton.Visible = true; this.stopButton.OnGUI(); this.addButton.Left = this.stopButton.Left + this.stopButton.Width; this.addButton.Top = this.stopButton.Top; this.addButton.Width = 100; this.addButton.Height = this.ControlHeight; this.addButton.Visible = true; this.addButton.OnGUI(); this.copyClipButton.Left = this.addButton.Left + this.addButton.Width; this.copyClipButton.Top = this.addButton.Top; this.copyClipButton.Width = this.addButton.Width; this.copyClipButton.Height = this.ControlHeight; this.copyClipButton.Visible = true; this.copyClipButton.OnGUI(); this.deleteClipButton.Left = this.copyClipButton.Left + this.copyClipButton.Width; this.deleteClipButton.Top = this.copyClipButton.Top; this.deleteClipButton.Width = this.copyClipButton.Width; this.deleteClipButton.Height = this.ControlHeight; this.deleteClipButton.Visible = true; this.deleteClipButton.OnGUI(); Rect toggleRect = this.deleteClipButton.WindowRect; toggleRect.x += toggleRect.width + ControlBase.FixedMargin * 2; toggleRect.width *= 1.5f; int iTmp; if ((iTmp = GUI.Toolbar(toggleRect, (int)this.dragMode, DRAG_MODES)) >= 0) { this.dragMode = (DragMode)iTmp; } //this.Height = GUIUtil.GetHeightForParent(this) + 5 * this.ControlHeight; toggleRect.x += toggleRect.width + ControlBase.FixedMargin * 2; toggleRect.width *= 1.80f; if ((iTmp = GUI.Toolbar(toggleRect, (int)this.curvePane.mode, CURVE_PANE_MODES)) >= 0) { this.curvePane.mode = (CurvePane.CurvePaneMode)iTmp; } // toggleRect.x += toggleRect.width + ControlBase.FixedMargin * 4; // string sTmp = // toggleRect.x += toggleRect.width + ControlBase.FixedMargin * 4; Rect curveRect = new Rect(0, toggleRect.yMax, 1000, 300); this.curvePane.SetFromRect(curveRect); this.curvePane.UpdateOffsets(curveRect, this.rectGui); GUI.BeginGroup(curveRect); if (this.ClipIsSelected()) { this.curvePane.Draw(curveRect, this.take.tracks[this.selectedTrackIndex].clips, this.selectedClipIndex, this.selectedTrackIndex); } else if (this.IsDataView()) { this.curvePane.DrawDataView(curveRect); } GUI.EndGroup(); if (this.curvePane.needsUpdate) { this.updated = true; } if (this.curvePane.wantsSave) { Serialize.Save(this.curvePane.typedSaveName, this.take); this.curvePane.LoadSavefileNames(); this.curvePane.wantsSave = false; } if (this.curvePane.wantsLoad) { XDocument doc = Deserialize.LoadFileFromSave(this.curvePane.selectedSaveName); List <string> guids = Deserialize.GetMaidGuids(doc); this.maidLoader.SelectMaidsWithGuids(guids); this.maidLoader.onMaidsLoaded = () => { this.take = Deserialize.DeserializeTake(doc); this.Stop(this, new EventArgs()); this.Update(); }; this.maidLoader.StartLoad(); this.curvePane.wantsLoad = false; } ControlBase.TryFocusGUI(this.rectGui); } catch (Exception e) { Debug.LogError(e); } }
public override string GetName() => Translation.GetText("UI", "camera");
public virtual string GetName() => Translation.GetText("UI", "track");
public void GuiFunc(int winId) { int iFontSize = gsLabel.fontSize; Rect rectItem = new Rect(iFontSize * 0.5f, iFontSize * 0.5f, rect.width - iFontSize * 0.5f, iFontSize * 1.5f); this.isField = GUI.Toggle(rectItem, this.isField, Translation.GetText("PropertyPicker", "isField"), new GUIStyle("toggle")); if (isField) { rectItem.y += rectItem.height; this.fieldBox.SetFromRect(rectItem); this.fieldBox.ScreenPos = new Rect(rect.x, rect.y, 0, 0); this.fieldBox.OnGUI(); if (this.fieldBox.Items.Count == 0) { GUI.enabled = false; } } else { rectItem.y += rectItem.height; this.propertyBox.SetFromRect(rectItem); this.propertyBox.ScreenPos = new Rect(rect.x, rect.y, 0, 0); this.propertyBox.OnGUI(); if (this.propertyBox.Items.Count == 0) { GUI.enabled = false; } } rectItem.y += rectItem.height; rectItem.width = (rect.width - iFontSize * 0.5f) / 2; this.okButton.SetFromRect(rectItem); this.okButton.ScreenPos = new Rect(rect.x, rect.y, 0, 0); this.okButton.OnGUI(); GUI.enabled = true; rectItem.x += rectItem.width; this.cancelButton.SetFromRect(rectItem); this.cancelButton.ScreenPos = new Rect(rect.x, rect.y, 0, 0); this.cancelButton.OnGUI(); float fHeight = rectItem.y + rectItem.height + fMargin; if (rect.height != fHeight) { Rect rectTmp = new Rect(rect.x, rect.y - fHeight, rect.width, fHeight); rect = rectTmp; } else if (rect.x < 0f) { Rect rectTmp = new Rect(fRightPos, rect.y, rect.width, rect.height); rect = rectTmp; } else if (rect.y < 0f) { Rect rectTmp = new Rect(rect.x, fUpPos, rect.width, rect.height); rect = rectTmp; } GUI.DragWindow(); }