Пример #1
0
    public override void OnInspectorGUI()
    {
        MegaCacheParticleLegacyPlayback mod = (MegaCacheParticleLegacyPlayback)target;

        serializedObject.Update();

#if !UNITY_5 && !UNITY_2017 && !UNITY_2018
        EditorGUIUtility.LookLikeControls();
#endif

        EditorGUILayout.PropertyField(_prop_time, new GUIContent("Time"));
        if (mod.time < 0.0f)
        {
            mod.time = 0.0f;
        }

        EditorGUILayout.PropertyField(_prop_fps, new GUIContent("Fps"));
        EditorGUILayout.PropertyField(_prop_loopmode, new GUIContent("Loop Mode"));
        EditorGUILayout.PropertyField(_prop_particle, new GUIContent("Particle System"));
        EditorGUILayout.PropertyField(_prop_importscale, new GUIContent("Import Scale"));

        EditorGUILayout.BeginVertical("Box");
        EditorGUILayout.LabelField("Data Import Options");
        EditorGUILayout.PropertyField(_prop_vel, new GUIContent("Velocity"));
        EditorGUILayout.PropertyField(_prop_rot, new GUIContent("Rotation"));
        EditorGUILayout.PropertyField(_prop_scale, new GUIContent("Scale"));
        EditorGUILayout.PropertyField(_prop_spin, new GUIContent("Spin"));
        EditorGUILayout.PropertyField(_prop_removealive, new GUIContent("Remove Alive"));
        EditorGUILayout.PropertyField(_prop_maxfile, new GUIContent("Max File"));
        EditorGUILayout.EndVertical();

        if (GUILayout.Button("Import Particle Cache"))
        {
            string file = EditorUtility.OpenFilePanel("Import Particle Cache", mod.lastpath, "prt");

            if (file != null && file.Length > 1)
            {
                mod.lastpath = file;
                //MegaCacheParticle.LoadFilePlayBack(mod, file);
                MegaCacheParticlePlaybackEditor.LoadFilePlayBack(mod, file);
            }
        }

        EditorGUILayout.BeginVertical("Box");
        EditorGUILayout.LabelField("Save Data Options");
        EditorGUILayout.PropertyField(_prop_optimize, new GUIContent("Optimize"));
        EditorGUILayout.PropertyField(_prop_savevel, new GUIContent("Velocity"));
        EditorGUILayout.PropertyField(_prop_saverot, new GUIContent("Rotation"));
        EditorGUILayout.PropertyField(_prop_savescale, new GUIContent("Scale"));
        EditorGUILayout.PropertyField(_prop_savespin, new GUIContent("Spin"));
        EditorGUILayout.EndVertical();

        if (GUILayout.Button("Save Particle Cache File"))
        {
            string file = EditorUtility.SaveFilePanel("Save MegaCache Particle Cache", mod.lastpath, "Particles", "mcp");

            if (file != null && file.Length > 1)
            {
                mod.lastpath = file;
                MegaCacheParticle.SaveCacheFile(mod, file);
            }
        }

        if (GUILayout.Button("Load MegaCache File"))
        {
            string file = EditorUtility.OpenFilePanel("Load MegaCache Particle Cache", mod.lastpath, "mcp");

            if (file != null && file.Length > 1)
            {
                mod.lastpath = file;
                //MegaCacheParticleImage img = MegaCacheParticleImage.LoadCache(file);
                MegaCacheParticleImage img = MegaCacheFile.LoadCache(file);

                if (img)
                {
                    if (mod.image)
                    {
                        if (Application.isEditor)
                        {
                            DestroyImmediate(mod.image);
                        }
                        else
                        {
                            Destroy(mod.image);
                        }
                    }
                    mod.image = img;
                }
            }
        }

        string infstring = "";
        if (mod.image)
        {
            infstring = "Current Memory: " + (mod.image.CalcMemory() / 1024) + "KB";

            if (mod.image.optimized)
            {
                infstring += "\nParticles Optmized: " + mod.image.optparticles.Count;
            }
            else
            {
                infstring += "\nParticles: " + mod.image.particles.Count;
            }
        }

        EditorGUILayout.HelpBox(infstring, MessageType.None);

        EditorGUILayout.PropertyField(_prop_cachesrc, new GUIContent("Cache Data Src"));

        EditorGUILayout.BeginVertical("box");
        mod.showpaths        = EditorGUILayout.BeginToggleGroup("Show Paths", mod.showpaths);
        mod.showstart        = EditorGUILayout.IntSlider("Start", mod.showstart, 0, mod.showparticlestep);
        mod.showparticlestep = EditorGUILayout.IntSlider("Particle Step", mod.showparticlestep, 1, 50);
        mod.showposstep      = EditorGUILayout.IntSlider("Position Step", mod.showposstep, 1, 10);
        mod.showcolor        = EditorGUILayout.ColorField("Color", mod.showcolor);
        EditorGUILayout.EndToggleGroup();
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical("box");

        EditorGUILayout.Slider(_prop_speed, -2.0f, 2.0f, new GUIContent("Speed"));
        EditorGUILayout.Slider(_prop_scaleall, 0.0f, 4.0f, new GUIContent("Scale"));
        EditorGUILayout.Slider(_prop_sizescale, 0.0f, 8.0f, new GUIContent("Size"));
        EditorGUILayout.PropertyField(_prop_axis, new GUIContent("Rot Axis"));
        EditorGUILayout.EndVertical();

        if (GUI.changed)
        {
            serializedObject.ApplyModifiedProperties();
            EditorUtility.SetDirty(target);
        }
    }
Пример #2
0
    public override void OnInspectorGUI()
    {
        MegaCacheParticlePro mod = (MegaCacheParticlePro)target;

        serializedObject.Update();

#if !UNITY_5 && !UNITY_2017 && !UNITY_2018
        EditorGUIUtility.LookLikeControls();
#endif

        //mod.framenum = EditorGUILayout.IntSlider("Frame", mod.framenum, 0, 99);

        EditorGUILayout.PropertyField(_prop_particle, new GUIContent("Particle System"));
        EditorGUILayout.PropertyField(_prop_maxparticles, new GUIContent("Max Particles"));
        EditorGUILayout.PropertyField(_prop_importscale, new GUIContent("Import Scale"));

        EditorGUILayout.BeginVertical("Box");
        EditorGUILayout.LabelField("Data Import Options");
        EditorGUILayout.PropertyField(_prop_vel, new GUIContent("Velocity"));
        EditorGUILayout.PropertyField(_prop_rot, new GUIContent("Rotation"));
        EditorGUILayout.PropertyField(_prop_scale, new GUIContent("Scale"));
        EditorGUILayout.PropertyField(_prop_spin, new GUIContent("Spin"));
        EditorGUILayout.PropertyField(_prop_removealive, new GUIContent("Remove Alive"));
        EditorGUILayout.PropertyField(_prop_yup, new GUIContent("Y Up Change"));
        EditorGUILayout.EndVertical();

        if (GUILayout.Button("Import Particle Cache"))
        {
            string file = EditorUtility.OpenFilePanel("Import Particle Cache", mod.lastpath, "prt");

            if (file != null && file.Length > 1)
            {
                mod.lastpath = file;
                MegaCacheParticle.LoadFile(mod, file);
            }
        }

        EditorGUILayout.PropertyField(_prop_seqstart, new GUIContent("Maya Seq Start"));
        EditorGUILayout.PropertyField(_prop_seqend, new GUIContent("Maya Seq End"));

        if (GUILayout.Button("Import Maya Particles"))
        {
            string file = EditorUtility.OpenFilePanel("Import Maya Particles", mod.lastpath, "pda");

            if (file != null && file.Length > 1)
            {
                mod.lastpath = file;
                MegaCacheParticle.LoadPDASequence(mod, file, mod.seqstart, mod.seqend);
            }
        }

        EditorGUILayout.BeginVertical("Box");
        EditorGUILayout.LabelField("Save Data Options");
        EditorGUILayout.PropertyField(_prop_optimize, new GUIContent("Optimize"));
        EditorGUILayout.PropertyField(_prop_savevel, new GUIContent("Velocity"));
        EditorGUILayout.PropertyField(_prop_saverot, new GUIContent("Rotation"));
        EditorGUILayout.PropertyField(_prop_savescale, new GUIContent("Scale"));
        EditorGUILayout.PropertyField(_prop_savespin, new GUIContent("Spin"));
        EditorGUILayout.EndVertical();

        if (GUILayout.Button("Save Particle Cache File"))
        {
            string file = EditorUtility.SaveFilePanel("Save MegaCache Particle Cache", mod.lastpath, "Particles", "mcp");

            if (file != null && file.Length > 1)
            {
                mod.lastpath = file;
                MegaCacheParticle.SaveCacheFile(mod, file);
            }
        }

        if (GUILayout.Button("Load MegaCache File"))
        {
            string file = EditorUtility.OpenFilePanel("Load MegaCache Particle Cache", mod.lastpath, "mcp");

            if (file != null && file.Length > 1)
            {
                mod.lastpath = file;
                //MegaCacheParticleImage img = MegaCacheParticleImage.LoadCache(file);
                MegaCacheParticleImage img = MegaCacheFile.LoadCache(file);

                if (img)
                {
                    if (mod.image)
                    {
                        if (Application.isEditor)
                        {
                            DestroyImmediate(mod.image);
                        }
                        else
                        {
                            Destroy(mod.image);
                        }
                    }
                    mod.image = img;
                }
            }
        }

        string infstring = "";
        if (mod.image)
        {
            infstring = "Current Memory: " + (mod.image.CalcMemory() / 1024) + "KB";

            if (mod.image.optimized)
            {
                infstring += "\nParticles: " + mod.image.optparticles.Count;
            }
            else
            {
                infstring += "\nParticles: " + mod.image.particles.Count;
            }
        }

        EditorGUILayout.HelpBox(infstring, MessageType.None);

        EditorGUILayout.PropertyField(_prop_cachesrc, new GUIContent("Cache Data Src"));

        EditorGUILayout.BeginVertical("box");
        mod.showpaths        = EditorGUILayout.BeginToggleGroup("Show Paths", mod.showpaths);
        mod.showstart        = EditorGUILayout.IntSlider("Start", mod.showstart, 0, mod.showparticlestep);
        mod.showparticlestep = EditorGUILayout.IntSlider("Particle Step", mod.showparticlestep, 1, 50);
        mod.showposstep      = EditorGUILayout.IntSlider("Position Step", mod.showposstep, 1, 10);
        mod.showcolor        = EditorGUILayout.ColorField("Color", mod.showcolor);
        EditorGUILayout.EndToggleGroup();
        EditorGUILayout.EndVertical();

        EditorGUILayout.BeginVertical("box");

        EditorGUILayout.Slider(_prop_speed, -2.0f, 2.0f, new GUIContent("Speed"));
        EditorGUILayout.Slider(_prop_scaleall, 0.0f, 4.0f, new GUIContent("Scale"));
        EditorGUILayout.Slider(_prop_emitscale, 0.0f, 4.0f, new GUIContent("Emit Scale"));
        EditorGUILayout.Slider(_prop_sizescale, 0.0f, 4.0f, new GUIContent("Size"));
        EditorGUILayout.Slider(_prop_emitspeed, 0.0f, 4.0f, new GUIContent("Emit Speed"));

        EditorGUILayout.PropertyField(_prop_useemit, new GUIContent("Use Emit Rate"));
        EditorGUILayout.PropertyField(_prop_emitrate, new GUIContent("Emit Rate"));
        EditorGUILayout.PropertyField(_prop_prewarm, new GUIContent("Pre Warm"));
        EditorGUILayout.PropertyField(_prop_axis, new GUIContent("Rot Axis"));
        EditorGUILayout.PropertyField(_prop_use3drot, new GUIContent("Use 3D Rot"));
        EditorGUILayout.EndVertical();

        if (GUI.changed)
        {
            serializedObject.ApplyModifiedProperties();
            EditorUtility.SetDirty(target);
        }
    }