protected void OnInspectorGUI_Multi() { EditorGUILayout.HelpBox("Displayed information is of the first selected model,\nbut any change affects all selected models.", MessageType.Info); MeshModel[] models = new MeshModel[targets.Length]; for (int i = 0; i < models.Length; ++i) { models[i] = targets[i] as MeshModel; } MeshModel firstModel = models[0]; bool isAllSkinnedModel = true; foreach (MeshModel model in models) { isAllSkinnedModel &= model.IsSkinnedModel(); } bool isAllNotFixingToGround = true; foreach (MeshModel model in models) { isAllNotFixingToGround &= (!model.isFixingToOrigin || !model.isFixingToGround); } PivotType pivotType = PivotType.Bottom; bool isPivotTypeChanged = false; bool isGroundPivot = false; bool isGroundPivotChanged = false; if (isAllSkinnedModel || isAllNotFixingToGround) { EditorGUILayout.Space(); if (isAllSkinnedModel) { pivotType = DrawPivotTypeField(firstModel, out isPivotTypeChanged); } if (isAllNotFixingToGround) { isGroundPivot = DrawGroundPivotField(firstModel, out isGroundPivotChanged); } } bool hasAllRootBone = true; foreach (MeshModel model in models) { hasAllRootBone &= (model.rootBoneObj != null); } bool isFixingToOrigin = false; bool isFixingToOriginChanged = false; bool isAllFixingToOrigin = true; bool isAllNotGroundPivot = true; bool isFixingToGround = false; bool isFixingToGroundChanged = false; if (isAllSkinnedModel && hasAllRootBone) { EditorGUILayout.Space(); EditorGUILayout.LabelField("Root Bone"); EditorGUI.indentLevel++; { isFixingToOrigin = DrawFixToOriginField(firstModel, out isFixingToOriginChanged); foreach (MeshModel model in models) { isAllFixingToOrigin &= model.isFixingToOrigin; } foreach (MeshModel model in models) { isAllNotGroundPivot &= !model.isGroundPivot; } if (isAllFixingToOrigin && isAllNotGroundPivot) { EditorGUI.indentLevel++; isFixingToGround = DrawFixToGroundField(firstModel, out isFixingToGroundChanged); EditorGUI.indentLevel--; } } EditorGUI.indentLevel--; } EditorGUILayout.Space(); bool isSpritePrefabChanged; GameObject spritePrefab = DrawSpritePrefabField(firstModel, out isSpritePrefabChanged); bool hasAllSpritePrefab = true; foreach (MeshModel model in models) { hasAllSpritePrefab &= (model.spritePrefab != null); } PrefabBuilder prefabBuilder = null; bool isPrefabBuilderChanged = false; if (hasAllSpritePrefab) { EditorGUI.indentLevel++; prefabBuilder = DrawPrefabBuilderField(model, out isPrefabBuilderChanged); EditorGUI.indentLevel--; } EditorGUILayout.Space(); bool isNameSuffixChanged; string nameSuffix = DrawModelNameSuffix(firstModel, out isNameSuffixChanged); if (isNameSuffixChanged) { PathHelper.CorrectPathString(ref nameSuffix); } if (isPivotTypeChanged || isGroundPivotChanged || isFixingToOriginChanged || isFixingToGroundChanged || isSpritePrefabChanged || isPrefabBuilderChanged || isNameSuffixChanged) { foreach (MeshModel model in models) { Undo.RecordObject(model, "Mesh Model"); if (isAllSkinnedModel && isPivotTypeChanged) { model.pivotType = pivotType; } if (isAllNotFixingToGround && isGroundPivotChanged) { model.isGroundPivot = isGroundPivot; } if (isAllSkinnedModel && hasAllRootBone) { if (isFixingToOriginChanged) { model.isFixingToOrigin = isFixingToOrigin; } if (isAllFixingToOrigin && isAllNotGroundPivot && isFixingToGroundChanged) { model.isFixingToGround = isFixingToGround; } } if (isSpritePrefabChanged) { model.spritePrefab = spritePrefab; } if (hasAllSpritePrefab && isPrefabBuilderChanged) { model.prefabBuilder = prefabBuilder; } if (isNameSuffixChanged) { model.nameSuffix = nameSuffix; } } } Studio studio = FindObjectOfType <Studio>(); if (studio == null) { return; } EditorGUILayout.Space(); if (DrawingHelper.DrawWideButton("Add all to the model list")) { foreach (MeshModel model in models) { AddToModelList(model); } } }
void OnGUI() { try { if (frames == null || studio == null) { return; } if (studio.samplings.Count == 0 || frames.Count == 0) { return; } const float BUTTOM_HEIGHT = 18f; const float MENU_HEIGHT = 60f; const float MARGIN = 2f; int spriteWidth = studio.samplings[0].tex.width; int spriteHeight = studio.samplings[0].tex.height; const float FRAME_LABEL_WIDTH = 30f; float editorWidth = Mathf.Max(spriteWidth + (MARGIN + FRAME_LABEL_WIDTH) * 2f, MIN_EDITOR_WIDTH); position = new Rect(position.x, position.y, editorWidth, MENU_HEIGHT + (float)spriteHeight + MARGIN); EditorGUI.BeginChangeCheck(); { DrawFrameRateField(ref studio.output.frameRate); DrawIntervalField(ref studio.output.frameInterval); } if (EditorGUI.EndChangeCheck()) { Reset(); } const float BUTTONS_Y = MENU_HEIGHT - 20f; Rect playRect = new Rect(MARGIN, BUTTONS_Y, editorWidth / 2f - MARGIN, BUTTOM_HEIGHT); EditorGUI.BeginChangeCheck(); playing = GUI.Toggle(playRect, playing, "Play", GUI.skin.button); if (EditorGUI.EndChangeCheck()) { if (playing) { Reset(); playing = true; } else { playing = false; } } Rect loopRect = new Rect(MARGIN + editorWidth / 2f, BUTTONS_Y, editorWidth / 2f - MARGIN, BUTTOM_HEIGHT); looping = GUI.Toggle(loopRect, looping, "Loop", GUI.skin.button); float spritePosX = MARGIN + FRAME_LABEL_WIDTH; if (spriteWidth < editorWidth) { spritePosX = (editorWidth - spriteWidth) / 2f; } float spritePosY = MENU_HEIGHT; Rect spriteRect = new Rect(spritePosX, spritePosY, spriteWidth, spriteHeight); EditorGUI.DrawTextureTransparent(spriteRect, studio.samplings[frameNumber].tex); DrawingHelper.StrokeRect(spriteRect, Color.black, 1f); Rect frameLabelRect = new Rect(1.0f, spritePosY, FRAME_LABEL_WIDTH, 15f); GUIStyle labelStyle = new GUIStyle(); labelStyle.normal.textColor = EditorGUIUtility.isProSkin ? Color.white : Color.black; EditorGUI.LabelField(frameLabelRect, frameNumber.ToString(), labelStyle); } catch (Exception e) { Debug.LogException(e); EditorApplication.update -= UpdateState; Close(); } }
private void OnInspectorGUI_Single() { Undo.RecordObject(model, "Mesh Model"); bool isAnyChanged = false; EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); model.mainRenderer = EditorGUILayout.ObjectField(new GUIContent("Main Renderer", "the most important and biggest renderer in hierarchy"), model.mainRenderer, typeof(Renderer), true) as Renderer; bool mainRendererChanged = EditorGUI.EndChangeCheck(); if (model.mainRenderer == null) { model.mainRenderer = MeshModel.FindBiggestRenderer(model.gameObject); } if (model.IsSkinnedModel()) { EditorGUILayout.Space(); if (mainRendererChanged) { model.pivotType = PivotType.Bottom; } bool isPivotTypeChanged; model.pivotType = DrawPivotTypeField(model, out isPivotTypeChanged); if (isPivotTypeChanged) { UpdateSceneWindow(); } } else { model.pivotType = PivotType.Center; } if (model.isFixingToOrigin && model.isFixingToGround) { GUI.enabled = false; } { bool isGroundPivotChanged; model.isGroundPivot = DrawGroundPivotField(model, out isGroundPivotChanged); if (isGroundPivotChanged) { UpdateSceneWindow(); } } if (model.isFixingToOrigin && model.isFixingToGround) { GUI.enabled = true; } if (model.IsSkinnedModel()) { EditorGUILayout.Space(); EditorGUI.BeginChangeCheck(); model.rootBoneObj = EditorGUILayout.ObjectField(new GUIContent("Root Bone", "root bone object to fix body"), model.rootBoneObj, typeof(Transform), true) as Transform; if (model.rootBoneObj == null) { GUI.enabled = false; } EditorGUI.indentLevel++; { model.isFixingToOrigin = DrawFixToOriginField(model, out isAnyChanged); if (model.isFixingToOrigin) { EditorGUI.indentLevel++; if (model.isGroundPivot) { GUI.enabled = false; } model.isFixingToGround = DrawFixToGroundField(model, out isAnyChanged); if (model.isGroundPivot) { GUI.enabled = true; } EditorGUI.indentLevel--; } } EditorGUI.indentLevel--; if (model.rootBoneObj == null) { GUI.enabled = true; } if (EditorGUI.EndChangeCheck()) { model.Animate(SelectedAnimation, Frame.BEGIN); } } EditorGUILayout.Space(); if (reservedAnimIndex >= 0) { SetAnimationByIndex(reservedAnimIndex); reservedAnimIndex = -1; } Rect animBoxRect = EditorGUILayout.BeginVertical(); serializedObject.Update(); animReorderableList.DoLayoutList(); serializedObject.ApplyModifiedProperties(); EditorGUILayout.EndVertical(); switch (Event.current.type) { case EventType.DragUpdated: case EventType.DragPerform: { if (!animBoxRect.Contains(Event.current.mousePosition)) { break; } DragAndDrop.visualMode = DragAndDropVisualMode.Copy; if (Event.current.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); foreach (object draggedObj in DragAndDrop.objectReferences) { AnimationClip clip = draggedObj as AnimationClip; if (clip != null) { MeshAnimation anim = new MeshAnimation(); anim.clip = clip; anim.selectedFrames = new List <Frame>(); model.AddAnimation(anim); } } } } Event.current.Use(); break; } if (model.animations.Count > 0 && DrawingHelper.DrawMiddleButton("Clear all")) { model.animations.Clear(); } EditorGUILayout.Space(); DrawReferenceControllerField(); if (model.referenceController != null) { EditorGUI.indentLevel++; model.outputController = EditorGUILayout.ObjectField(new GUIContent("Output Controller", "controller to which a baker saves animation states related to the animation list's animations"), model.outputController, typeof(AnimatorController), false) as AnimatorController; EditorGUI.indentLevel--; } EditorGUILayout.Space(); model.spritePrefab = DrawSpritePrefabField(model, out isAnyChanged); if (model.spritePrefab != null) { EditorGUI.indentLevel++; model.prefabBuilder = DrawPrefabBuilderField(model, out isAnyChanged); EditorGUI.indentLevel--; } EditorGUILayout.Space(); if (SelectedAnimation != null) { SelectedAnimation.customizer = EditorGUILayout.ObjectField(new GUIContent("Customizer", "component that customizes this model at every frames in the selected animation"), SelectedAnimation.customizer, typeof(AnimationCustomizer), true) as AnimationCustomizer; } EditorGUILayout.Space(); bool isNameSuffixChanged; model.nameSuffix = DrawModelNameSuffix(model, out isNameSuffixChanged); if (isNameSuffixChanged) { PathHelper.CorrectPathString(ref model.nameSuffix); } EditorGUILayout.Space(); if (DrawingHelper.DrawWideButton("Add to the model list")) { AddToModelList(model); } }
private static void DrawBakingProgress(int editorWidth, int editorHeight, GUIStyle titleStyle, List <Model> bakingModels, Batcher batcher) { const float HELP_BOX_HEIGHT = 54; // help box + two spaces const float TITLE_HEIGHT = 30; // title label + two spaces const float BOTTOM_AREA_HEIGHT = 34; // cancel button + two spaces float maxBodyAreaHeight = editorHeight - HELP_BOX_HEIGHT - TITLE_HEIGHT - BOTTOM_AREA_HEIGHT; float FIELD_HEIGHT = 16; float computedBodyHeight = 0; for (int i = 0; i < bakingModels.Count; ++i) { computedBodyHeight += FIELD_HEIGHT; Model model = bakingModels[i]; if (Model.IsMeshModel(model)) { computedBodyHeight += Model.AsMeshModel(model).GetValidAnimations().Count *FIELD_HEIGHT; } } float bodyAreaHeight = Mathf.Min(computedBodyHeight, maxBodyAreaHeight); Rect titleRect = EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField(string.Format("Baking.. ({0}/{1})", batcher.ModelIndex, bakingModels.Count), titleStyle, GUILayout.Height(TITLE_HEIGHT + bodyAreaHeight)); EditorGUILayout.EndVertical(); float bodyY = titleRect.y + TITLE_HEIGHT; int firstModelIndex = 0; if (computedBodyHeight > maxBodyAreaHeight) { float simulatedBodyHeight = 0; for (int i = 0; i < bakingModels.Count; ++i) { float totalModelHeight = FIELD_HEIGHT; Model model = bakingModels[i]; if (Model.IsMeshModel(model)) { totalModelHeight += Model.AsMeshModel(model).GetValidAnimations().Count *FIELD_HEIGHT; } float thresholdHeight = totalModelHeight + FIELD_HEIGHT * 2; // extra two for baking one & post ellipsis; if (simulatedBodyHeight + thresholdHeight < maxBodyAreaHeight) { simulatedBodyHeight += totalModelHeight; } else { if (i > batcher.ModelIndex) { break; } firstModelIndex++; if (firstModelIndex == 1) { simulatedBodyHeight += FIELD_HEIGHT; // for pre ellipsis } } } } Debug.Assert(firstModelIndex < bakingModels.Count); GUIStyle labelStyle = new GUIStyle(); labelStyle.normal.textColor = EditorGUIUtility.isProSkin ? Color.white : Color.black; { // progress bar int totalTargetCount = 0; int ongoingTargetCount = 0; for (int i = 0; i < bakingModels.Count; ++i) { Model model = bakingModels[i]; if (Model.IsMeshModel(model)) { int validAnimationCount = Model.AsMeshModel(model).GetValidAnimations().Count; if (validAnimationCount > 0) { totalTargetCount += validAnimationCount; if (i < batcher.ModelIndex) { ongoingTargetCount += validAnimationCount; } else if (i == batcher.ModelIndex) { MeshBaker animationBaker = batcher.CurrentBaker as MeshBaker; if (animationBaker != null) { ongoingTargetCount += animationBaker.AnimationIndex; } } } else { totalTargetCount++; if (i <= batcher.ModelIndex) { ongoingTargetCount++; } } } else { totalTargetCount++; if (i <= batcher.ModelIndex) { ongoingTargetCount++; } } } float progress = (float)ongoingTargetCount / (float)totalTargetCount; const float PROGRESS_BAR_WIDTH = 10; Rect progressBarBgRect = new Rect(editorWidth, bodyY, PROGRESS_BAR_WIDTH, bodyAreaHeight); DrawingHelper.FillRect(progressBarBgRect, EditorGUIUtility.isProSkin ? lightGrayColor : darkGrayColor); Rect progressBarFgRect = new Rect(editorWidth, bodyY, PROGRESS_BAR_WIDTH, bodyAreaHeight * progress); DrawingHelper.FillRect(progressBarFgRect, EditorGUIUtility.isProSkin ? Color.white : Color.black); labelStyle.alignment = TextAnchor.MiddleRight; float progressLabelY = bodyY + bodyAreaHeight * progress - (FIELD_HEIGHT / 2); Rect progressLabelRect = new Rect(14, progressLabelY, editorWidth - 17, FIELD_HEIGHT); EditorGUI.LabelField(progressLabelRect, string.Format("{0:0}%", progress * 100), labelStyle); } labelStyle.alignment = TextAnchor.MiddleLeft; float FIELD_X = 14; float bodyHeight = 0; if (firstModelIndex > 0) { Rect ellipsisRect = new Rect(FIELD_X, bodyY + bodyHeight, editorWidth, FIELD_HEIGHT); EditorGUI.indentLevel++; EditorGUI.indentLevel++; EditorGUI.LabelField(ellipsisRect, "...", labelStyle); EditorGUI.indentLevel--; EditorGUI.indentLevel--; bodyHeight += FIELD_HEIGHT; } for (int mi = firstModelIndex; mi < bakingModels.Count; ++mi) { if (bodyHeight + FIELD_HEIGHT > maxBodyAreaHeight) { return; } Model model = bakingModels[mi]; Rect modelRect = new Rect(FIELD_X, bodyY + bodyHeight, editorWidth, FIELD_HEIGHT); bodyHeight += FIELD_HEIGHT; FieldState state = FieldState.None; if (mi < batcher.ModelIndex) { state = FieldState.Completed; } else if (mi == batcher.ModelIndex) { state = FieldState.Baking; } bool elliptical = false; if (bodyHeight + FIELD_HEIGHT > maxBodyAreaHeight) { if (mi < bakingModels.Count - 1) { elliptical = true; } } string labelText; if (elliptical) { labelText = "..."; } else { labelText = mi.ToString() + ". " + model.name; if (model.nameSuffix.Length > 0) { labelText += model.nameSuffix; } } labelStyle.fontStyle = GetLabelFontStyle(state); EditorGUI.indentLevel++; EditorGUI.LabelField(modelRect, labelText, labelStyle); EditorGUI.indentLevel--; if (state == FieldState.Completed && !elliptical) { DrawCheckMark(modelRect); } if (Model.IsMeshModel(model)) { MeshModel meshModel = Model.AsMeshModel(model); List <MeshAnimation> validAnimations = meshModel.GetValidAnimations(); for (int ai = 0; ai < validAnimations.Count; ++ai) { if (bodyHeight + FIELD_HEIGHT > maxBodyAreaHeight) { return; } MeshAnimation anim = validAnimations[ai]; MeshBaker animationBaker = batcher.CurrentBaker as MeshBaker; Rect animationRect = new Rect(FIELD_X, bodyY + bodyHeight, editorWidth, FIELD_HEIGHT); bodyHeight += FIELD_HEIGHT; state = FieldState.None; if (mi < batcher.ModelIndex || (mi == batcher.ModelIndex && (animationBaker != null && ai < animationBaker.AnimationIndex))) { state = FieldState.Completed; } else if (mi == batcher.ModelIndex && (animationBaker != null && ai == animationBaker.AnimationIndex)) { state = FieldState.Baking; } elliptical = false; if (bodyHeight + FIELD_HEIGHT > maxBodyAreaHeight) { if (mi < bakingModels.Count - 1 || ai < validAnimations.Count - 1) { elliptical = true; } } if (elliptical) { labelText = "..."; } else { labelText = (meshModel.referenceController != null) ? anim.stateName : anim.clip.name; } labelStyle.fontStyle = GetLabelFontStyle(state); EditorGUI.indentLevel++; EditorGUI.indentLevel++; EditorGUI.LabelField(animationRect, labelText, labelStyle); EditorGUI.indentLevel--; EditorGUI.indentLevel--; if (state == FieldState.Completed && !elliptical) { DrawCheckMark(animationRect, 10); } } } } }
private void OnInspectorGUI_Single() { Undo.RecordObject(model, "Particle Model"); bool isAnyChanged = false; EditorGUI.BeginChangeCheck(); model.mainParticleSystem = EditorGUILayout.ObjectField("Main Particle System", model.mainParticleSystem, typeof(ParticleSystem), true) as ParticleSystem; if (EditorGUI.EndChangeCheck()) { model.targetChecked = false; } if (model.mainParticleSystem == null) { model.TrySetMainParticleSystem(); } if (model.mainParticleSystem != null) { if (!model.targetChecked) { model.CheckModel(); } if (model.animationClip != null) { EditorGUI.indentLevel++; GUI.enabled = false; EditorGUILayout.FloatField("Duration", model.mainParticleSystem.main.duration, EditorStyles.label); GUI.enabled = true; EditorGUI.indentLevel--; } } EditorGUILayout.Space(); model.isGroundPivot = DrawGroundPivotField(model, out isAnyChanged); EditorGUILayout.Space(); model.isLooping = DrawLoopingField(model, out isAnyChanged); if (model.isLooping) { EditorGUI.indentLevel++; model.isPrewarm = DrawPrewarmField(model, out isAnyChanged); EditorGUI.indentLevel--; } EditorGUILayout.Space(); model.spritePrefab = DrawSpritePrefabField(model, out isAnyChanged); if (model.spritePrefab != null) { EditorGUI.indentLevel++; model.prefabBuilder = DrawPrefabBuilderField(model, out isAnyChanged); EditorGUI.indentLevel--; } EditorGUILayout.Space(); bool isNameSuffixChanged; model.nameSuffix = DrawModelNameSuffix(model, out isNameSuffixChanged); if (isNameSuffixChanged) { PathHelper.CorrectPathString(ref model.nameSuffix); } EditorGUILayout.Space(); if (DrawingHelper.DrawWideButton("Add to the model list")) { AddToModelList(model); } }
protected void OnInspectorGUI_Multi() { EditorGUILayout.HelpBox("Displayed information is of the first selected model,\nbut any change affects all selected models.", MessageType.Info); ParticleModel[] models = new ParticleModel[targets.Length]; for (int i = 0; i < models.Length; ++i) { models[i] = targets[i] as ParticleModel; } ParticleModel firstModel = models[0]; EditorGUILayout.Space(); bool isGroundPivotChanged; bool isGroundPivot = DrawGroundPivotField(firstModel, out isGroundPivotChanged); EditorGUILayout.Space(); bool isLoopingChanged; bool isLooping = DrawLoopingField(firstModel, out isLoopingChanged); bool isAllLooping = true; foreach (ParticleModel model in models) { isAllLooping &= model.isLooping; } bool isPrewarmChanged = false; bool isPrewarm = false; if (isAllLooping) { EditorGUI.indentLevel++; isPrewarm = DrawPrewarmField(firstModel, out isPrewarmChanged); EditorGUI.indentLevel--; } EditorGUILayout.Space(); bool isSpritePrefabChanged; GameObject spritePrefab = DrawSpritePrefabField(firstModel, out isSpritePrefabChanged); bool hasAllSpritePrefab = true; foreach (ParticleModel model in models) { hasAllSpritePrefab &= (model.spritePrefab != null); } PrefabBuilder prefabBuilder = null; bool isPrefabBuilderChanged = false; if (hasAllSpritePrefab) { EditorGUI.indentLevel++; prefabBuilder = DrawPrefabBuilderField(model, out isPrefabBuilderChanged); EditorGUI.indentLevel--; } EditorGUILayout.Space(); bool isNameSuffixChanged; string nameSuffix = DrawModelNameSuffix(firstModel, out isNameSuffixChanged); if (isNameSuffixChanged) { PathHelper.CorrectPathString(ref nameSuffix); } if (isGroundPivotChanged || isLoopingChanged || isPrewarmChanged || isSpritePrefabChanged || isPrefabBuilderChanged || isNameSuffixChanged) { foreach (ParticleModel model in models) { Undo.RecordObject(model, "Particle Model"); if (isGroundPivotChanged) { model.isGroundPivot = isGroundPivot; } if (isLoopingChanged) { model.isLooping = isLooping; } if (isPrewarmChanged) { model.isPrewarm = isPrewarm; } if (isSpritePrefabChanged) { model.spritePrefab = spritePrefab; } if (hasAllSpritePrefab && isPrefabBuilderChanged) { model.prefabBuilder = prefabBuilder; } if (isNameSuffixChanged) { model.nameSuffix = nameSuffix; } } } Studio studio = FindObjectOfType <Studio>(); if (studio == null) { return; } EditorGUILayout.Space(); if (DrawingHelper.DrawWideButton("Add all to the model list")) { foreach (ParticleModel model in models) { AddToModelList(model); } } }
void OnGUI() { try { if (frames == null || studio == null) { return; } if (studio.samplings.Count == 0) { return; } int texWidth = studio.samplings[0].tex.width; int texHeight = studio.samplings[0].tex.height; float padding = 10.0f; int colSize = Mathf.FloorToInt(Screen.width / (texWidth + padding)); if (colSize < 1) { colSize = 1; } if (studio.samplings.Count > 1) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Select all")) { frames.Clear(); for (int i = 0; i < studio.samplings.Count; ++i) { frames.Add(new Frame(i, studio.samplings[i].time)); } } if (GUILayout.Button("Select each half")) { int modular = 0; if (frames.Count >= 2) { if (frames[0].index == 0) { modular = 1; } else if (frames[0].index == 1) { modular = 0; } } frames.Clear(); for (int i = 0; i < studio.samplings.Count; ++i) { if (i % 2 == modular) { frames.Add(new Frame(i, studio.samplings[i].time)); } } } if (GUILayout.Button("Clear all")) { frames.Clear(); } GUILayout.EndHorizontal(); } GUILayout.Space(padding); whatPos = GUILayout.BeginScrollView(whatPos); { Rect rect = new Rect(padding, 0, texWidth, texHeight); int col = 0; int rowCount = 0; for (int smpi = 0; smpi < studio.samplings.Count; ++smpi) { Sampling sampling = studio.samplings[smpi]; if (col >= colSize) { col = 0; rowCount++; rect.x = padding; rect.y += texHeight + padding + LABEL_HEIGHT; GUILayout.EndHorizontal(); GUILayout.Space(texHeight + padding); } if (col == 0) { GUILayout.BeginHorizontal(); } if (GUI.Button(rect, "")) { if (frames.Count == 0) { frames.Add(new Frame(smpi, sampling.time)); } else { bool exist = false; foreach (Frame selectedFrame in frames) { if (smpi == selectedFrame.index) { exist = true; break; } } int inserti = 0; for (; inserti < frames.Count; ++inserti) { if (smpi < frames[inserti].index) { break; } } if (exist) { frames.Remove(new Frame(smpi, 0)); } else { frames.Insert(inserti, new Frame(smpi, sampling.time)); } } } EditorGUI.DrawTextureTransparent(rect, sampling.tex); foreach (Frame selectedFrame in frames) { if (selectedFrame.index == smpi) { DrawingHelper.StrokeRect(rect, Color.red, 2.0f); break; } } GUI.backgroundColor = new Color(1f, 1f, 1f, 0.5f); GUI.contentColor = new Color(1f, 1f, 1f, 0.7f); GUI.Label(new Rect(rect.x, rect.y + rect.height, rect.width, LABEL_HEIGHT), smpi.ToString(), "ProgressBarBack"); GUI.contentColor = Color.white; GUI.backgroundColor = Color.white; col++; rect.x += texWidth + padding; } GUILayout.EndHorizontal(); GUILayout.Space(texHeight + padding); GUILayout.Space(rowCount * 26); } GUILayout.EndScrollView(); } catch (Exception e) { Debug.LogException(e); Close(); } }