void OnSceneGUI(SceneView sv)
    {
        try // make sure we don't break the whole scene
        {
            var slotContainer = targets[0] as VFXModel;
            if (VFXViewWindow.currentWindow != null)
            {
                VFXView view = VFXViewWindow.currentWindow.graphView;
                if (view.controller != null && view.controller.model && view.controller.graph == slotContainer.GetGraph())
                {
                    if (slotContainer is VFXParameter)
                    {
                        var controller = view.controller.GetParameterController(slotContainer as VFXParameter);

                        m_CurrentController = controller;
                        if (controller != null)
                        {
                            controller.DrawGizmos(view.attachedComponent);
                        }
                    }
                    else
                    {
                        m_CurrentController = view.controller.GetNodeController(slotContainer, 0);
                    }
                    if (m_CurrentController != null)
                    {
                        m_CurrentController.DrawGizmos(view.attachedComponent);

                        if (m_CurrentController.gizmoables.Count > 0)
                        {
                            s_EffectUi = this;
                        }
                        else
                        {
                            s_EffectUi = null;
                        }
                    }
                }
                else
                {
                    m_CurrentController = null;
                }
            }
        }
        catch (System.Exception e)
        {
            Debug.LogException(e);
        }
        finally
        {
        }
    }
Esempio n. 2
0
    void OnSceneGUI(SceneView sv)
    {
        try // make sure we don't break the whole scene
        {
            var slotContainer = targets[0] as VFXModel;
            if (VFXViewWindow.currentWindow != null)
            {
                VFXView view = VFXViewWindow.currentWindow.graphView;
                if (view.controller != null && view.controller.model && view.controller.graph == slotContainer.GetGraph())
                {
                    if (slotContainer is VFXParameter)
                    {
                        var controller = view.controller.GetParameterController(slotContainer as VFXParameter);

                        m_CurrentController = controller;
                        if (controller != null)
                        {
                            controller.DrawGizmos(view.attachedComponent);
                        }
                    }
                    else
                    {
                        m_CurrentController = view.controller.GetNodeController(slotContainer, 0);
                    }
                    if (m_CurrentController != null)
                    {
                        m_CurrentController.DrawGizmos(view.attachedComponent);

                        if (m_CurrentController.gizmoables.Count > 0)
                        {
                            SceneViewOverlay.Window(new GUIContent("Choose Gizmo"), SceneViewGUICallback, (int)SceneViewOverlay.Ordering.ParticleEffect, SceneViewOverlay.WindowDisplayOption.OneWindowPerTitle);
                        }
                    }
                }
                else
                {
                    m_CurrentController = null;
                }
            }
        }
        catch (System.Exception e)
        {
            Debug.LogException(e);
        }
        finally
        {
        }
    }
Esempio n. 3
0
        public override void OnGUI()
        {
            if (s_ControllersMap.Any())
            {
                GUILayout.BeginHorizontal();
                try
                {
                    var currentIndex = Math.Max(0, Array.IndexOf(s_ControllersMap.Keys.ToArray(), selectedController));
                    var entries      = s_ControllersMap.Select(x => $"{x.Value.controller.name}, {(x.Key as VFXParameterController)?.exposedName ?? (x.Key as VFXController<VFXModel>)?.name}").ToArray();
                    GUI.enabled = true;
                    int result = EditorGUILayout.Popup(currentIndex, entries);
                    selectedController = s_ControllersMap.Keys.ElementAt(result);

                    if (!s_ControllersMap.TryGetValue(selectedController, out var vfxView))
                    {
                        return;
                    }

                    if (selectedController.gizmoIndeterminate)
                    {
                        GUILayout.Label(Contents.gizmoIndeterminateWarning, Styles.warningStyle, GUILayout.Width(19), GUILayout.Height(18));
                    }
                    else if (selectedController.gizmoNeedsComponent && vfxView.attachedComponent == null)
                    {
                        GUILayout.Label(Contents.gizmoLocalWarning, Styles.warningStyle, GUILayout.Width(19), GUILayout.Height(18));
                    }
                    else
                    {
                        if (GUILayout.Button(Contents.gizmoFrame, Styles.frameButtonStyle, GUILayout.Width(16), GUILayout.Height(16)))
                        {
                            Bounds b         = selectedController.GetGizmoBounds(vfxView.attachedComponent);
                            var    sceneView = SceneView.lastActiveSceneView;
                            if (b.size.sqrMagnitude > Mathf.Epsilon && sceneView)
                            {
                                sceneView.Frame(b, false);
                            }
                        }
                    }
                }
                finally
                {
                    GUILayout.EndHorizontal();
                }
            }
        }