Skip to content

Commit

Permalink
VFX Graph sample github button in package manager (Unity-Technologies…
Browse files Browse the repository at this point in the history
…#7199)

* samples github link button

* correct folder

unity.testing.visualeffectgraph => unity.visualeffectgraph

* changelog

* Clean older versions considerations

no backport needed = clean code

* changed GUID

* Apply formatting changes

* Button text changed

Co-authored-by: noreply@unity3d.com <noreply@unity3d.com>
  • Loading branch information
MarieGuff and noreply@unity3d.com committed Feb 21, 2022
1 parent d2d9146 commit 6341538
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 0 deletions.
1 change: 1 addition & 0 deletions com.unity.visualeffectgraph/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
## [14.0.1] - 2021-12-07
### Added
- New Timeline Integration which supports scrubbing
- Samples project github link button in package manager

### Fixed
- Creating a new VFX of the same name as an already opened VFX will reuse the existing window [Case 1382841](https://issuetracker.unity3d.com/product/unity/issues/guid/1382841/)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@

using System;
using UnityEditor.PackageManager;
using UnityEditor.PackageManager.UI;
using UnityEngine;
using UnityEngine.UIElements;

[UnityEditor.InitializeOnLoad]
internal class SamplesLinkPackageManagerExtension : IPackageManagerExtension
{
VisualElement rootVisualElement;
const string SAMPLEBUTTON_TEXT = "open VFX Graph Samples project on Github";
const string GITHUB_URL = "https://github.com/Unity-Technologies/VisualEffectGraph-Samples";
const string VFX_GRAPH_NAME = "com.unity.visualeffectgraph";

private Button samplesButton;
private VisualElement parent;

public VisualElement CreateExtensionUI()
{
samplesButton = new Button();
samplesButton.text = SAMPLEBUTTON_TEXT;
samplesButton.clickable.clicked += () => Application.OpenURL(GITHUB_URL);
return samplesButton;
}

static SamplesLinkPackageManagerExtension()
{
PackageManagerExtensions.RegisterExtension(new SamplesLinkPackageManagerExtension());
}

void IPackageManagerExtension.OnPackageSelectionChange(PackageInfo packageInfo)
{
// Prevent the button from rendering on other packages
if (samplesButton.parent != null)
parent = samplesButton.parent;

bool shouldRender = packageInfo?.name == VFX_GRAPH_NAME;
if (!shouldRender)
{
samplesButton.RemoveFromHierarchy();
}
else
{
parent.Add(samplesButton);
}
}

void IPackageManagerExtension.OnPackageAddedOrUpdated(PackageInfo packageInfo) { }

void IPackageManagerExtension.OnPackageRemoved(PackageInfo packageInfo) { }
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 6341538

Please sign in to comment.