private void RebuildProperties(InvItem item) { // Which properties are available? List <int> availableVarIDs = new List <int>(); foreach (InvVar invVar in invVars) { if (!invVar.limitToCategories || bins.Count == 0 || invVar.categoryIDs.Contains(item.binID)) { availableVarIDs.Add(invVar.id); } } // Create new properties / transfer existing values List <InvVar> newInvVars = new List <InvVar>(); foreach (InvVar invVar in invVars) { if (availableVarIDs.Contains(invVar.id)) { InvVar newInvVar = new InvVar(invVar); InvVar oldInvVar = item.GetProperty(invVar.id); if (oldInvVar != null) { newInvVar.TransferValues(oldInvVar); } newInvVars.Add(newInvVar); } } item.vars = newInvVars; }
private void LoadPropertyData(string dataString) { if (string.IsNullOrEmpty(dataString)) { return; } string[] dataArray = dataString.Split("#"[0]); if (dataArray.Length > 0) { foreach (string propertyData in dataArray) { string[] chunkData = propertyData.Split("_"[0]); if (chunkData.Length == 2) { int _id = -1; int.TryParse(chunkData[0], out _id); if (_id >= 0) { InvVar invVar = GetProperty(_id); if (invVar != null) { invVar.LoadData(chunkData[1]); } } } } } }
private void SideMenu(InvVar invVar) { GenericMenu menu = new GenericMenu(); sideItem = sceneAttributes.IndexOf(invVar); menu.AddItem(new GUIContent("Insert after"), false, PropertyCallback, "Insert after"); if (sceneAttributes.Count > 0) { menu.AddItem(new GUIContent("Delete"), false, PropertyCallback, "Delete"); } if (sideItem > 0 || sideItem < sceneAttributes.Count - 1) { menu.AddSeparator(""); } if (sideItem > 0) { menu.AddItem(new GUIContent("Re-arrange/Move to top"), false, PropertyCallback, "Move to top"); menu.AddItem(new GUIContent("Re-arrange/Move up"), false, PropertyCallback, "Move up"); } if (sideItem < sceneAttributes.Count - 1) { menu.AddItem(new GUIContent("Re-arrange/Move down"), false, PropertyCallback, "Move down"); menu.AddItem(new GUIContent("Re-arrange/Move to bottom"), false, PropertyCallback, "Move to bottom"); } menu.ShowAsContext(); }
public void RebuildProperties() { // Which properties are available? List <int> availableVarIDs = new List <int> (); foreach (InvVar invVar in KickStarter.inventoryManager.invVars) { if (!invVar.limitToCategories || KickStarter.inventoryManager.bins.Count == 0 || invVar.categoryIDs.Contains(binID)) { availableVarIDs.Add(invVar.id); } } // Create new properties / transfer existing values List <InvVar> newInvVars = new List <InvVar> (); foreach (InvVar invVar in KickStarter.inventoryManager.invVars) { if (availableVarIDs.Contains(invVar.id)) { InvVar newInvVar = new InvVar(invVar); InvVar oldInvVar = GetProperty(invVar.id); if (oldInvVar != null) { newInvVar.TransferValues(oldInvVar); } newInvVar.popUpID = invVar.popUpID; newInvVars.Add(newInvVar); } } vars = newInvVars; }
/** * <summary>Updates the 'value' variables specific to an inventory item based on another InvVar instance.</summary> * <param name = "invVar">The other InvVar to copy 'value' variables from</param> */ public void TransferValues(InvVar invVar) { val = invVar.val; floatVal = invVar.floatVal; textVal = invVar.textVal; textValLineID = invVar.textValLineID; }
private void DeactivateAllAttributes() { foreach (InvVar sceneAttribute in sceneAttributes) { sceneAttribute.isEditing = false; } selectedSceneAttribute = null; }
private void DeactivateAllInvVars() { foreach (InvVar invVar in invVars) { invVar.isEditing = false; } selectedInvVar = null; }
/** * <summary>Updates the 'value' variables specific to an inventory item based on another InvVar instance.</summary> * <param name = "invVar">The other InvVar to copy 'value' variables from</param> */ public void TransferValues(InvVar invVar) { val = invVar.val; floatVal = invVar.floatVal; textVal = invVar.textVal; textValLineID = invVar.textValLineID; vector3Val = invVar.vector3Val; popUpsLineID = invVar.popUpsLineID; }
private string GetPropertyDisplayValue(int languageNumber, InvItem invItem) { if (invItem != null) { InvVar invVar = invItem.GetProperty(itemPropertyID, multiplyByItemCount); if (invVar != null) { return(invVar.GetDisplayValue(languageNumber)); } } return(string.Empty); }
private string GetPropertyDisplayValue(int languageNumber, InvItem invItem) { if (invItem != null) { InvVar invVar = invItem.GetProperty(itemPropertyID); if (invVar != null) { return(invVar.GetDisplayValue(languageNumber)); } } return(""); }
/** * <summary>Gets the total value of all instances of an Integer inventory property (e.g. currency) within a set of inventory items.</summary> * <param name = "invInstances">The inventory item instances to get the total value from</param> * <param name = "propertyID">The ID number of the Inventory property (see InvVar) to get the total value of</param> * <returns>The total value of all instances of the Integer inventory property within the set of inventory items</returns> */ public int GetTotalIntProperty(int propertyID) { int result = 0; foreach (InvInstance invInstance in invInstances) { InvVar invVar = invInstance.GetProperty(propertyID); if (invVar != null && invVar.type == VariableType.Integer) { result += invVar.IntegerValue; } } return(result); }
/** * <summary>Gets the total value of all instances of an Float inventory property (e.g. weight) within a set of inventory items.</summary> * <param name = "invInstances">The inventory item instances to get the total value from</param> * <param name = "propertyID">The ID number of the Inventory property (see InvVar) to get the total value of</param> * <returns>The total value of all instances of the Float inventory property within the set of inventory items</returns> */ public float GetTotalFloatProperty(int propertyID) { float result = 0f; foreach (InvInstance invInstance in invInstances) { InvVar invVar = invInstance.GetProperty(propertyID); if (invVar != null && invVar.type == VariableType.Float) { result += invVar.FloatValue; } } return(result); }
private void PropertyCallback(object obj) { if (sideItem >= 0) { InvVar tempVar = sceneAttributes[sideItem]; switch (obj.ToString()) { case "Insert after": Undo.RecordObject(this, "Insert item"); sceneAttributes.Insert(sideItem + 1, new InvVar(GetIDArray())); break; case "Delete": Undo.RecordObject(this, "Delete item"); DeactivateAllAttributes(); sceneAttributes.RemoveAt(sideItem); break; case "Move to top": sceneAttributes.RemoveAt(sideItem); sceneAttributes.Insert(0, tempVar); break; case "Move up": Undo.RecordObject(this, "Move item up"); sceneAttributes.RemoveAt(sideItem); sceneAttributes.Insert(sideItem - 1, tempVar); break; case "Move down": Undo.RecordObject(this, "Move item down"); sceneAttributes.RemoveAt(sideItem); sceneAttributes.Insert(sideItem + 1, tempVar); break; case "Move to bottom": sceneAttributes.RemoveAt(sideItem); sceneAttributes.Insert(sceneAttributes.Count, tempVar); break; } } EditorUtility.SetDirty(this); AssetDatabase.SaveAssets(); sideItem = -1; }
private string GetPropertyDisplayValue(int languageNumber, InvInstance invInstance) { if (InvInstance.IsValid(invInstance)) { InvVar invVar = invInstance.GetProperty(itemPropertyID); if (invVar != null) { if (multiplyByItemCount) { return(invVar.GetDisplayValue(languageNumber, invInstance.Count)); } return(invVar.GetDisplayValue(languageNumber)); } } return(string.Empty); }
private void CreateAttributesGUI() { EditorGUILayout.BeginVertical(CustomStyles.thinBox); EditorGUILayout.LabelField("All scene attributes", CustomStyles.subHeader); EditorGUILayout.Space(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(Mathf.Min(sceneAttributes.Count * 21, 165f) + 5)); foreach (InvVar sceneAttribute in sceneAttributes) { EditorGUILayout.BeginHorizontal(); string buttonLabel = sceneAttribute.label; if (buttonLabel == "") { buttonLabel = "(Untitled)"; } if (GUILayout.Toggle(selectedSceneAttribute == sceneAttribute, sceneAttribute.id + ": " + buttonLabel, "Button")) { if (selectedSceneAttribute != sceneAttribute) { DeactivateAllAttributes(); ActivateAttribute(sceneAttribute); } } if (GUILayout.Button("", CustomStyles.IconCog)) { SideMenu(sceneAttribute); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); if (GUILayout.Button("Create new scene attribute")) { Undo.RecordObject(this, "Create scene attribute"); InvVar newSceneAttribute = new InvVar(GetIDArray()); sceneAttributes.Add(newSceneAttribute); DeactivateAllAttributes(); ActivateAttribute(newSceneAttribute); } EditorGUILayout.EndVertical(); }
private void CreatePropertiesGUI() { EditorGUILayout.BeginVertical(CustomStyles.thinBox); EditorGUILayout.LabelField("Inventory properties", CustomStyles.subHeader); EditorGUILayout.Space(); scrollPos = EditorGUILayout.BeginScrollView(scrollPos, GUILayout.Height(Mathf.Min(invVars.Count * 21, 235f) + 5)); foreach (InvVar invVar in invVars) { EditorGUILayout.BeginHorizontal(); string buttonLabel = invVar.label; if (buttonLabel == "") { buttonLabel = "(Untitled)"; } if (GUILayout.Toggle(invVar.isEditing, invVar.id + ": " + buttonLabel, "Button")) { if (selectedInvVar != invVar) { DeactivateAllInvVars(); ActivateItem(invVar); } } if (GUILayout.Button(Resource.CogIcon, GUILayout.Width(20f), GUILayout.Height(15f))) { SideMenu(invVar); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndScrollView(); if (GUILayout.Button("Create new property")) { Undo.RecordObject(this, "Create inventory property"); InvVar newInvVar = new InvVar(GetIDArrayProperty()); invVars.Add(newInvVar); DeactivateAllInvVars(); ActivateItem(newInvVar); } EditorGUILayout.EndVertical(); }
/** * A Constructor that copies all values from another variable. * This way ensures that no connection remains to the asset file. */ public InvVar(InvVar assetVar) { val = assetVar.val; floatVal = assetVar.floatVal; textVal = assetVar.textVal; type = assetVar.type; id = assetVar.id; label = assetVar.label; link = assetVar.link; pmVar = assetVar.pmVar; popUps = assetVar.popUps; updateLinkOnStart = assetVar.updateLinkOnStart; categoryIDs = assetVar.categoryIDs; limitToCategories = assetVar.limitToCategories; textValLineID = assetVar.textValLineID; popUpsLineID = assetVar.popUpsLineID; }
override public ActionEnd End(List <AC.Action> actions) { if (attributeID == -1) { return(GenerateStopActionEnd()); } InvVar attribute = sceneSettings.GetAttribute(attributeID); if (attribute != null) { return(ProcessResult(CheckCondition(attribute), actions)); } ACDebug.LogWarning("The 'Scene: Check attribute' Action halted the ActionList because it cannot find the scene attribute with an ID of " + attributeID); return(GenerateStopActionEnd()); }
public override ActionEnd End(List <Action> actions) { if (attributeID == -1) { return(GenerateStopActionEnd()); } InvVar attribute = sceneSettings.GetAttribute(attributeID); if (attribute != null) { return(ProcessResult(CheckCondition(attribute), actions)); } LogWarning("Cannot find the scene attribute with an ID of " + attributeID); return(GenerateStopActionEnd()); }
override public float Run() { InvItem invItem = (setVarAsPropertyMethod == SetVarAsPropertyMethod.SelectedItem) ? KickStarter.runtimeInventory.LastSelectedItem : KickStarter.inventoryManager.GetItem(invID); if (invItem != null && runtimeVariable != null) { InvVar invVar = invItem.GetProperty(propertyID); if (invVar == null) { LogWarning("Cannot find property with ID " + propertyID + " on Inventory item " + invItem.GetLabel(0)); return(0f); } if (runtimeVariable.type == VariableType.String) { runtimeVariable.textVal = invVar.GetDisplayValue(Options.GetLanguage()); } else if (runtimeVariable.type == invVar.type) { if (invVar.type == VariableType.Float) { runtimeVariable.FloatValue = invVar.FloatValue; } else if (invVar.type == VariableType.Vector3) { runtimeVariable.Vector3Value = invVar.Vector3Value; } else { runtimeVariable.IntegerValue = invVar.IntegerValue; } } else { LogWarning("Cannot assign " + varLocation.ToString() + " Variable " + runtimeVariable.label + "'s value from '" + invVar.label + "' property because their types do not match."); } } return(0); }
/** * <summary>Updates the 'value' variables specific to an inventory item based on another InvVar instance.</summary> * <param name = "invVar">The other InvVar to copy 'value' variables from</param> * <param name = "addValues">If True, integer and float values will be added to the property, rather then replaced/param> */ public void TransferValues(InvVar invVar, bool addValues = false) { if (addValues) { val += invVar.val; floatVal += invVar.floatVal; } else { val = invVar.val; floatVal = invVar.floatVal; } textVal = invVar.textVal; textValLineID = invVar.textValLineID; vector3Val = invVar.vector3Val; popUpsLineID = invVar.popUpsLineID; popUpID = invVar.popUpID; }
override public float Run() { GVar myVar = (varLocation == VariableLocation.Global) ? GlobalVariables.GetVariable(variableID) : LocalVariables.GetVariable(variableID, localVariables); InvItem invItem = (setVarAsPropertyMethod == SetVarAsPropertyMethod.SelectedItem) ? KickStarter.runtimeInventory.LastSelectedItem : KickStarter.inventoryManager.GetItem(invID); if (invItem != null && myVar != null) { InvVar invVar = invItem.GetProperty(propertyID); if (myVar.type == VariableType.String) { myVar.textVal = invVar.GetDisplayValue(Options.GetLanguage()); } else if (myVar.type == invVar.type) { if (invVar.type == VariableType.Float) { myVar.FloatValue = invVar.FloatValue; } else if (invVar.type == VariableType.Vector3) { myVar.Vector3Value = invVar.Vector3Value; } else { myVar.IntegerValue = invVar.IntegerValue; } } else { ACDebug.LogWarning("Cannot assign " + varLocation.ToString() + " Variable " + myVar.label + "'s value from '" + invVar.label + "' property because their types do not match."); } } return(0); }
private void PropertyCallback(object obj) { if (sideItem >= 0) { ResetFilter(); InvVar tempVar = invVars[sideItem]; switch (obj.ToString()) { case "Insert after": Undo.RecordObject(this, "Insert item"); invVars.Insert(sideItem + 1, new InvVar(GetIDArrayProperty())); break; case "Delete": Undo.RecordObject(this, "Delete item"); DeactivateAllInvVars(); invVars.RemoveAt(sideItem); break; case "Move up": Undo.RecordObject(this, "Move item up"); invVars.RemoveAt(sideItem); invVars.Insert(sideItem - 1, tempVar); break; case "Move down": Undo.RecordObject(this, "Move item down"); invVars.RemoveAt(sideItem); invVars.Insert(sideItem + 1, tempVar); break; } } EditorUtility.SetDirty(this); AssetDatabase.SaveAssets(); sideItem = -1; }
/** * <summary>Gets a property of the inventory item.</summary> * <param name = "ID">The ID number of the property to get</param> * <param name = "multiplyByItemCount">If True, then the property's integer/float value will be multipled by the item's count</param> * <returns>The property of the inventory item</returns> */ public InvVar GetProperty(int ID, bool multiplyByItemCount = false) { if (vars.Count > 0 && ID >= 0) { foreach (InvVar var in vars) { if (var.id == ID) { if (multiplyByItemCount && count > 1 && (var.type == VariableType.Integer || var.type == VariableType.Float)) { InvVar stackedVar = new InvVar(var); stackedVar.val *= count; stackedVar.floatVal *= (float)count; return(stackedVar); } return(var); } } } return(null); }
/** * <summary>Gets the total amount of given integer or float inventory property, found in the current inventory<summary> * <param name = "propertyID">The ID of the integer or float inventory property</param> * <returns>The total amount of the property's value</returns> */ public InvVar GetPropertyTotals(int propertyID) { InvVar originalVar = KickStarter.inventoryManager.GetProperty(propertyID); if (originalVar == null) { return(null); } InvVar totalVar = new InvVar(propertyID, originalVar.type); foreach (InvInstance invInstance in invInstances) { if (InvInstance.IsValid(invInstance)) { InvVar var = invInstance.GetProperty(propertyID); if (var != null) { totalVar.TransferValues(var); } } } return(totalVar); }
private void ActivateAttribute(InvVar sceneAttribute) { selectedSceneAttribute = sceneAttribute; EditorGUIUtility.editingTextField = false; }
private void ActivateItem(InvVar invVar) { invVar.isEditing = true; selectedInvVar = invVar; }
protected bool CheckCondition(InvVar attribute) { if (attribute == null) { LogWarning("Cannot check state of attribute since it cannot be found!"); return(false); } switch (attribute.type) { case VariableType.Boolean: { int fieldValue = attribute.val; int compareValue = (int)boolValue; if (boolCondition == BoolCondition.EqualTo) { if (fieldValue == compareValue) { return(true); } } else { if (fieldValue != compareValue) { return(true); } } break; } case VariableType.Integer: case VariableType.PopUp: { int fieldValue = attribute.val; int compareValue = intValue; if (intCondition == IntCondition.EqualTo) { if (fieldValue == compareValue) { return(true); } } else if (intCondition == IntCondition.NotEqualTo) { if (fieldValue != compareValue) { return(true); } } else if (intCondition == IntCondition.LessThan) { if (fieldValue < compareValue) { return(true); } } else if (intCondition == IntCondition.MoreThan) { if (fieldValue > compareValue) { return(true); } } break; } case VariableType.Float: { float fieldValue = attribute.floatVal; float compareValue = floatValue; if (intCondition == IntCondition.EqualTo) { if (Mathf.Approximately(fieldValue, compareValue)) { return(true); } } else if (intCondition == IntCondition.NotEqualTo) { if (!Mathf.Approximately(fieldValue, compareValue)) { return(true); } } else if (intCondition == IntCondition.LessThan) { if (fieldValue < compareValue) { return(true); } } else if (intCondition == IntCondition.MoreThan) { if (fieldValue > compareValue) { return(true); } } break; } case VariableType.String: { string fieldValue = attribute.textVal; string compareValue = AdvGame.ConvertTokens(stringValue); if (!checkCase) { fieldValue = fieldValue.ToLower(); compareValue = compareValue.ToLower(); } if (boolCondition == BoolCondition.EqualTo) { if (fieldValue == compareValue) { return(true); } } else { if (fieldValue != compareValue) { return(true); } } break; } default: break; } return(false); }
private void RebuildProperties(InvItem item) { // Which properties are available? List<int> availableVarIDs = new List<int>(); foreach (InvVar invVar in invVars) { if (!invVar.limitToCategories || bins.Count == 0 || invVar.categoryIDs.Contains (item.binID)) { availableVarIDs.Add (invVar.id); } } // Create new properties / transfer existing values List<InvVar> newInvVars = new List<InvVar>(); foreach (InvVar invVar in invVars) { if (availableVarIDs.Contains (invVar.id)) { InvVar newInvVar = new InvVar (invVar); InvVar oldInvVar = item.GetProperty (invVar.id); if (oldInvVar != null) { newInvVar.TransferValues (oldInvVar); } newInvVars.Add (newInvVar); } } item.vars = newInvVars; }
public InvVar GetPropertyTotals(int ID) { InvVar totalVar = new InvVar (); foreach (InvItem item in localItems) { InvVar var = item.GetProperty (ID); if (var != null) { totalVar.val += var.val; totalVar.floatVal += var.floatVal; } } return totalVar; }
public override float Run() { int runtimeInvID = -1; if (setVarAsPropertyMethod == SetVarAsPropertyMethod.SelectedItem) { if (KickStarter.runtimeInventory.SelectedItem != null) { runtimeInvID = KickStarter.runtimeInventory.SelectedItem.id; } } else { runtimeInvID = invID; } InvVar invVar = null; if (runtimeInvID >= 0) { if (multiplyByItemCount) { invVar = KickStarter.runtimeInventory.GetPropertyTotals(propertyID, runtimeInvID); } else { InvItem invItem = KickStarter.inventoryManager.GetItem(runtimeInvID); if (invItem != null) { invVar = invItem.GetProperty(propertyID); } } } if (invVar == null) { LogWarning("Cannot find property with ID " + propertyID + " on Inventory item ID " + runtimeInvID); return(0f); } if (runtimeVariable.type == VariableType.String) { runtimeVariable.textVal = invVar.GetDisplayValue(Options.GetLanguage()); } else if (runtimeVariable.type == invVar.type) { if (invVar.type == VariableType.Float) { runtimeVariable.FloatValue = invVar.FloatValue; } else if (invVar.type == VariableType.Vector3) { runtimeVariable.Vector3Value = invVar.Vector3Value; } else { runtimeVariable.IntegerValue = invVar.IntegerValue; } } else { LogWarning("Cannot assign " + varLocation.ToString() + " Variable " + runtimeVariable.label + "'s value from '" + invVar.label + "' property because their types do not match."); } return(0); }
private void CreatePropertiesGUI() { EditorGUILayout.LabelField ("Inventory properties", EditorStyles.boldLabel); EditorGUILayout.Space (); scrollPos = EditorGUILayout.BeginScrollView (scrollPos, GUILayout.Height (Mathf.Min (invVars.Count * 21, 235f)+5)); foreach (InvVar invVar in invVars) { EditorGUILayout.BeginHorizontal (); string buttonLabel = invVar.label; if (buttonLabel == "") { buttonLabel = "(Untitled)"; } if (GUILayout.Toggle (invVar.isEditing, invVar.id + ": " + buttonLabel, "Button")) { if (selectedInvVar != invVar) { DeactivateAllInvVars (); ActivateItem (invVar); } } if (GUILayout.Button (sideIcon, GUILayout.Width (20f), GUILayout.Height (15f))) { SideMenu (invVar); } EditorGUILayout.EndHorizontal (); } EditorGUILayout.EndScrollView (); if (GUILayout.Button("Create new property")) { Undo.RecordObject (this, "Create inventory property"); InvVar newInvVar = new InvVar (GetIDArrayProperty ()); invVars.Add (newInvVar); DeactivateAllInvVars (); ActivateItem (newInvVar); } }
private void DeactivateAllAttributes() { selectedSceneAttribute = null; }
public override float Run() { int runtimeInvID = -1; if (setVarAsPropertyMethod == SetVarAsPropertyMethod.SelectedItem) { if (InvInstance.IsValid(KickStarter.runtimeInventory.SelectedInstance)) { runtimeInvID = KickStarter.runtimeInventory.SelectedInstance.ItemID; } } else { runtimeInvID = invID; } InvVar invVar = null; if (runtimeInvID >= 0) { InvInstance invInstance = (useLiveValues) ? KickStarter.runtimeInventory.GetInstance(runtimeInvID) : new InvInstance(KickStarter.inventoryManager.GetItem(runtimeInvID)); if (!InvInstance.IsValid(invInstance)) { if (useLiveValues) { LogWarning("Cannot find Inventory item with ID " + runtimeInvID + " in the Player's inventory"); } else { LogWarning("Cannot find Inventory item with ID " + runtimeInvID); } return(0f); } invVar = invInstance.GetProperty(propertyID); } if (invVar == null) { LogWarning("Cannot find property with ID " + propertyID + " on Inventory item ID " + runtimeInvID); return(0f); } if (runtimeVariable.type == VariableType.String) { runtimeVariable.TextValue = invVar.GetDisplayValue(Options.GetLanguage()); } else if (runtimeVariable.type == invVar.type) { int itemCount = (useLiveValues && multiplyByItemCount) ? KickStarter.runtimeInventory.GetCount(runtimeInvID) : 1; switch (invVar.type) { case VariableType.Float: runtimeVariable.FloatValue = invVar.FloatValue * (float)itemCount; break; case VariableType.Integer: runtimeVariable.IntegerValue = invVar.IntegerValue * itemCount; break; case VariableType.Vector3: runtimeVariable.Vector3Value = invVar.Vector3Value; break; default: runtimeVariable.IntegerValue = invVar.IntegerValue; break; } } else { LogWarning("Cannot assign " + varLocation.ToString() + " Variable " + runtimeVariable.label + "'s value from '" + invVar.label + "' property because their types do not match."); } return(0); }
private void SideMenu(InvVar invVar) { GenericMenu menu = new GenericMenu (); sideItem = invVars.IndexOf (invVar); menu.AddItem (new GUIContent ("Insert after"), false, PropertyCallback, "Insert after"); if (invVars.Count > 0) { menu.AddItem (new GUIContent ("Delete"), false, PropertyCallback, "Delete"); } if (sideItem > 0 || sideItem < invVars.Count-1) { menu.AddSeparator (""); } if (sideItem > 0) { menu.AddItem (new GUIContent ("Move up"), false, PropertyCallback, "Move up"); } if (sideItem < invVars.Count-1) { menu.AddItem (new GUIContent ("Move down"), false, PropertyCallback, "Move down"); } menu.ShowAsContext (); }