Ejemplo n.º 1
0
        public void DrawDCCMenu(BaseMeshSync player)
        {
            var server = player as MeshSyncServer;

            if (server == null)
            {
                return;
            }

            GUILayout.BeginVertical("Box");

            if (HandleBlenderPath(server))
            {
                GUILayout.EndVertical();
                return;
            }

            HandleRunMmode(server);

            HandleRedirect(server);

            GUILayout.EndVertical();

            EditorGUILayout.Space();
        }
Ejemplo n.º 2
0
//----------------------------------------------------------------------------------------------------------------------
        internal static bool DrawMaterialList(BaseMeshSync t, bool allowFold = true)
        {
            //[TODO-sin: 2021-12-7] Refactor. Remove allowFold
            bool changed = false;

            if (allowFold)
            {
                var styleFold = EditorStyles.foldout;
                styleFold.fontStyle = FontStyle.Bold;
                t.foldMaterialList  = EditorGUILayout.Foldout(t.foldMaterialList, "Materials", true, styleFold);
                if (!t.foldMaterialList)
                {
                    return(false);
                }

                changed = DrawMaterialListElements(t);
                DrawMaterialImportExportButtons(t);
                if (GUILayout.Button("Open Material Window", GUILayout.Width(160.0f)))
                {
                    MaterialWindow.Open(t);
                }
                EditorGUILayout.Space();
            }
            else
            {
                GUILayout.Label("Materials", EditorStyles.boldLabel);
                changed = DrawMaterialListElements(t);
                DrawMaterialImportExportButtons(t);
            }

            return(changed);
        }
Ejemplo n.º 3
0
        protected static bool DrawMiscSettings(BaseMeshSync t)
        {
            bool changed = false;
            MeshSyncPlayerConfig playerConfig = t.GetConfigV();

            // Misc
            t.foldMisc = EditorGUILayout.Foldout(t.foldMisc, "Misc", true, GetBoldFoldoutStyle());
            if (t.foldMisc)
            {
                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Sync Material List",
                                                                  guiFunc: () => EditorGUILayout.Toggle("Sync Material List", playerConfig.SyncMaterialList),
                                                                  updateFunc: (bool toggle) => { playerConfig.SyncMaterialList = toggle; }
                                                                  );

                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Progressive Display",
                                                                  guiFunc: () => EditorGUILayout.Toggle("Progressive Display", playerConfig.ProgressiveDisplay),
                                                                  updateFunc: (bool toggle) => { playerConfig.ProgressiveDisplay = toggle; }
                                                                  );


                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Logging",
                                                                  guiFunc: () => EditorGUILayout.Toggle("Logging", playerConfig.Logging),
                                                                  updateFunc: (bool toggle) => { playerConfig.Logging = toggle; }
                                                                  );

                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Profiling",
                                                                  guiFunc: () => EditorGUILayout.Toggle("Profiling", playerConfig.Profiling),
                                                                  updateFunc: (bool toggle) => { playerConfig.Profiling = toggle; }
                                                                  );

                EditorGUILayout.Space();
            }

            return(changed);
        }
Ejemplo n.º 4
0
        internal static bool DrawSimpleMaterialList(BaseMeshSync t)
        {
            GUILayout.Label("Materials", EditorStyles.boldLabel);
            bool changed = DrawMaterialListElements(t);

            DrawMaterialImportExportButtons(t);
            return(changed);
        }
Ejemplo n.º 5
0
        public static void Open(BaseMeshSync server)
        {
            var window = (MaterialWindow)EditorWindow.GetWindow(typeof(MaterialWindow));

            window.titleContent = new GUIContent("Material List");
            window.m_server     = server;
            window.Show();
        }
Ejemplo n.º 6
0
//----------------------------------------------------------------------------------------------------------------------

        protected static bool DrawAssetSyncSettings(BaseMeshSync t)
        {
            t.foldSyncSettings = EditorGUILayout.Foldout(t.foldSyncSettings, "Asset Sync Settings", true, GetBoldFoldoutStyle());
            MeshSyncPlayerConfig config = t.GetConfigV();

            if (!t.foldSyncSettings)
            {
                return(false);
            }

            bool changed = false;

            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Sync Transform",
                                                              guiFunc: () => EditorGUILayout.Toggle("Update Transform", config.SyncTransform),
                                                              updateFunc: (bool toggle) => { config.SyncTransform = toggle; }
                                                              );

            ComponentSyncSettings syncCameraSettings = config.GetComponentSyncSettings(MeshSyncPlayerConfig.SYNC_CAMERA);

            changed |= MeshSyncInspectorUtility.DrawComponentSyncSettings(t, "Cameras", syncCameraSettings);

            using (new EditorGUI.DisabledScope(!(syncCameraSettings.CanCreate && syncCameraSettings.CanUpdate))) {
                EditorGUI.indentLevel++;

                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Physical Camera Params",
                                                                  guiFunc: () => EditorGUILayout.Toggle("Use Physical Params", config.IsPhysicalCameraParamsUsed()),
                                                                  updateFunc: (bool toggle) => { config.UsePhysicalCameraParams(toggle); }
                                                                  );

                EditorGUI.indentLevel--;
            }

            changed |= MeshSyncInspectorUtility.DrawComponentSyncSettings(t, "Lights",
                                                                          config.GetComponentSyncSettings(MeshSyncPlayerConfig.SYNC_LIGHTS));


            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Sync Meshes",
                                                              guiFunc: () => EditorGUILayout.Toggle("Meshes", config.SyncMeshes),
                                                              updateFunc: (bool toggle) => { config.SyncMeshes = toggle; }
                                                              );

            EditorGUI.indentLevel++;
            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Update Mesh Colliders",
                                                              guiFunc: () => EditorGUILayout.Toggle("Update Mesh Colliders", config.UpdateMeshColliders),
                                                              updateFunc: (bool toggle) => { config.UpdateMeshColliders = toggle; }
                                                              );
            EditorGUI.indentLevel--;

            changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Sync Visibility",
                                                              guiFunc: () => EditorGUILayout.Toggle("Visibility", config.SyncVisibility),
                                                              updateFunc: (bool toggle) => { config.SyncVisibility = toggle; }
                                                              );

            EditorGUILayout.Space();

            return(changed);
        }
Ejemplo n.º 7
0
        protected static bool DrawImportSettings(BaseMeshSync t)
        {
            bool changed = false;
            MeshSyncPlayerConfig playerConfig = t.GetConfigV();

            t.foldImportSettings = EditorGUILayout.Foldout(t.foldImportSettings, "Import Settings", true, GetBoldFoldoutStyle());
            if (t.foldImportSettings)
            {
                MeshSyncInspectorUtility.DrawModelImporterSettingsGUI(t, playerConfig.GetModelImporterSettings());

                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Animation Interpolation",
                                                                  guiFunc: () => EditorGUILayout.Popup(new GUIContent("Animation Interpolation"),
                                                                                                       playerConfig.AnimationInterpolation, MeshSyncEditorConstants.ANIMATION_INTERPOLATION_ENUMS),
                                                                  updateFunc: (int val) => { playerConfig.AnimationInterpolation = val; }
                                                                  );


                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Keyframe Reduction",
                                                                  guiFunc: () => EditorGUILayout.Toggle("Keyframe Reduction", playerConfig.KeyframeReduction),
                                                                  updateFunc: (bool toggle) => { playerConfig.KeyframeReduction = toggle; }
                                                                  );

                if (playerConfig.KeyframeReduction)
                {
                    EditorGUI.indentLevel++;

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Threshold",
                                                                      guiFunc: () => EditorGUILayout.FloatField("Threshold", playerConfig.ReductionThreshold),
                                                                      updateFunc: (float val) => { playerConfig.ReductionThreshold = val; }
                                                                      );

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Erase Flat Curves",
                                                                      guiFunc: () => EditorGUILayout.Toggle("Erase Flat Curves", playerConfig.ReductionEraseFlatCurves),
                                                                      updateFunc: (bool toggle) => { playerConfig.ReductionEraseFlatCurves = toggle; }
                                                                      );
                    EditorGUI.indentLevel--;
                }

                changed |= EditorGUIDrawerUtility.DrawUndoableGUI(t, "MeshSync: Z-Up Correction",
                                                                  guiFunc: () => EditorGUILayout.Popup(new GUIContent("Z-Up Correction"), playerConfig.ZUpCorrection,
                                                                                                       MeshSyncEditorConstants.Z_UP_CORRECTION_ENUMS),
                                                                  updateFunc: (int val) => { playerConfig.ZUpCorrection = val; }
                                                                  );

                EditorGUILayout.Space();
            }

            return(changed);
        }
Ejemplo n.º 8
0
        static void DrawMaterialImportExportButtons(BaseMeshSync t)
        {
            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();
        }
Ejemplo n.º 9
0
//----------------------------------------------------------------------------------------------------------------------

        protected static void DrawExportAssets(BaseMeshSync t)
        {
            GUIStyle 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();
        }
Ejemplo n.º 10
0
//----------------------------------------------------------------------------------------------------------------------
        internal static bool DrawDefaultMaterialList(BaseMeshSync t)
        {
            GUIStyle styleFold = EditorStyles.foldout;

            styleFold.fontStyle = FontStyle.Bold;
            t.foldMaterialList  = EditorGUILayout.Foldout(t.foldMaterialList, "Materials", true, styleFold);
            if (!t.foldMaterialList)
            {
                return(false);
            }

            bool changed = DrawMaterialListElements(t);

            DrawMaterialImportExportButtons(t);
            if (GUILayout.Button("Open Material Window", GUILayout.Width(160.0f)))
            {
                MaterialWindow.Open(t);
            }
            EditorGUILayout.Space();

            return(changed);
        }
Ejemplo n.º 11
0
        //returns true if changed
        static bool DrawMaterialListElements(BaseMeshSync t)
        {
            // calculate label width
            float labelWidth = 60; // minimum
            {
                GUIStyle style = GUI.skin.box;
                foreach (MaterialHolder md in t.materialList)
                {
                    Vector2 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);
            }

            bool changed = false;

            foreach (MaterialHolder matHolder in t.materialList)
            {
                Rect rect = EditorGUILayout.BeginHorizontal();
                EditorGUI.DrawRect(new Rect(rect.x, rect.y, 16, 16), matHolder.color);
                EditorGUILayout.LabelField("", GUILayout.Width(16));
                EditorGUILayout.LabelField(matHolder.name, GUILayout.Width(labelWidth));
                {
                    Material destMat = EditorGUILayout.ObjectField(matHolder.material, typeof(Material), true) as Material;
                    if (destMat != matHolder.material)
                    {
                        t.AssignMaterial(matHolder, destMat);
                        changed = true;
                    }
                }
                EditorGUILayout.EndHorizontal();
            }

            return(changed);
        }
Ejemplo n.º 12
0
//----------------------------------------------------------------------------------------------------------------------

        protected static bool DrawAnimationTweak(BaseMeshSync player)
        {
            bool changed = false;

            GUIStyle styleFold = EditorStyles.foldout;

            styleFold.fontStyle       = FontStyle.Bold;
            player.foldAnimationTweak = EditorGUILayout.Foldout(player.foldAnimationTweak, "Animation Tweak", true, styleFold);
            if (player.foldAnimationTweak)
            {
                MeshSyncPlayerConfig   config = player.GetConfigV();
                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++;

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(player, "MeshSync: Frame Rate",
                                                                      guiFunc: () => EditorGUILayout.FloatField("Frame Rate", frameRate),
                                                                      updateFunc: (float val) => {
                        if (val > 0)
                        {
                            ApplyFrameRate(clips, val);
                        }
                    }
                                                                      );
                    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;

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(player, "MeshSync: Scale",
                                                                      guiFunc: () => EditorGUILayout.FloatField("Scale", animationTweakSettings.TimeScale),
                                                                      updateFunc: (float val) => { animationTweakSettings.TimeScale = val; }
                                                                      );


                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(player, "MeshSync: Offset",
                                                                      guiFunc: () => EditorGUILayout.FloatField("Offset", animationTweakSettings.TimeOffset),
                                                                      updateFunc: (float val) => { animationTweakSettings.TimeOffset = val; }
                                                                      );
                    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;

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(player, "MeshSync: Step",
                                                                      guiFunc: () => EditorGUILayout.IntField("Step", animationTweakSettings.DropStep),
                                                                      updateFunc: (int val) => { animationTweakSettings.DropStep = val; }
                                                                      );

                    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;

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(player, "MeshSync: Threshold",
                                                                      guiFunc: () => EditorGUILayout.FloatField("Threshold", animationTweakSettings.ReductionThreshold),
                                                                      updateFunc: (float val) => {
                        animationTweakSettings.ReductionThreshold = val;
                        ApplyKeyframeReduction(clips, val, animationTweakSettings.EraseFlatCurves);
                    }
                                                                      );

                    changed |= EditorGUIDrawerUtility.DrawUndoableGUI(player, "MeshSync: Erase Flat Curves",
                                                                      guiFunc: () => EditorGUILayout.Toggle("Erase Flat Curves", animationTweakSettings.EraseFlatCurves),
                                                                      updateFunc: (bool toggle) => {
                        animationTweakSettings.EraseFlatCurves = toggle;
                        ApplyKeyframeReduction(clips, animationTweakSettings.ReductionThreshold, toggle);
                    }
                                                                      );

                    EditorGUI.indentLevel--;
                    GUILayout.EndVertical();
                }

                EditorGUILayout.Space();
            }

            return(changed);
        }