void OnSubactionChanged(SubactionData subaction) { //We need to change the text without firing another update, so unready then re-ready after setting ready = false; input.value = panel.varData.data; ready = true; }
public BaseIdle() : base("NeutralAction", 1, "idle", "NeutralAction") { SubactionData transitionData = SubactionDataDefault.GetByName("DoTransition"); transitionData.SetArgument("transitionState", "NeutralState"); subactionCategories.Add(SubactionGroup.STATETRANSITION, stateTransitionDataList); }
void InstantiateSubactionVarDataCard(SubactionVarData varData, SubactionData subaction) { GameObject go = NGUITools.AddChild(gameObject, varDataCardPrefab); SubactionVarDataPanel panel = go.GetComponent <SubactionVarDataPanel>(); panel.varData = varData; panel.BroadcastMessage("OnSubactionChanged", subaction, SendMessageOptions.DontRequireReceiver); children.Add(go); }
public static Subaction GenerateSubactionFromData(SubactionData data) { try{ Subaction subaction = ScriptableObject.CreateInstance("Subaction" + data.SubactionName) as Subaction; subaction.arg_dict = data.arguments; return(subaction); } catch { Debug.Log("Could not find subaction named " + data.SubactionName); return(null); } }
public void SetSubaction(SubactionData subactionToSet) { subaction = subactionToSet; //label.text = subaction.SubactionName; label.text = subaction.ToString(); ModifyLegacyEditorDataAction legacyAction = ScriptableObject.CreateInstance <ModifyLegacyEditorDataAction>(); legacyAction.init("currentSubaction", subactionToSet); legacyAction.enableDeselect(); GetComponent <OnClickSendAction>().action = legacyAction; }
private void displayHitbox(SubactionData data) { viewerBoxInstance = GameObject.Instantiate <ViewerBoxDisplayer>(viewerBoxPrefab); viewerBoxInstance.viewerCamera = viewerCamera; viewerBoxInstance.fighter = fighterViewerObject; viewerBoxInstance.createHitboxSubData = data; viewerBoxInstance.transform.SetParent(fighterViewerObject.transform.parent, false); viewerBoxInstance.BroadcastMessage("SetCamera", viewerCamera); //Link it to the proper createHitbox action }
public void setSubactionFromData() { SubactionData subaction = LegacyEditorData.instance.currentSubaction; if (subaction.SubactionName == "CreateHitbox") { subaction.arguments["centerX"].data = boxRect.center.x.ToString(); subaction.arguments["centerY"].data = boxRect.center.y.ToString(); subaction.arguments["width"].data = boxRect.width.ToString(); subaction.arguments["height"].data = boxRect.height.ToString(); LegacyEditorData.ChangedSubaction(); } }
private void ChangedSubaction(SubactionData data) { //If it's the same subaction, it means only the data inside it has changed. The internal components will handle this. if (data != lastData) { disposeHitbox(); //We always throw out the old one before we make a new one if (data?.SubactionName == "CreateHitbox") { displayHitbox(data); } } lastData = data; }
private void instantiateButton(SubactionData subDataToSet, int index) { GameObject go = NGUITools.AddChild(gameObject, SubactionCardPrefab); SubactionCard card = go.GetComponent <SubactionCard>(); card.SetAnchors(anchorObject, leftAnchorOffset, rightAnchorOffset); card.SetSubaction(subDataToSet); card.SetEditor(editor); card.RegisterListeners(); card.setIndex(index); children.Add(go); }
void OnSubactionChanged(SubactionData data) { if (subaction != null) //If the subaction is null it should always remain off { if (data == subaction) { selectedBg.spriteName = "selected-action-bg"; } else { selectedBg.spriteName = "unselected-action-bg"; } } }
public void changedValue(string newVal) { //Because this window will only ever be visible when a create hitbox subaction is selected, we just need to get the current subaction. SubactionData createHitboxSubaction = editor.currentSubaction; SubactionVarData varData = createHitboxSubaction.arguments[varDataName]; //Convert this to a LegacyAction ChangeSubactionVarDataInput legacyAction = ScriptableObject.CreateInstance <ChangeSubactionVarDataInput>(); legacyAction.init(varData, newVal); LegacyEditorData.instance.DoAction(legacyAction); input.value = varData.data; }
void OnSubactionChanged(SubactionData subaction) { //Since this is fired even when the panel is deactivated, we need to check if it's a createHitboxAction if (editor?.currentSubaction?.SubactionName == "CreateHitbox") { SubactionData createHitboxSubaction = editor.currentSubaction; SubactionVarData varData = createHitboxSubaction.arguments[varDataName]; //We need to change the text without firing another update, so unready then re-ready after setting ready = false; input.value = varData.data; ready = true; } }
private void getDataFromSubaction() { SubactionData subaction = LegacyEditorData.instance.currentSubaction; if (subaction.SubactionName == "CreateHitbox") { float centerX = float.Parse(subaction.arguments["centerX"].data); float centerY = float.Parse(subaction.arguments["centerY"].data); float width = float.Parse(subaction.arguments["width"].data); float height = float.Parse(subaction.arguments["height"].data); boxRect.center = new Vector2(centerX, centerY); boxRect.size = new Vector2(width, height); } }
/// <summary> /// In this parsing section, we can assume the action is set and we are adding properties or subactions to it. This means we don't need to null check everything /// </summary> /// <param name="line">The full text line to parse</param> /// <param name="workingAction">The DynamicAction currently being processed. Guaranteed not null.</param> private static void ProcessActionSection(string line, DynamicAction workingAction, int lineNumber) { string token; //Process Properties Tokens if ((token = GetTokenVal(line, ActionTokens.Properties.Length)) != null) { int lengthNo = 1; if (int.TryParse(token, out lengthNo)) { workingAction.length = lengthNo; } else { throwException(string.Format("Could not parse int for property {0} - {1}", ActionTokens.Properties.Length, token), lineNumber); } } else if ((token = GetTokenVal(line, ActionTokens.Properties.Animation)) != null) { workingAction.animationName = token; } else if ((token = GetTokenVal(line, ActionTokens.Properties.ExitAction)) != null) { workingAction.exit_action = token; } //Process Group else if ((token = GetTokenVal(line, ActionTokens.GroupStart)) != null) { //Debug.Log("Starting SubGroup "+token); workingSubGroupName = token; } else if ((token = GetTokenVal(line, ActionTokens.GroupEnd, 0)) != null) { //Debug.Log("Ending SubGroup"); workingSubGroupName = null; } //If we haven't closed this subGroup by now, all that's left is a Subaction Definition else if (workingSubGroupName != null) { SubactionData subData = processSubactionLine(line, lineNumber); if (subData != null) { workingAction.AddSubaction(workingSubGroupName, subData); } } }
/// <summary> /// Add a Subaction to the action in the given category. Optionally, insert the subaction at a given position /// Defaults to -1, which will be interpreted as 'add it to the end' /// </summary> /// <param name="category">The subaction category to add it to</param> /// <param name="subData">The SubactionData to add to the list</param> /// <param name="order">Where to put it in the list (zero indexed). The SubactionData at that position and everything afterwards will get bumped up one. -1 means add to the end</param> public void AddSubaction(string category, SubactionData subData, int position = LAST_POSITION) { List <SubactionData> subList = subactionCategories.GetIfKeyExists(category); if (position == LAST_POSITION) { subList.Add(subData); } else { subList.Insert(position, subData); for (int i = position + 1; i < subList.Count; i++) { subList[i].order += 1; } } }
public override void execute() { actionToAddTo = LegacyEditorData.instance.currentAction; groupToAddTo = LegacyEditorData.instance.subactionGroup; Debug.Log("CreateNewSubaction actionToAddTo: " + actionToAddTo); Debug.Log("CreateNewSubaction groupToAddTo: " + groupToAddTo); //Since we don't want to add THIS subactionData, but a copy of it, we reinstance the scriptable object //subDataToAdd = Instantiate(subDataMaster) as SubactionData; if (groupToAddTo == "Current Frame") { groupToAddTo = SubactionGroup.ONFRAME(LegacyEditorData.instance.currentFrame); Debug.Log("Current Group: " + groupToAddTo); } subDataToAdd = subDataMaster.CreateSubactionData(); actionToAddTo.subactionCategories.GetIfKeyExists(groupToAddTo).Add(subDataToAdd); Debug.Log(actionToAddTo.subactionCategories); LegacyEditorData.ChangedActionData(); }
void OnSubactionChanged(SubactionData subaction) { //Debug.Log("Subaction Changed: " + subaction,this); if (subaction == null) { //Debug.Log("Deactivating default", defaultSubactionContextPanel); foreach (EditSubactionContextPanel uniquePanel in uniqueContextPanels.Values) { uniquePanel.DeactivatePanel(); } defaultSubactionContextPanel.DeactivatePanel(); } else { if (uniqueContextPanels.ContainsKey(subaction.SubactionName)) { if (LegacyEditorData.contextualPanel != null) { //Debug.Log("Deactivating old panel for unique", LegacyEditorData.contextualPanel); LegacyEditorData.contextualPanel.DeactivatePanel(); } //Debug.Log("Activating unique panel", uniqueContextPanels[subaction.SubactionName]); uniqueContextPanels[subaction.SubactionName].ActivatePanel(); } else { if (LegacyEditorData.contextualPanel != null) { //Debug.Log("Deactivating old panel for default", LegacyEditorData.contextualPanel); LegacyEditorData.contextualPanel.DeactivatePanel(); } //Debug.Log("Activating default panel", defaultSubactionContextPanel); defaultSubactionContextPanel.ActivatePanel(); } } }
void OnSubactionChanged(SubactionData subaction) { SubactionData sub = LegacyEditorData.instance.currentSubaction; //Since we want to clear the list if we deselect a subaction, we take this part out of the null check foreach (GameObject child in children) { NGUITools.Destroy(child); } children.Clear(); if (sub != null) { foreach (SubactionVarData varData in sub.arguments.GetItems()) { InstantiateSubactionVarDataCard(varData, subaction); } } InstantiateDeleteButton(); scrollPanel.ResetPosition(); grid.Reposition(); }
public void init(SubactionData data) { subDataToRemove = data; }
/// <summary> /// Given a line containing the definition of a SubactionData, return that SubactionData as an object. /// This uses reflection to get the Subactions, so the spelling of the SubName is key. /// </summary> /// <param name="line">The line being parsed</param> /// <returns>A proper SubactionData object, ready for injecting into a Dynamic Action</returns> private static SubactionData processSubactionLine(string line, int lineNumber) { string[] startParenSplit = line.Split('('); //This string should contain EXACTLY one parenthesis pair. Any more or less and you f****d up your script, dawg if (startParenSplit.Length != 2 || !line.EndsWith(")")) { //Debug.Log(startParenSplit.Length); //Debug.Log(line.EndsWith(")")); throwException("Incorrect parenthesis in subDataLine: " + line, lineNumber); return(null); } string subDataName = startParenSplit[0]; string argList = startParenSplit[1].Substring(0, startParenSplit[1].Length - 1); //Debug.Log(string.Format("PARSING SUBACTION {0}\n\tArguments: {1}",subDataName,argList)); SubactionDataDefault subDataDef = Resources.Load <SubactionDataDefault>("SubactionData/" + subDataName); if (subDataDef != null) { SubactionData subData = subDataDef.CreateSubactionData(); string[] splitArgs = new string[0]; if (argList.Length > 0) { splitArgs = argList.Split(','); } if (subDataDef.scriptArgNames.Count != splitArgs.Length) { throwException(string.Format("Subaction {0} has {1} arguments, expecting {2}", subDataName, splitArgs.Length, subDataDef.scriptArgNames.Count), lineNumber); return(null); } for (int i = 0; i < splitArgs.Length; i++) { string argumentName = subDataDef.scriptArgNames[i]; SubactionSource source = SubactionSource.CONSTANT; if (splitArgs[i].StartsWith("owner.")) { source = SubactionSource.OWNER; splitArgs[i] = splitArgs[i].Substring("owner.".Length); } else if (splitArgs[i].StartsWith("action.")) { source = SubactionSource.ACTION; splitArgs[i] = splitArgs[i].Substring("action.".Length); } SubactionVarType varType = subDataDef.arguments[argumentName].type; SubactionVarData argVarData = new SubactionVarData(argumentName, source, varType, splitArgs[i]); subData.arguments[argumentName] = argVarData; } return(subData); } else { throwException("No Subaction found with name " + subDataName, lineNumber); } return(null); }
void OnSubactionChanged(SubactionData data) { checkbox.value = (panel.varData.data == "true"); }
private void SubactionChanged(SubactionData sub) { OnModelChanged(); }