예제 #1
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();
    }
예제 #2
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();
    }
예제 #3
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);
        }
    }
예제 #4
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();
    }
예제 #5
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
        {
            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();
        }

        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);

        EditorGUILayout.Space();

        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/XffectPP//glow_per_obj/blend");
            xevent.GlowPerObjReplacementShader = Shader.Find("Hidden/Xffect/PP/glow_per_obj/replacement");
            xevent.gameObject.layer            = Script.gameObject.layer;

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

        DrawInfos();
        serializedObject.ApplyModifiedProperties();
    }
예제 #6
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);
        }
    }