private RightClickableElement(RightClickOption option, Action action, string nameOverride, Color?bgColorOverride, Sprite spriteOverride, Sprite bgSpriteOverride) { this.option = option; this.action = action; this.nameOverride = nameOverride; this.bgColorOverride = bgColorOverride; this.spriteOverride = spriteOverride; this.bgSpriteOverride = bgSpriteOverride; }
/// <summary> /// Return an int (same logic as IComparable) ordering the right click options according to the list /// defined in this RightClickOptionOrder /// </summary> /// <param name="c1"></param> /// <param name="c2"></param> /// <returns>-1 if c2 should go first, 1 if c1 should go first, 0 if they are the same</returns> public int Compare(RightClickOption c1, RightClickOption c2) { var p1 = orderedOptions.IndexOf(c1); var p2 = orderedOptions.IndexOf(c2); if (p1 == -1 && p2 == -1) { return(String.Compare(c1.label, c2.label, StringComparison.Ordinal)); } if (p1 == -1) { return(1); } if (p2 == -1) { return(-1); } return(p1.CompareTo(p2)); }
/// <summary> /// Default to the RightClickOption at the specified path if option is null. Convenience method /// for defaulting to a programmer-defined instance of this SO. /// </summary> /// <param name="defaultOptionPath">Path to the RightClickOption resource that should be used /// for this option if option is null, for example: "ScriptableObjects/Interaction/RightclickOptions/Pull"</param> /// <param name="option">option, can be null</param> /// <returns>option if it's not null, otherwise returns the RightClickOption at the specified path</returns> public static RightClickOption DefaultIfNull(string defaultOptionPath, RightClickOption option) { return(option ? option : Resources.Load <RightClickOption>(defaultOptionPath)); }