static void DrawMaterialListElements(MeshSyncPlayer t) { // calculate label width float labelWidth = 60; // minimum { var style = GUI.skin.box; foreach (var md in t.materialList) { var size = style.CalcSize(new GUIContent(md.name)); labelWidth = Mathf.Max(labelWidth, size.x); } // 100: margin for color and material field labelWidth = Mathf.Min(labelWidth, EditorGUIUtility.currentViewWidth - 100); } foreach (var md in t.materialList) { var rect = EditorGUILayout.BeginHorizontal(); EditorGUI.DrawRect(new Rect(rect.x, rect.y, 16, 16), md.color); EditorGUILayout.LabelField("", GUILayout.Width(16)); EditorGUILayout.LabelField(md.name, GUILayout.Width(labelWidth)); { var tmp = EditorGUILayout.ObjectField(md.material, typeof(Material), true) as Material; if (tmp != md.material) { t.AssignMaterial(md, tmp); } } EditorGUILayout.EndHorizontal(); } }
public static void Open(MeshSyncPlayer server) { var window = (MaterialWindow)EditorWindow.GetWindow(typeof(MaterialWindow)); window.titleContent = new GUIContent("Material List"); window.m_server = server; window.Show(); }
public static void DrawMaterialList(MeshSyncPlayer t, bool allowFold = true) { Action drawInExportButton = () => { GUILayout.BeginHorizontal(); if (GUILayout.Button("Import List", GUILayout.Width(110.0f))) { var path = EditorUtility.OpenFilePanel("Import material list", "Assets", "asset"); t.ImportMaterialList(path); } if (GUILayout.Button("Export List", GUILayout.Width(110.0f))) { var path = EditorUtility.SaveFilePanel("Export material list", "Assets", t.name + "_MaterialList", "asset"); t.ExportMaterialList(path); } GUILayout.EndHorizontal(); }; if (allowFold) { var styleFold = EditorStyles.foldout; styleFold.fontStyle = FontStyle.Bold; t.foldMaterialList = EditorGUILayout.Foldout(t.foldMaterialList, "Materials", true, styleFold); if (t.foldMaterialList) { DrawMaterialListElements(t); drawInExportButton(); if (GUILayout.Button("Open Material Window", GUILayout.Width(160.0f))) { MaterialWindow.Open(t); } EditorGUILayout.Space(); } } else { GUILayout.Label("Materials", EditorStyles.boldLabel); DrawMaterialListElements(t); drawInExportButton(); } }
void OnRecvQuery(QueryMessage data) { switch (data.queryType) { case QueryMessage.QueryType.PluginVersion: data.AddResponseText(MeshSyncPlayer.GetPluginVersion()); break; case QueryMessage.QueryType.ProtocolVersion: data.AddResponseText(MeshSyncPlayer.protocolVersion.ToString()); break; case QueryMessage.QueryType.HostName: data.AddResponseText("Unity " + Application.unityVersion); break; case QueryMessage.QueryType.RootNodes: { var roots = UnityEngine.SceneManagement.SceneManager.GetActiveScene().GetRootGameObjects(); foreach (var go in roots) { data.AddResponseText(BuildPath(go.GetComponent <Transform>())); } } break; case QueryMessage.QueryType.AllNodes: { var objects = FindObjectsOfType <Transform>(); foreach (var go in objects) { data.AddResponseText(BuildPath(go.GetComponent <Transform>())); } } break; default: break; } data.FinishRespond(); }
public static void DrawExportAssets(MeshSyncPlayer t) { var style = EditorStyles.foldout; style.fontStyle = FontStyle.Bold; t.foldExportAssets = EditorGUILayout.Foldout(t.foldExportAssets, "Export Assets", true, style); if (t.foldExportAssets) { GUILayout.BeginHorizontal(); if (GUILayout.Button("Export Meshes", GUILayout.Width(160.0f))) { t.ExportMeshes(); } if (GUILayout.Button("Export Materials", GUILayout.Width(160.0f))) { t.ExportMaterials(); } GUILayout.EndHorizontal(); } EditorGUILayout.Space(); }
public static void DrawPluginVersion() { EditorGUILayout.LabelField("Plugin Version: " + MeshSyncPlayer.GetPluginVersion()); }
//---------------------------------------------------------------------------------------------------------------------- protected void DrawPlayerSettings(MeshSyncPlayer t, SerializedObject so) { var styleFold = EditorStyles.foldout; styleFold.fontStyle = FontStyle.Bold; // Asset Sync Settings t.foldSyncSettings = EditorGUILayout.Foldout(t.foldSyncSettings, "Asset Sync Settings", true, styleFold); MeshSyncPlayerConfig playerConfig = m_asset.GetConfig(); if (t.foldSyncSettings) { EditorGUIToggle("Visibility", ref playerConfig.SyncVisibility); EditorGUIToggle("Transform", ref playerConfig.SyncTransform); EditorGUIToggle("Cameras", ref playerConfig.SyncCameras); if (playerConfig.SyncCameras) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(so.FindProperty("m_usePhysicalCameraParams"), new GUIContent("Physical Camera Params")); //EditorGUILayout.PropertyField(so.FindProperty("m_useCustomCameraMatrices"), new GUIContent("Custom View/Proj Matrices")); EditorGUI.indentLevel--; } EditorGUIToggle("Lights", ref playerConfig.SyncLights); EditorGUIToggle("Meshes", ref playerConfig.SyncMeshes); EditorGUI.indentLevel++; EditorGUIToggle("Update Mesh Colliders", ref playerConfig.UpdateMeshColliders); EditorGUI.indentLevel--; //EditorGUILayout.PropertyField(so.FindProperty("m_syncPoints"), new GUIContent("Points")); EditorGUIToggle("Materials", ref playerConfig.SyncMaterials); EditorGUI.indentLevel++; EditorGUIToggle("Find From AssetDatabase", ref playerConfig.FindMaterialFromAssets); EditorGUI.indentLevel--; EditorGUILayout.Space(); } // Import Settings t.foldImportSettings = EditorGUILayout.Foldout(t.foldImportSettings, "Import Settings", true, styleFold); if (t.foldImportSettings) { EditorGUIPopup(new GUIContent("Animation Interpolation"), m_animationInterpolationEnums, ref playerConfig.AnimationInterpolation ); EditorGUIToggle("Keyframe Reduction", ref playerConfig.KeyframeReduction); if (playerConfig.KeyframeReduction) { EditorGUI.indentLevel++; EditorGUIFloatField("Threshold", ref playerConfig.ReductionThreshold); EditorGUIToggle("Erase Flat Curves", ref playerConfig.ReductionEraseFlatCurves); EditorGUI.indentLevel--; } EditorGUIPopup(new GUIContent("Z-Up Correction"), m_zUpCorrectionEnums, ref playerConfig.ZUpCorrection); EditorGUILayout.Space(); } // Misc t.foldMisc = EditorGUILayout.Foldout(t.foldMisc, "Misc", true, styleFold); if (t.foldMisc) { EditorGUIToggle("Sync Material List", ref playerConfig.SyncMaterialList); EditorGUIToggle("Progressive Display", ref playerConfig.ProgressiveDisplay); EditorGUIToggle("Logging", ref playerConfig.Logging); EditorGUIToggle("Profiling", ref playerConfig.Profiling); EditorGUILayout.Space(); } }
//---------------------------------------------------------------------------------------------------------------------- protected static void DrawAnimationTweak(MeshSyncPlayer player) { GUIStyle styleFold = EditorStyles.foldout; styleFold.fontStyle = FontStyle.Bold; player.foldAnimationTweak = EditorGUILayout.Foldout(player.foldAnimationTweak, "Animation Tweak", true, styleFold); if (player.foldAnimationTweak) { MeshSyncPlayerConfig config = player.GetConfig(); AnimationTweakSettings animationTweakSettings = config.GetAnimationTweakSettings(); float frameRate = 30.0f; List <AnimationClip> clips = player.GetAnimationClips(); if (clips.Count > 0) { frameRate = clips[0].frameRate; } { // Override Frame Rate GUILayout.BeginVertical("Box"); EditorGUILayout.LabelField("Override Frame Rate", EditorStyles.boldLabel); EditorGUI.indentLevel++; float prevFrameRate = frameRate; frameRate = EditorGUILayout.FloatField("Frame Rate", frameRate); if (!Mathf.Approximately(prevFrameRate, frameRate) && frameRate > 0) { ApplyFrameRate(clips, frameRate); } EditorGUI.indentLevel--; GUILayout.EndVertical(); } // Time Scale { GUILayout.BeginVertical("Box"); EditorGUILayout.LabelField("Time Scale", EditorStyles.boldLabel); EditorGUI.indentLevel++; float prevTimeScale = animationTweakSettings.TimeScale; float prevTimeOffset = animationTweakSettings.TimeOffset; EditorGUIFloatField("Scale", ref animationTweakSettings.TimeScale); EditorGUIFloatField("Offset", ref animationTweakSettings.TimeOffset); if (!Mathf.Approximately(prevTimeScale, animationTweakSettings.TimeScale) || !Mathf.Approximately(prevTimeOffset, animationTweakSettings.TimeOffset) ) { ApplyTimeScale(clips, animationTweakSettings.TimeScale, animationTweakSettings.TimeOffset ); } EditorGUI.indentLevel--; GUILayout.EndVertical(); } // Drop Keyframes { GUILayout.BeginVertical("Box"); EditorGUILayout.LabelField("Drop Keyframes", EditorStyles.boldLabel); EditorGUI.indentLevel++; int prevDropStep = animationTweakSettings.DropStep; EditorGUIIntField("Step", ref animationTweakSettings.DropStep); if (prevDropStep != animationTweakSettings.DropStep && animationTweakSettings.DropStep > 1) { ApplyDropKeyframes(clips, animationTweakSettings.DropStep); } EditorGUI.indentLevel--; GUILayout.EndVertical(); } // Keyframe Reduction { GUILayout.BeginVertical("Box"); EditorGUILayout.LabelField("Keyframe Reduction", EditorStyles.boldLabel); EditorGUI.indentLevel++; float prevReductionThreshold = animationTweakSettings.ReductionThreshold; bool prevEraseFlatCurves = animationTweakSettings.EraseFlatCurves; EditorGUIFloatField("Threshold", ref animationTweakSettings.ReductionThreshold); EditorGUIToggle("Erase Flat Curves", ref animationTweakSettings.EraseFlatCurves); if (!Mathf.Approximately(prevReductionThreshold, animationTweakSettings.ReductionThreshold) || prevEraseFlatCurves != animationTweakSettings.EraseFlatCurves) { ApplyKeyframeReduction(clips, animationTweakSettings.ReductionThreshold, animationTweakSettings.EraseFlatCurves ); } EditorGUI.indentLevel--; GUILayout.EndVertical(); } EditorGUILayout.Space(); } }
public static void DrawTextureList(MeshSyncPlayer t) { }
public static void DrawPlayerSettings(MeshSyncPlayer t, SerializedObject so) { var styleFold = EditorStyles.foldout; styleFold.fontStyle = FontStyle.Bold; // Sync Settings t.foldSyncSettings = EditorGUILayout.Foldout(t.foldSyncSettings, "Sync Settings", true, styleFold); if (t.foldSyncSettings) { EditorGUILayout.PropertyField(so.FindProperty("m_syncVisibility"), new GUIContent("Visibility")); EditorGUILayout.PropertyField(so.FindProperty("m_syncTransform"), new GUIContent("Transform")); EditorGUILayout.PropertyField(so.FindProperty("m_syncCameras"), new GUIContent("Cameras")); if (t.syncCameras) { EditorGUI.indentLevel++; #if UNITY_2018_1_OR_NEWER EditorGUILayout.PropertyField(so.FindProperty("m_usePhysicalCameraParams"), new GUIContent("Physical Camera Params")); #endif //EditorGUILayout.PropertyField(so.FindProperty("m_useCustomCameraMatrices"), new GUIContent("Custom View/Proj Matrices")); EditorGUI.indentLevel--; } EditorGUILayout.PropertyField(so.FindProperty("m_syncLights"), new GUIContent("Lights")); EditorGUILayout.PropertyField(so.FindProperty("m_syncMeshes"), new GUIContent("Meshes")); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(so.FindProperty("m_updateMeshColliders")); EditorGUI.indentLevel--; //EditorGUILayout.PropertyField(so.FindProperty("m_syncPoints"), new GUIContent("Points")); EditorGUILayout.PropertyField(so.FindProperty("m_syncMaterials"), new GUIContent("Materials")); EditorGUI.indentLevel++; EditorGUILayout.PropertyField(so.FindProperty("m_findMaterialFromAssets"), new GUIContent("Find From AssetDatabase")); EditorGUI.indentLevel--; EditorGUILayout.Space(); } // Import Settings t.foldImportSettings = EditorGUILayout.Foldout(t.foldImportSettings, "Import Settings", true, styleFold); if (t.foldImportSettings) { EditorGUILayout.PropertyField(so.FindProperty("m_animationInterpolation")); EditorGUILayout.PropertyField(so.FindProperty("m_keyframeReduction")); if (t.keyframeReduction) { EditorGUI.indentLevel++; EditorGUILayout.PropertyField(so.FindProperty("m_reductionThreshold"), new GUIContent("Threshold")); EditorGUILayout.PropertyField(so.FindProperty("m_reductionEraseFlatCurves"), new GUIContent("Erase Flat Curves")); EditorGUI.indentLevel--; } EditorGUILayout.PropertyField(so.FindProperty("m_zUpCorrection"), new GUIContent("Z-Up Correction")); EditorGUILayout.Space(); } // Misc t.foldMisc = EditorGUILayout.Foldout(t.foldMisc, "Misc", true, styleFold); if (t.foldMisc) { EditorGUILayout.PropertyField(so.FindProperty("m_syncMaterialList")); EditorGUILayout.PropertyField(so.FindProperty("m_progressiveDisplay")); EditorGUILayout.PropertyField(so.FindProperty("m_logging")); EditorGUILayout.PropertyField(so.FindProperty("m_profiling")); EditorGUILayout.Space(); } }
public void DrawAnimationTweak(MeshSyncPlayer t) { var styleFold = EditorStyles.foldout; styleFold.fontStyle = FontStyle.Bold; t.foldAnimationTweak = EditorGUILayout.Foldout(t.foldAnimationTweak, "Animation Tweak", true, styleFold); if (t.foldAnimationTweak) { // Override Frame Rate GUILayout.BeginVertical("Box"); EditorGUILayout.LabelField("Override Frame Rate", EditorStyles.boldLabel); EditorGUI.indentLevel++; m_animationFrameRate = EditorGUILayout.FloatField("Frame Rate", m_animationFrameRate); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Apply", GUILayout.Width(120.0f))) { ApplyFrameRate(t.GetAnimationClips(), m_animationFrameRate); } GUILayout.EndHorizontal(); EditorGUI.indentLevel--; GUILayout.EndVertical(); // Time Scale GUILayout.BeginVertical("Box"); EditorGUILayout.LabelField("Time Scale", EditorStyles.boldLabel); EditorGUI.indentLevel++; m_animationTimeScale = EditorGUILayout.FloatField("Scale", m_animationTimeScale); m_animationTimeOffset = EditorGUILayout.FloatField("Offset", m_animationTimeOffset); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Apply", GUILayout.Width(120.0f))) { ApplyTimeScale(t.GetAnimationClips(), m_animationTimeScale, m_animationTimeOffset); } GUILayout.EndHorizontal(); EditorGUI.indentLevel--; GUILayout.EndVertical(); // Drop Keyframes GUILayout.BeginVertical("Box"); EditorGUILayout.LabelField("Drop Keyframes", EditorStyles.boldLabel); EditorGUI.indentLevel++; m_animationDropStep = EditorGUILayout.IntField("Step", m_animationDropStep); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Apply", GUILayout.Width(120.0f))) { ApplyDropKeyframes(t.GetAnimationClips(), m_animationDropStep); } GUILayout.EndHorizontal(); EditorGUI.indentLevel--; GUILayout.EndVertical(); // Keyframe Reduction GUILayout.BeginVertical("Box"); EditorGUILayout.LabelField("Keyframe Reduction", EditorStyles.boldLabel); EditorGUI.indentLevel++; m_reductionThreshold = EditorGUILayout.FloatField("Threshold", m_reductionThreshold); m_eraseFlatCurves = EditorGUILayout.Toggle("Erase Flat Curves", m_eraseFlatCurves); GUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Apply", GUILayout.Width(120.0f))) { ApplyKeyframeReduction(t.GetAnimationClips(), m_reductionThreshold, m_eraseFlatCurves); } GUILayout.EndHorizontal(); EditorGUI.indentLevel--; GUILayout.EndVertical(); EditorGUILayout.Space(); } }