コード例 #1
0
    void DrawPresets()
    {
        #region preset box0
        EditorGUILayout.BeginVertical("box");

        if (mShowingPresetList.Count > 0)
        {
            #region rows
            EditorGUILayout.BeginHorizontal();
            int rows       = 1;
            int iconwidths = 0;
            for (int i = 0; i < mShowingPresetList.Count; i++)
            {
                rows        = Mathf.FloorToInt(PresetViewWidth / PRESET_WIDTH);
                iconwidths += PRESET_WIDTH;
                if (iconwidths > PresetViewWidth && i > 0)
                {
                    iconwidths = PRESET_WIDTH;
                    EditorGUILayout.EndHorizontal();
                    EditorGUILayout.BeginHorizontal();
                }


                if (PresetViewWidth >= PRESET_WIDTH * 2)
                {
                    EditorGUILayout.BeginVertical("box", GUILayout.MaxWidth(Mathf.CeilToInt(PresetViewWidth / rows) - 44 / rows));
                }
                else
                {
                    EditorGUILayout.BeginVertical("box");
                }


                //begin preset unit
                EditorGUILayout.BeginHorizontal(GUILayout.MinHeight(46));

                //EditorGUI.DrawPreviewTexture(new Rect(0, 0, 40, 40), texTest);



                if (GUILayout.Button(mShowingPresetList[i].PreviewIcon, PreviewButtonStyle, new GUILayoutOption[] { GUILayout.Width(64), GUILayout.Height(64) }))
                {
                    GameObject pobj = AssetDatabase.LoadAssetAtPath(mShowingPresetList[i].Path, typeof(GameObject)) as GameObject;

                    if (pobj == null)
                    {
                        Debug.LogWarning("prefab isn't existed, please refresh." + mShowingPresetList[i].Path);
                    }
                    else
                    {
                        GameObject obj = PrefabUtility.InstantiatePrefab(pobj) as GameObject;
                        if (obj != null)
                        {
                            Selection.activeGameObject = obj;
                            XffectComponent xobj = obj.GetComponent <XffectComponent>();
                            if (xobj != null)
                            {
                                xobj.EditView = true;
                                xobj.EnableEditView();
                            }

                            CompositeXffect cxobj = obj.GetComponent <CompositeXffect>();
                            if (cxobj != null)
                            {
                                cxobj.EnableEditView();
                            }
                        }

                        EditorUtility.UnloadUnusedAssetsImmediate();
                        System.GC.Collect();
                    }
                }

                //GUI.backgroundColor = bcolor;

                EditorGUILayout.BeginVertical();
                EditorGUILayout.LabelField(mShowingPresetList[i].Name, new GUILayoutOption[] { GUILayout.Width(PRESET_WIDTH - 64), GUILayout.Height(40) });
                EditorGUILayout.LabelField(mShowingPresetList[i].CreatedTime);
                EditorGUILayout.EndVertical();

                //end preset unit
                EditorGUILayout.EndHorizontal();

                //end preset frame
                EditorGUILayout.EndVertical();
            }

            //end presets box.
            EditorGUILayout.EndHorizontal();
            #endregion //row
        }
        else
        {
            EditorGUILayout.HelpBox("No prefabs found.", MessageType.Info);
        }

        //end outer frame box.
        EditorGUILayout.EndVertical();
        #endregion //box0
    }
コード例 #2
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();
        XEditor.BeginCommonArea("xffect main config", Script.gameObject.name, this, true);

        EditorGUILayout.Space();

        XEditor.DrawToggle("update in editor?", "", EditView);

        //EditView.boolValue = EditorGUILayout.Toggle("update in editor:", EditView.boolValue,GUILayout.Height(40f));


        if (EditView.boolValue == true)
        {
            if (!XffectComponent.IsActive(Script.gameObject))
            {
                EditView.boolValue = false;
                Debug.Log("you need to activate the xffect object: " + Script.gameObject.name + " before updating it in editor.");
            }
        }

        if (EditView.boolValue)
        {
            Script.EnableEditView();
        }
        else
        {
            Script.DisableEditView();
        }

        if (EditView.boolValue)
        {
            if (GUILayout.Button("Reset"))
            {
                Script.ResetEditScene();
            }
        }

        XEditor.DrawSeparator();

        XEditor.DrawFloat("life(-1 means infinite):", "", LifeTime);
        XEditor.DrawToggle("ignore time scale?", "", IgnoreTimeScale);


        EditorGUILayout.Space();

        XEditor.DrawFloat("scale:", "change this Xffect's scale", Scale);


        if (GUILayout.Button("Add Layer"))
        {
            GameObject  layer = new GameObject(LayerName);
            EffectLayer efl   = (EffectLayer)layer.AddComponent("EffectLayer");
            layer.transform.parent      = Selection.activeTransform;
            efl.transform.localPosition = Vector3.zero;
            //default to effect layer object.
            efl.ClientTransform  = efl.transform;
            efl.GravityObject    = efl.transform;
            efl.BombObject       = efl.transform;
            efl.TurbulenceObject = efl.transform;
            efl.AirObject        = efl.transform;
            efl.VortexObj        = efl.transform;
            efl.DirCenter        = efl.transform;
            efl.Material         = AssetDatabase.LoadAssetAtPath(XEditorTool.GetXffectPath() + DefaultMatPath, typeof(Material)) as Material;

            efl.gameObject.layer = Script.gameObject.layer;

            Selection.activeGameObject = layer;
        }


        if (GUILayout.Button("Add Event"))
        {
            GameObject        obj    = new GameObject("_Event");
            XftEventComponent xevent = (XftEventComponent)obj.AddComponent("XftEventComponent");
            xevent.transform.parent        = Selection.activeTransform;
            xevent.transform.localPosition = Vector3.zero;
            xevent.RadialBlurShader        = Shader.Find("Xffect/PP/radial_blur_new");
            xevent.GlowCompositeShader     = Shader.Find("Xffect/PP/glow_compose");
            xevent.GlowDownSampleShader    = Shader.Find("Xffect/PP/glow_downsample");
            xevent.GlowBlurShader          = Shader.Find("Xffect/PP/glow_conetap");
            xevent.RadialBlurObj           = xevent.transform;
            xevent.ColorInverseShader      = Shader.Find("Xffect/PP/color_inverse");

            xevent.GlowPerObjBlendShader       = Shader.Find("Xffect/glow_per_obj/blend");
            xevent.GlowPerObjReplacementShader = Shader.Find("Xffect/glow_per_obj/replacement");

            xevent.gameObject.layer = Script.gameObject.layer;

            Selection.activeGameObject = obj;
        }


        EditorGUILayout.Space();

        XEditor.EndXArea();

        DrawInfos();

        serializedObject.ApplyModifiedProperties();
    }
コード例 #3
0
    public override void OnInspectorGUI()
    {
        serializedObject.Update();


        //check if need to upgrade.
        System.Version myVer = new System.Version(Script.MyVersion);
        if (myVer <= new System.Version("4.4.0"))
        {
            DoPatch440(Script);
            EditorUtility.SetDirty(target);
        }

        XEditor.BeginCommonArea("xffect main config", Script.gameObject.name, this, true);

        EditorGUILayout.Space();


        if (EditorUtility.IsPersistent(target))
        {
            if (GUILayout.Button("Put To Scene"))
            {
                GameObject obj = PrefabUtility.InstantiatePrefab(Selection.activeObject as GameObject) as GameObject;
                Selection.activeGameObject = obj;
                if (obj != null)
                {
                    XffectComponent xobj = obj.GetComponent <XffectComponent>();
                    if (xobj != null)
                    {
                        xobj.EditView = true;
                        xobj.EnableEditView();
                    }
                }
            }
        }


        XEditor.DrawToggle("update in editor?", "", EditView);

        //EditView.boolValue = EditorGUILayout.Toggle("update in editor:", EditView.boolValue,GUILayout.Height(40f));


        //if (EditView.boolValue == true) {
        //if (!XffectComponent.IsActive(Script.gameObject)) {
        //EditView.boolValue = false;
        //Debug.Log ("you need to activate the xffect object: " + Script.gameObject.name + " before updating it in editor.");
        //}
        //}

        if (EditView.boolValue)
        {
            Script.EnableEditView();
        }
        else
        {
            Paused.boolValue = false;
            Script.DisableEditView();
        }

        if (EditView.boolValue)
        {
            PlaybackTime.floatValue = EditorGUILayout.FloatField("Playback time: ", PlaybackTime.floatValue);

            if (PlaybackTime.floatValue < 0f)
            {
                PlaybackTime.floatValue = 0f;
            }

            string disp = "Pause";
            if (Paused.boolValue)
            {
                disp = "Play";
            }
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(disp))
            {
                Paused.boolValue = !Paused.boolValue;
            }

            if (GUILayout.Button("Reset"))
            {
                Paused.boolValue = false;
                Script.ResetEditScene();
            }
            EditorGUILayout.EndHorizontal();
        }

        XEditor.DrawSeparator();

        XEditor.DrawFloat("life(-1 means infinite):", "", LifeTime);
        XEditor.DrawToggle("ignore time scale?", "", IgnoreTimeScale);

        XEditor.DrawToggle("auto destroy?", "check on this option if you want this obj to be destroyed when finished, note this option only works in play mode.", AutoDestroy);

        XEditor.DrawToggle("merge same mesh?", "check on this option to merge the meshes with same material, can reduce drawcalls.", MergeSameMaterialMesh);

        XEditor.DrawToggle("update when offscreen?", "", UpdateWhenOffScreen);

        if (XEditor.DrawToggle("use with 2d sprite?", "", UseWith2DSprite))
        {
            XEditor.DrawText("sorting layer name:", "", SortingLayerName);
            XEditor.DrawInt("sorting order:", "", SortingOrder);
        }

        EditorGUILayout.Space();



        XEditor.DrawInt("Max Fps:", "", MaxFps);

        XEditor.DrawFloat("scale:", "change this Xffect's scale", Scale);



        if (!Mathf.Approximately(1f, Scale.floatValue))
        {
            XEditor.DrawInfo("note it's not recommended to use this function to change xffect's scale. if you encounter strange behavious, please change it back to 1.");
        }

        if (GUILayout.Button("Add Layer"))
        {
            GameObject  layer = new GameObject(LayerName);
            EffectLayer efl   = (EffectLayer)layer.AddComponent <EffectLayer>();
            layer.transform.parent      = Selection.activeTransform;
            efl.transform.localPosition = Vector3.zero;
            //default to effect layer object.
            efl.ClientTransform  = efl.transform;
            efl.GravityObject    = efl.transform;
            efl.BombObject       = efl.transform;
            efl.TurbulenceObject = efl.transform;
            efl.AirObject        = efl.transform;
            efl.VortexObj        = efl.transform;
            //efl.DirCenter = efl.transform;
            efl.Material = AssetDatabase.LoadAssetAtPath(XEditorTool.GetXffectPath() + DefaultMatPath, typeof(Material)) as Material;

            efl.gameObject.layer = Script.gameObject.layer;

            efl.LineStartObj = efl.transform;

            Selection.activeGameObject = layer;
        }


        if (GUILayout.Button("Add Event"))
        {
            GameObject        obj    = new GameObject("_Event");
            XftEventComponent xevent = (XftEventComponent)obj.AddComponent <XftEventComponent>();
            xevent.transform.parent        = Selection.activeTransform;
            xevent.transform.localPosition = Vector3.zero;
            xevent.RadialBlurShader        = Shader.Find("Xffect/PP/radial_blur");
            xevent.GlowCompositeShader     = Shader.Find("Xffect/PP/glow_compose");
            xevent.GlowDownSampleShader    = Shader.Find("Xffect/PP/glow_downsample");
            xevent.GlowBlurShader          = Shader.Find("Xffect/PP/glow_conetap");
            xevent.RadialBlurObj           = xevent.transform;
            xevent.ColorInverseShader      = Shader.Find("Xffect/PP/color_inverse");

            xevent.GlowPerObjBlendShader       = Shader.Find("Hidden/PP/Xffect/glow_per_obj/blend");
            xevent.GlowPerObjReplacementShader = Shader.Find("Hidden/PP/Xffect/glow_per_obj/replacement");
            xevent.gameObject.layer            = Script.gameObject.layer;

            Selection.activeGameObject = obj;
        }
        XEditor.EndXArea();

        DrawInfos();
        serializedObject.ApplyModifiedProperties();
    }
コード例 #4
0
    public void OnSceneGUI()
    {
        serializedObject.Update();

        Rect r = new Rect(0, Screen.height - 120, 160, 80);


        Vector2 mouse = Event.current.mousePosition;

        Rect r2 = r;

        r2.yMin -= 30;
        r2.xMin -= 10;
        r2.xMax += 10;
        r2.yMax += 10;

        if (r2.Contains(mouse) && Event.current.type == EventType.Layout)
        {
            int controlID = GUIUtility.GetControlID(1024, FocusType.Passive);
            HandleUtility.AddControl(controlID, 0F);
        }

        Handles.BeginGUI();
        GUILayout.BeginArea(r, Script.gameObject.name, "Window");


        EditView.boolValue = GUILayout.Toggle(EditView.boolValue, "update in editor?");

        PlaybackTime.floatValue = EditorGUILayout.FloatField("Playback time: ", PlaybackTime.floatValue);

        if (PlaybackTime.floatValue < 0f)
        {
            PlaybackTime.floatValue = 0f;
        }

        if (EditView.boolValue)
        {
            Script.EnableEditView();
        }
        else
        {
            Paused.boolValue = false;
            Script.DisableEditView();
        }

        if (EditView.boolValue)
        {
            string disp = "Pause";
            if (Paused.boolValue)
            {
                disp = "Play";
            }
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(disp))
            {
                Paused.boolValue = !Paused.boolValue;
            }

            if (GUILayout.Button("Reset"))
            {
                Paused.boolValue = false;
                Script.ResetEditScene();
            }
            EditorGUILayout.EndHorizontal();
        }
        GUILayout.EndArea();

        Handles.EndGUI();

        serializedObject.ApplyModifiedProperties();
    }
コード例 #5
0
    public override void OnInspectorGUI()
    {
        XffectComponent ctarget = (XffectComponent)target;

        if (Application.isEditor && !EditorApplication.isPlaying)
        {
            EditorApplication.update = ctarget.Update;
        }

        EditorGUILayout.BeginVertical();
        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        ctarget.LifeTime = EditorGUILayout.FloatField("life:", ctarget.LifeTime);
        EditorGUILayout.LabelField("[life -1 means infinite.]");

        ctarget.IgnoreTimeScale = EditorGUILayout.Toggle("ignore time scale?", ctarget.IgnoreTimeScale);

        EditorGUILayout.Separator();

        ctarget.Scale = EditorGUILayout.FloatField("scale:", ctarget.Scale);
        EditorGUILayout.Separator();

        if (GUILayout.Button("Add Layer"))
        {
            GameObject  layer = new GameObject(LayerName);
            EffectLayer efl   = (EffectLayer)layer.AddComponent("EffectLayer");
            layer.transform.parent = Selection.activeTransform;

            efl.transform.localPosition = Vector3.zero;
            //fixed 2012.6.25. default to effect layer object.
            efl.ClientTransform  = efl.transform;
            efl.GravityObject    = efl.transform;
            efl.BombObject       = efl.transform;
            efl.TurbulenceObject = efl.transform;
            efl.AirObject        = efl.transform;
            efl.VortexObj        = efl.transform;
            efl.DirCenter        = efl.transform;
        }


        if (GUILayout.Button("Add Event"))
        {
            GameObject        layer  = new GameObject("_Event");
            XftEventComponent xevent = (XftEventComponent)layer.AddComponent("XftEventComponent");
            xevent.transform.parent        = Selection.activeTransform;
            xevent.transform.localPosition = Vector3.zero;
            xevent.RadialBlurShader        = Shader.Find("Xffect/PP/radial_blur_new");
            xevent.GlowCompositeShader     = Shader.Find("Xffect/PP/glow_compose");
            xevent.GlowDownSampleShader    = Shader.Find("Xffect/PP/glow_downsample");
            xevent.GlowBlurShader          = Shader.Find("Xffect/PP/glow_conetap");
            xevent.RadialBlurObj           = xevent.transform;
            xevent.ColorInverseShader      = Shader.Find("Xffect/PP/color_inverse");
        }

        EditorGUILayout.Separator();
        ctarget.EditView = EditorGUILayout.Toggle("update in editor?", ctarget.EditView);

        //prevent asset inspector to update.
        if (ctarget.EditView == true)
        {
            if (!XffectComponent.IsActive(ctarget.gameObject))
            {
                ctarget.EditView = false;
                Debug.Log("you should activate the xffect object: " + ctarget.gameObject.name + " before updating it in editor.");
            }
        }

        if (ctarget.EditView)
        {
            ctarget.EnableEditView();
        }
        else
        {
            ctarget.DisableEditView();
        }

        if (ctarget.EditView)
        {
            if (GUILayout.Button("Reset Editor Xffect"))
            {
                ctarget.ResetEditScene();
            }
        }
        EditorGUILayout.EndVertical();

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
コード例 #6
0
    public void OnSceneGUI()
    {
        serializedObject.Update();

        Rect r = new Rect(0, Screen.height - 160, 160, 120);


        Vector2 mouse = Event.current.mousePosition;

        Rect r2 = r;

        r2.yMin -= 30;
        r2.xMin -= 10;
        r2.xMax += 10;
        r2.yMax += 10;

        if (r2.Contains(mouse) && Event.current.type == EventType.Layout)
        {
            int controlID = GUIUtility.GetControlID(1024, FocusType.Passive);
            HandleUtility.AddControl(controlID, 0F);
        }

        Handles.BeginGUI();
        GUILayout.BeginArea(r, Script.gameObject.name, "Window");



        mOpenCaptureWindow = GUILayout.Toggle(mOpenCaptureWindow, "preview capture tool?");


        GUI.enabled = false;

        Object prefab = PrefabUtility.GetPrefabParent(target);

        if (mOpenCaptureWindow && prefab != null)
        {
            GUI.enabled  = true;
            Tools.hidden = true;
        }
        else
        {
            Tools.hidden = false;
        }

        if (GUILayout.Button("capture"))
        {
            if (prefab == null)
            {
                //string info = target.name + " has no prefab instance, it can't be captured. please make a prefab instance first.";
                //XEditorTool.ShowNotification(info);
                //do nothing.
            }
            else
            {
                string path = AssetDatabase.GetAssetPath(prefab);

                string imgPath = path.Substring(0, path.LastIndexOf(".prefab")) + "_preview.png";

                Debug.Log("Saving captured image to:" + imgPath);

                CaptureRect(imgPath);
            }
        }

        GUI.enabled = true;


        EditView.boolValue = GUILayout.Toggle(EditView.boolValue, "update in editor?");

        EditorGUIUtility.labelWidth = 110f;

        PlaybackTime.floatValue = EditorGUILayout.FloatField("Playback time: ", PlaybackTime.floatValue);

        EditorGUIUtility.labelWidth = 0f;

        if (PlaybackTime.floatValue < 0f)
        {
            PlaybackTime.floatValue = 0f;
        }

        if (EditView.boolValue)
        {
            Script.EnableEditView();
            GUI.enabled = true;
        }
        else
        {
            Paused.boolValue = false;
            Script.DisableEditView();
            GUI.enabled = false;
        }

        //if (EditView.boolValue)
        {
            string disp = "Pause";
            if (Paused.boolValue)
            {
                disp = "Play";
            }
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button(disp))
            {
                Paused.boolValue = !Paused.boolValue;
            }

            if (GUILayout.Button("Reset"))
            {
                Paused.boolValue = false;
                Script.ResetEditScene();
            }

            GUI.enabled = true;

            EditorGUILayout.EndHorizontal();
        }
        GUILayout.EndArea();

        Handles.EndGUI();

        if (mOpenCaptureWindow)
        {
            HandleInput();
            UpdateRect();
            DrawCaptureHandles();
            CaptureProcess();
        }

        serializedObject.ApplyModifiedProperties();
    }
コード例 #7
0
    public override void OnInspectorGUI()
    {
        XffectComponent ctarget = (XffectComponent)target;

        if (Application.isEditor && !EditorApplication.isPlaying)
        {
            EditorApplication.update = ctarget.Update;
        }

        EditorGUILayout.BeginVertical();
        EditorGUILayout.Space();
        EditorGUILayout.Separator();
        ctarget.LifeTime = EditorGUILayout.FloatField("life:", ctarget.LifeTime);
        EditorGUILayout.LabelField("[life -1 means infinite.]");

        EditorGUILayout.Separator();

        ctarget.Scale = EditorGUILayout.FloatField("scale:", ctarget.Scale);
        EditorGUILayout.Separator();

        if (GUILayout.Button("Add Layer"))
        {
            GameObject  layer = new GameObject(LayerName);
            EffectLayer efl   = (EffectLayer)layer.AddComponent("EffectLayer");
            layer.transform.parent = Selection.activeTransform;

            efl.transform.localPosition = Vector3.zero;
            //fixed 2012.6.25. default to effect layer object.
            efl.ClientTransform  = efl.transform;
            efl.GravityObject    = efl.transform;
            efl.BombObject       = efl.transform;
            efl.TurbulenceObject = efl.transform;
            efl.AirObject        = efl.transform;
            efl.VortexObj        = efl.transform;
            efl.DirCenter        = efl.transform;
        }

        EditorGUILayout.Separator();
        ctarget.EditView = EditorGUILayout.Toggle("update in editor?", ctarget.EditView);

        //prevent asset inspector to update.
        if (ctarget.EditView == true)
        {
            if (ctarget.gameObject.active == false)
            {
                ctarget.EditView = false;
                Debug.LogWarning("you should set the xffect object: " + ctarget.gameObject.name + " to active before update it.");
            }
        }

        if (ctarget.EditView)
        {
            ctarget.EnableEditView();
        }
        else
        {
            ctarget.DisableEditView();
        }

        if (ctarget.EditView)
        {
            if (GUILayout.Button("Reset Editor Xffect"))
            {
                ctarget.ResetEditScene();
            }
        }
        EditorGUILayout.EndVertical();

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