Beispiel #1
0
        protected void OnEnable()
        {
            VFXManagerEditor.CheckVFXManager();

            graphView = new VFXView();
            graphView.StretchToParentSize();
            SetupFramingShortcutHandler(graphView);

            rootVisualElement.Add(graphView);


            var currentAsset = GetCurrentResource();

            if (currentAsset != null)
            {
                LoadResource(currentAsset);
            }

            autoCompile = true;


            graphView.RegisterCallback <AttachToPanelEvent>(OnEnterPanel);
            graphView.RegisterCallback <DetachFromPanelEvent>(OnLeavePanel);

            if (rootVisualElement.panel != null)
            {
                rootVisualElement.AddManipulator(m_ShortcutHandler);
            }

            currentWindow = this;

#if USE_EXIT_WORKAROUND_FOGBUGZ_1062258
            EditorApplication.wantsToQuit += Quitting_Workaround;
#endif
        }
Beispiel #2
0
        protected void OnEnable()
        {
            VFXManagerEditor.CheckVFXManager();

            if (m_ResourceHistory == null)
            {
                m_ResourceHistory = new List <VisualEffectResource>();
            }

            graphView = new VFXView();
            graphView.StretchToParentSize();
            SetupFramingShortcutHandler(graphView);

            rootVisualElement.Add(graphView);

            // make sure we don't do something that might touch the model on the view OnEnable because
            // the models OnEnable might be called after in the case of a domain reload.
            m_OnUpdateAction = () =>
            {
                var currentAsset = GetCurrentResource();
                if (currentAsset != null)
                {
                    LoadResource(currentAsset);
                }
            };

            autoCompile = true;

            graphView.RegisterCallback <AttachToPanelEvent>(OnEnterPanel);
            graphView.RegisterCallback <DetachFromPanelEvent>(OnLeavePanel);

            if (rootVisualElement.panel != null)
            {
                rootVisualElement.AddManipulator(m_ShortcutHandler);
            }

            currentWindow = this;

#if USE_EXIT_WORKAROUND_FOGBUGZ_1062258
            EditorApplication.wantsToQuit += Quitting_Workaround;
#endif

            var icon = AssetDatabase.LoadAssetAtPath <Texture2D>(VisualEffectGraphPackageInfo.assetPackagePath + "/Editor Default Resources/VFX/" + (EditorGUIUtility.isProSkin ? "vfx_graph_icon_gray_dark.png" : "vfx_graph_icon_gray_light.png"));
            titleContent.image = icon;
        }
Beispiel #3
0
        protected void OnEnable()
        {
            VFXManagerEditor.CheckVFXManager();

            if (m_ResourceHistory == null)
            {
                m_ResourceHistory = new List <VisualEffectResource>();
            }

            graphView = new VFXView();
            graphView.StretchToParentSize();
            SetupFramingShortcutHandler(graphView);

            rootVisualElement.Add(graphView);

            // make sure we don't do something that might touch the model on the view OnEnable because
            // the models OnEnable might be called after in the case of a domain reload.
            m_OnUpdateAction = () =>
            {
                var currentAsset = GetCurrentResource();
                if (currentAsset != null)
                {
                    LoadResource(currentAsset);
                }
            };

            autoCompile = true;

            graphView.RegisterCallback <AttachToPanelEvent>(OnEnterPanel);
            graphView.RegisterCallback <DetachFromPanelEvent>(OnLeavePanel);

            if (rootVisualElement.panel != null)
            {
                rootVisualElement.AddManipulator(m_ShortcutHandler);
            }

            currentWindow = this;

#if USE_EXIT_WORKAROUND_FOGBUGZ_1062258
            EditorApplication.wantsToQuit += Quitting_Workaround;
#endif
        }
 static void CheckVFXManagerOnce()
 {
     VFXManagerEditor.CheckVFXManager();
     EditorApplication.update -= CheckVFXManagerOnce;
 }
 void IPreprocessBuildWithReport.OnPreprocessBuild(BuildReport report)
 {
     VFXManagerEditor.CheckVFXManager();
 }
Beispiel #6
0
    void OnPreprocessAsset()
    {
        bool isVFX = assetPath.EndsWith(VisualEffectResource.Extension);

        if (isVFX)
        {
            VFXManagerEditor.CheckVFXManager();
        }
        if (!allowExternalization)
        {
            return;
        }
        if (isVFX)
        {
            string vfxName      = Path.GetFileNameWithoutExtension(assetPath);
            string vfxDirectory = Path.GetDirectoryName(assetPath);

            string shaderDirectory = vfxDirectory + "/" + k_ShaderDirectory + "/" + vfxName;

            if (!Directory.Exists(shaderDirectory))
            {
                return;
            }
            VisualEffectAsset asset = AssetDatabase.LoadAssetAtPath <VisualEffectAsset>(assetPath);
            if (asset == null)
            {
                return;
            }

            bool oneFound = false;
            VisualEffectResource resource = asset.GetResource();
            if (resource == null)
            {
                return;
            }
            VFXShaderSourceDesc[] descs = resource.shaderSources;

            foreach (var shaderPath in Directory.GetFiles(shaderDirectory))
            {
                if (shaderPath.EndsWith(k_ShaderExt))
                {
                    System.IO.StreamReader file = new System.IO.StreamReader(shaderPath);

                    string shaderLine = file.ReadLine();
                    file.Close();
                    if (shaderLine == null || !shaderLine.StartsWith("//"))
                    {
                        continue;
                    }

                    string[] shaderParams = shaderLine.Split(',');

                    string shaderName = shaderParams[0].Substring(2);

                    int index;
                    if (!int.TryParse(shaderParams[1], out index))
                    {
                        continue;
                    }

                    if (index < 0 || index >= descs.Length)
                    {
                        continue;
                    }
                    if (descs[index].name != shaderName)
                    {
                        continue;
                    }

                    string shaderSource = File.ReadAllText(shaderPath);
                    //remove the first two lines that where added when externalized
                    shaderSource = shaderSource.Substring(shaderSource.IndexOf("\n", shaderSource.IndexOf("\n") + 1) + 1);

                    descs[index].source = shaderSource;
                    oneFound            = true;
                }
            }
            if (oneFound)
            {
                resource.shaderSources = descs;
            }
        }
    }
Beispiel #7
0
 static VisualEffectAssetEditorUtility()
 {
     VFXManagerEditor.CheckVFXManager();
     UnityEngine.VFX.VFXManager.activateVFX = true;
 }