/// <summary>Creates a new animated property.</summary> /// <param name="animation">The animation that this property is a part of.</param> /// <param name="property">The property being animated.</param> public AnimatedProperty(UIAnimation animation, CssProperty property) { Animation = animation; InnerPropertyInfo = property; if (property.IsAlias) { CssPropertyAlias alias = property as CssPropertyAlias; PropertyInfo = alias.Target; } else { PropertyInfo = property; } }
/// <summary>Gets hold of the selected property and figures out the approximate file name.</summary> private static void LoadSelected() { // Get the property name: string name = Properties[SelectedPropertyIndex]; // Get the actual property: CssProperties.All.TryGetValue(name, out SelectedProperty); if (SelectedProperty == null) { PropertyFile = null; return; } if (SelectedProperty.IsAlias) { // e.g. color-r is an alias of color. // Get as an alias: CssPropertyAlias alias = SelectedProperty as CssPropertyAlias; if (alias == null || alias.Target == null) { return; } // Get the target of the alias: string aliasedTo = alias.Target.Name; PropertyFile = ToCamelCase(aliasedTo); } else { // Same as property: PropertyFile = ToCamelCase(SelectedProperty.Name); } }
void OnGUI() { PowerUIEditor.HelpBox("Here's the CSS properties that PowerUI is currently recognising."); if (Properties == null) { Load(); } // Dropdown list: int selected = EditorGUILayout.Popup(SelectedPropertyIndex, Properties); if (selected != SelectedPropertyIndex || SelectedProperty == null) { SelectedPropertyIndex = selected; LoadSelected(); } // Detailed information about the selected property: if (SelectedProperty != null) { // Show the name: EditorGUILayout.LabelField(SelectedProperty.Name, EditorStyles.boldLabel); string hostName; // Get as a composite property: CssCompositeProperty composite = SelectedProperty as CssCompositeProperty; if (composite != null) { // It's a composite property (e.g. font, animation etc). // They set multiple properties at once. EditorGUILayout.LabelField("Composite property"); hostName = SelectedProperty.Name; } else if (SelectedProperty.IsAlias) { // Get as an alias: CssPropertyAlias alias = SelectedProperty as CssPropertyAlias; // e.g. color-r is an alias of color. if (alias.Target == null) { // Hmm! hostName = SelectedProperty.Name; // It's not an alias property EditorGUILayout.LabelField("Not an alias"); } else { // Get the target of the alias: string aliasedTo = alias.Target.Name; // It's an alias property EditorGUILayout.LabelField("Alias of " + aliasedTo); hostName = aliasedTo; } } else { hostName = SelectedProperty.Name; // It's not an alias property EditorGUILayout.LabelField("Not an alias/ composite"); } if (!string.IsNullOrEmpty(PropertyFile)) { PowerUIEditor.HelpBox("To find the source file, search for its name in camel case, like this:"); EditorGUILayout.SelectableLabel(PropertyFile); } if (SelectedProperty.NonStandard) { PowerUIEditor.WarnBox("This property is non-standard or not on a standards track."); } else if (SelectedProperty.NamespaceName == "svg") { if (GUILayout.Button("View Mozilla Docs (SVG)")) { Application.OpenURL("https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/" + hostName); } } else { if (GUILayout.Button("View Mozilla Docs")) { Application.OpenURL("https://developer.mozilla.org/en-US/docs/Web/CSS/" + hostName); } } } }