forked from Unity-Technologies/Graphics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VFX Graph sample github button in package manager (Unity-Technologies…
…#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
Showing
3 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
com.unity.visualeffectgraph/Editor/SamplesLinkPackageManagerExtension.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { } | ||
} |
11 changes: 11 additions & 0 deletions
11
com.unity.visualeffectgraph/Editor/SamplesLinkPackageManagerExtension.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.