public override void Awake() { if (this.fsmTemplateControl.fsmTemplate != null && Application.isPlaying) { this.runFsm = base.Fsm.CreateSubFsm(this.fsmTemplateControl); } }
void Awake() { tween = GetComponent<Tween>(); tween.autoPlay = false; fsm = new Fsm(this); }
/// <summary> /// Initialize FSM on awake so it doesn't cause hitches later /// </summary> public override void Awake() { if (fsmTemplateControl.fsmTemplate != null && Application.isPlaying) { runFsm = Fsm.CreateSubFsm(fsmTemplateControl); } }
public StateMovingCurvedGround(Fsm fsm) : base(fsm) { _locomotion = Fsm.gameObject.GetOrAdd<ManagerLocomotion>(); _ground = Fsm.gameObject.GetOrAdd<ManagerGroundProbe>(); _input = Fsm.gameObject.GetComponent<IManagerInput>(); }
/// <summary> /// Open the specified FSM in the Playmaker Editor /// </summary> public static void OpenInEditor(Fsm fsm) { if (fsm.Owner != null) { OpenInEditor(fsm.Owner as PlayMakerFSM); } }
void Awake() { rigidbody = GetComponent<Rigidbody2D>(); animator = GetComponent<Animator>(); fsm = new Fsm(this); }
/// <summary> /// Initialize FSM on awake so it doesn't cause hitches later /// </summary> public override void Awake() { if (fsmTemplateControl.fsmTemplate != null) { runFsm = Fsm.CreateSubFsm(fsmTemplateControl); } }
public static void SetDirty(Fsm fsm) { #if UNITY_EDITOR // Unity 5.3.2 disallows scene dirty calls when playing if (Application.isPlaying) return; if (fsm == null || fsm.OwnerObject == null) return; //Debug.Log("SetDirty: " + FsmUtility.GetFullFsmLabel(fsm)); fsm.Preprocessed = false; // force pre-process to run again if (fsm.UsedInTemplate != null) { UnityEditor.EditorUtility.SetDirty(fsm.UsedInTemplate); } else if (fsm.Owner != null) { UnityEditor.EditorUtility.SetDirty(fsm.Owner); #if !UNITY_PRE_5_3 UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(fsm.Owner.gameObject.scene); #elif !UNITY_PRE_5_0 // Not sure if we need to do this...? UnityEditor.EditorApplication.MarkSceneDirty(); #endif } #endif }
public StateFalling(Fsm fsm) : base(fsm) { _material = Resources.Load<PhysicsMaterial2D>("NoFriction"); _collider = Fsm.gameObject.GetComponent<Collider2D>(); _collider.sharedMaterial = null; _locomotion = Fsm.gameObject.GetOrAdd<ManagerLocomotion>(); _locomotion.Rigidbody.gravityScale = 11f; _input = Fsm.gameObject.GetComponent<IManagerInput>(); }
public StateHit(Fsm fsm) : base(fsm) { StateDuration = 0.25f; _locomotion = Fsm.gameObject.GetOrAdd<ManagerLocomotion>(); _health = Fsm.gameObject.GetOrAdd<ManagerHealth>(); _collision = Fsm.gameObject.GetOrAdd<ManagerCollision>(); }
public static void RecordLastRaycastHitInfo(Fsm fsm,RaycastHit2D info) { if (lastRaycastHit2DInfoLUT==null) { lastRaycastHit2DInfoLUT = new Dictionary<Fsm, RaycastHit2D>(); } lastRaycastHit2DInfoLUT[fsm] = info; }
public StateProjectile(Fsm fsm, string prefabPath, float angle, float duration) : base(fsm) { StateDuration = duration; _shotAngle = angle; _shotOffset = (Quaternion.Euler(0f, 0f, _shotAngle) * (3f * Vector2.right)); _projectilePrefab = Resources.Load<GameObject>(prefabPath); }
// ONLY WORKS IF THE FSMVAR POINTS TO A REGULAR FSM VARIABLE public static void RefreshValueFromFsmVar(Fsm fromFsm,FsmVar fsmVar) { if (fromFsm==null) { return; } if (fsmVar==null) { return; } if (!fsmVar.useVariable) { return; } switch (fsmVar.Type) { case VariableType.Int: fsmVar.GetValueFrom( (NamedVariable)fromFsm.Variables.GetFsmInt(fsmVar.variableName) ); break; case VariableType.Float: fsmVar.GetValueFrom( (NamedVariable)fromFsm.Variables.GetFsmFloat(fsmVar.variableName)); break; case VariableType.Bool: fsmVar.GetValueFrom( (NamedVariable)fromFsm.Variables.GetFsmBool(fsmVar.variableName)); break; case VariableType.Color: fsmVar.GetValueFrom( (NamedVariable)fromFsm.Variables.GetFsmColor(fsmVar.variableName)); break; case VariableType.Quaternion: fsmVar.GetValueFrom( (NamedVariable)fromFsm.Variables.GetFsmQuaternion(fsmVar.variableName)); break; case VariableType.Rect: fsmVar.GetValueFrom( (NamedVariable)fromFsm.Variables.GetFsmRect(fsmVar.variableName)); break; case VariableType.Vector2: fsmVar.GetValueFrom( (NamedVariable)fromFsm.Variables.GetFsmVector2(fsmVar.variableName)); break; case VariableType.Vector3: fsmVar.GetValueFrom( (NamedVariable)fromFsm.Variables.GetFsmVector3(fsmVar.variableName)); break; case VariableType.Texture: fsmVar.GetValueFrom( (NamedVariable)fromFsm.Variables.GetFsmVector3(fsmVar.variableName)); break; case VariableType.Material: fsmVar.GetValueFrom( (NamedVariable)fromFsm.Variables.GetFsmMaterial(fsmVar.variableName)); break; case VariableType.String: fsmVar.GetValueFrom( (NamedVariable)fromFsm.Variables.GetFsmString(fsmVar.variableName)); break; case VariableType.GameObject: fsmVar.GetValueFrom( (NamedVariable)fromFsm.Variables.GetFsmGameObject(fsmVar.variableName)); break; } }
public static RaycastHit2D GetLastRaycastHitInfo(Fsm fsm) { if (lastRaycastHit2DInfoLUT==null) { lastRaycastHit2DInfoLUT[fsm] = new RaycastHit2D(); return lastRaycastHit2DInfoLUT[fsm]; } return lastRaycastHit2DInfoLUT[fsm]; }
// On liste ici tout les managers et composants qui vont nous servir dans cet état //ManagerLocomotion _locomotion; //IManagerInput _input; // Le constructeur de l'état, appelé seulement une fois : au moment où on utilise AddState dans la fsm. // Utile pour référencer les manager ou des composants, et fixer la durée de l'état public StateToCopy(Fsm fsm) : base(fsm) { // GetOrAdd permet d'ajouter un composant s'il n'est pas déjà attaché, dans tous les cas il retourne le composant. //_input = Fsm.gameObject.GetComponent<IManagerInput>(); // Par contre on ne peut par ajouter une interface comme composant, dans ce cas on doit utiliser GetComponent. //_locomotion = Fsm.gameObject.GetOrAdd<ManagerLocomotion>(); // StateDuration représente la durée de l'état, la propriété IsOver vaudra true quand cette durée sera écoulée. // Cette propriété sert principalement pour écrire des transitions dans la fsm : pour sortir de l'état quand il est achevé. // Il peut être laissé à zero si on ne sort de l'état que pour des conditions indépendantes du temps (ex : vie < 10) StateDuration = 0f; }
public string ParseXpathQuery(Fsm fsm) { parsedQuery = xPathQuery.Value; if (xPathVariables!=null) { int i = 0; foreach (FsmVar xPathVar in xPathVariables) { if (! xPathVar.IsNone) { parsedQuery = parsedQuery.Replace ("_" + i + "_", PlayMakerUtils.ParseFsmVarToString(fsm,xPathVar)) ; } i++; } } return parsedQuery; }
public static bool EditFsmXpathQueryField(Fsm fsm,FsmXpathQuery target) { bool edited =false; target._foldout = FsmEditorGUILayout.BoldFoldout(target._foldout,new GUIContent("xPath Query")); if (target.xPathQuery==null) { target.xPathQuery = new FsmString(); } if (target._foldout) { target.xPathQuery = VariableEditor.FsmStringField(new GUIContent("xPath Query"),fsm,target.xPathQuery,null); } if (string.IsNullOrEmpty(target.xPathQuery.Value)) { }else{ if (target.xPathVariables==null || target.xPathVariables.Length==0) { if (!target._foldout) { EditorGUILayout.LabelField("xPath Query",target.xPathQuery.Value); } }else{ EditorGUILayout.LabelField("xPath Query parsed",target.ParseXpathQuery(fsm)); } } if (target._foldout) { edited = edited || EditFsmXpathQueryVariablesProperties(fsm,target); } return edited; }
public override void OnEnter() { GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { return; } spriteRenderer = go.GetComponent <SpriteRenderer>(); if (spriteRenderer == null) { LogError("SwapSingleSprite: Missing SpriteRenderer!"); return; } _orig = spriteRenderer.sprite; SwapSprites(); Finish(); }
public void GetItemAtIndex() { if (itemName.IsNone) { return; } object element = null; currentIndex.Value = nextItemIndex; try { element = (string)gdeData[nextItemIndex]; } catch (System.Exception e) { Debug.LogError(e.Message); Fsm.Event(failureEvent); return; } PlayMakerUtils.ApplyValueToFsmVar(Fsm, itemName, element); }
void doRemoveRpc() { if (_networkView == null) { Fsm.Event(failureEvent); return; } if (_networkView.isMine) { PhotonNetwork.RemoveRPCs(_networkView); } else { if (!PhotonNetwork.isMasterClient) { Fsm.Event(failureEvent); return; } PhotonNetwork.RemoveRPCs(_networkView); } }
protected override void DoPaintAction() { var go = Fsm.GetOwnerDefaultTarget(gameObject); if (UpdateCache(go)) { STETilemap tilemap = cachedComponent as STETilemap; int gridX; int gridY; if ((ePositionType)positionType.Value == ePositionType.LocalPosition) { gridX = TilemapUtils.GetGridX(tilemap, startPaintingPosition.Value); gridY = TilemapUtils.GetGridY(tilemap, startPaintingPosition.Value); } else// if ((ePositionType)positionType.Value == ePositionType.GridPosition) { gridX = (int)startPaintingPosition.Value.x; gridY = (int)startPaintingPosition.Value.y; } TilemapDrawingUtils.FloodFill(tilemap as STETilemap, gridX, gridY, tileSelection.Get2DTileDataArray(), randomizePattern.Value); tilemap.UpdateMesh(); } }
public override void OnEnter() { if (nextItemIndex == 0) { if (!SetUpHashTableProxyPointer(Fsm.GetOwnerDefaultTarget(gameObject), reference.Value)) { Fsm.Event(failureEvent); Finish(); } _keys = new ArrayList(proxy.hashTable.Keys); if (startIndex.Value > 0) { nextItemIndex = startIndex.Value; } } DoGetNextItem(); Finish(); }
public override void OnEnter() { if (SetUpHashTableProxyPointer(Fsm.GetOwnerDefaultTarget(gameObject), reference.Value)) { if (keyExistsAlreadyEvent != null) { foreach (FsmString _key in keys) { if (proxy.hashTable.ContainsKey(_key.Value)) { Fsm.Event(keyExistsAlreadyEvent); Finish(); } } } AddToHashTable(); Fsm.Event(successEvent); } Finish(); }
private void PlayVideoFinished(ePlayVideoFinishReason _finishReason) { switch (_finishReason) { case ePlayVideoFinishReason.PLAYBACK_ENDED: Fsm.Event(playbackEndedEvent); break; case ePlayVideoFinishReason.PLAYBACK_ERROR: Fsm.Event(playbackErrorEvent); break; case ePlayVideoFinishReason.USER_EXITED: Fsm.Event(userExitedEvent); break; default: Log("[MediaLibrary] Unhandled reason."); break; } Finish(); }
private void SetAttributes() { XmlNode _node = DataMakerXmlUtils.XmlRetrieveNode(xmlReference.Value); if (_node == null) { Debug.LogWarning("XMl reference is empty, or likely invalid"); Fsm.Event(errorEvent); return; } int att_i = 0; foreach (FsmString att in attributes) { SetNodeProperty(_node, att.Value, attributesValues[att_i].Value); att_i++; } // Debug.Log(_node.OwnerDocument.OuterXml); Finish(); }
void Execute() { if (!UpdateCache(Fsm.GetOwnerDefaultTarget(gameObject))) { return; } if (!size.IsNone) { size.Value = this.cachedComponent.size; } if (!sizeX.IsNone) { sizeX.Value = this.cachedComponent.size.x; } if (!sizeY.IsNone) { sizeY.Value = this.cachedComponent.size.y; } }
public override void OnEnter() { bool isSucces = SteamUserStats.SetStat((string)statAPIname.Value, (float)floatData.Value); if (isSucces) { bool storeStats = SteamUserStats.StoreStats(); if (storeStats) { Fsm.Event(success); } else { Fsm.Event(failed); } } else { Fsm.Event(failed); } Finish(); }
private void DoAction() { #if USES_WEBVIEW GameObject _webViewGO = Fsm.GetOwnerDefaultTarget(gameObject); if (_webViewGO == null) { LogWarning(string.Format("[WebView] Game object is null.")); return; } WebView _webView = _webViewGO.GetComponent <WebView>(); if (_webView == null) { LogWarning(string.Format("[WebView] WebView component not found in game object: {0}.", _webViewGO.name)); return; } // Update webview property value _webView.ShowSpinnerOnLoad = showSpinnerOnLoad; #endif }
void Dialog_Completed(ConsentDialog dialog, ConsentDialog.CompletedResults results) { buttonId.Value = results.buttonId; if (results.toggleValues != null) { toggleCount.Value = results.toggleValues.Count; toggleIDs.stringValues = new string[toggleCount.Value]; toggleValues.boolValues = new bool[toggleCount.Value]; int i = 0; foreach (KeyValuePair <string, bool> pair in results.toggleValues) { toggleIDs.stringValues[i] = pair.Key; toggleValues.boolValues[i] = pair.Value; i++; } } Fsm.Event(eventTarget, completedEvent); Finish(); }
private void DoAddHudText() { // exit if objects are null if ((HudTextObject == null) || (TextColor == null) || (StayDuration == null) || (HudString == null)) { return; } // get the hud text component HUDText hudt = Fsm.GetOwnerDefaultTarget(HudTextObject).GetComponent <HUDText>(); // fail if component is not attached if (hudt == null) { string msg = string.Format("HUDText is not attached to object: {0}", Fsm.GetOwnerDefaultTarget(HudTextObject).name); UnityEngine.Debug.LogError(msg); FsmDebugUtility.Log(msg); return; } // add the hud text hudt.Add(HudString.Value, TextColor.Value, StayDuration.Value); }
void doGetNetworkDisconnectionInfo() { NetworkDisconnection _networkDisconnectionInfo = Fsm.EventData.DisconnectionInfo; disconnectionLabel.Value = _networkDisconnectionInfo.ToString(); switch (_networkDisconnectionInfo) { case NetworkDisconnection.Disconnected: if (disConnectedEvent != null) { Fsm.Event(disConnectedEvent); } break; case NetworkDisconnection.LostConnection: if (lostConnectionEvent != null) { Fsm.Event(lostConnectionEvent); } break; } }
void InitFsmVar() { var go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { return; } if (go != cachedGO) { sourceFsm = ActionHelpers.GetGameObjectFsm(go, fsmName.Value); sourceVariable = sourceFsm.FsmVariables.GetVariable(storeValue.variableName); targetVariable = Fsm.Variables.GetVariable(storeValue.variableName); storeValue.Type = targetVariable.VariableType; if (!string.IsNullOrEmpty(storeValue.variableName) && sourceVariable == null) { LogWarning("Missing Variable: " + storeValue.variableName); } cachedGO = go; } }
public override void OnEnter() { // get the animator component var go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { Finish(); return; } _animator = go.GetComponent <Animator>(); if (_animator == null) { Finish(); return; } DoFeetPivotActive(); Finish(); }
void GetAvatar(int iImage) { uint ImageWidth, ImageHeight; bool success = SteamUtils.GetImageSize(iImage, out ImageWidth, out ImageHeight); if (!success) { Fsm.Event(noAvatar); } else { byte[] Image = new byte[ImageWidth * ImageHeight * 4]; success = SteamUtils.GetImageRGBA(iImage, Image, (int)(ImageWidth * ImageHeight * 4)); if (success) { Texture2D ret = null; ret = new Texture2D((int)ImageWidth, (int)ImageHeight, TextureFormat.RGBA32, false, true); ret.LoadRawTextureData(Image); ret.Apply(); avatar.Value = ret; } } }
public override void OnEnter() { string check = ErrorCheck(); if (check != null) { Debug.LogError(check); return; } GameObject chart = Fsm.GetOwnerDefaultTarget(ChartObject); var pie = chart.GetComponent <PieChart>(); if (pie.DataSource.HasCategory(CategoryName.Value)) { pie.DataSource.SetMaterial(CategoryName.Value, new ChartDynamicMaterial(Material.Value, HoverColor.Value, ClickColor.Value)); pie.DataSource.SetCateogryParams(CategoryName.Value, RadiusScale.Value, DepthScale.Value, DepthOffset.Value); } else { pie.DataSource.AddCategory(CategoryName.Value, new ChartDynamicMaterial(Material.Value, HoverColor.Value, ClickColor.Value), RadiusScale.Value, DepthScale.Value, DepthOffset.Value); } Finish(); }
public override void OnEnter() { bool ok = false; try { ok = loadAllResource(); }catch (UnityException e) { Debug.LogWarning(e.Message); } if (ok) { Fsm.Event(successEvent); } else { Fsm.Event(failureEvent); } Finish(); }
void DoGetCsvHeader() { CsvData _data = CsvData.GetReference(reference.Value); if (_data == null) { Fsm.Event(errorEvent); header.Resize(0); return; } if (!_data.HasHeader) { LogError("Csv Data '" + reference.Value + "' has no header"); Fsm.Event(errorEvent); header.Resize(0); return; } header.stringValues = _data.HeaderKeys.ToArray(); header.SaveChanges(); }
void DoiTween() { if (iTweenType == iTweenFSMType.all) { iTween.Pause(); } else { if (inScene) { iTween.Pause(System.Enum.GetName(typeof(iTweenFSMType), iTweenType)); } else { GameObject go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { return; } iTween.Pause(go, System.Enum.GetName(typeof(iTweenFSMType), iTweenType), includeChildren); } } }
void TounchInput() { if (Input.touchCount == 1) { var touch = Input.GetTouch(0); if (touch.position.x < Screen.width / 2) { if (touch.phase == touchPhase) { storeFingerId.Value = touch.fingerId; Fsm.Event(sendEventLeft); } } else if (touch.position.x > Screen.width / 2) { if (touch.phase == touchPhase) { storeFingerId.Value = touch.fingerId; Fsm.Event(sendEventRight); } } } }
public override void OnEnter() { int batteryLife = (int)SteamUtils.GetCurrentBatteryPower(); bool isAC = (batteryLife == 255) ? true : false; if (batteryPercentage != null) { batteryPercentage.Value = batteryLife; } if (acPowerUsed != null) { acPowerUsed.Value = isAC; } if (isAC) { Fsm.Event(acPowered); } else { Fsm.Event(batteryPowered); } Finish(); }
public override string ErrorCheck() { GameObject checkObject = Fsm.GetOwnerDefaultTarget(ChartObject); if (ChartObject == null || checkObject == null) { return("Chart object cannot be null"); } if (checkObject.GetComponent <BarChart>() == null) { return("Object must be a either a CanvasBarChart chart or a WorldSpaceBarChart chart"); } if (CategoryName.Value == "" || CategoryName.Value == null) { return("Category name cannot be null or empty"); } if (Material.Value == null) { return("Material cannot be null"); } return(null); }
private Collider2D[] GetOverlapCircleAll() { var fromGo = Fsm.GetOwnerDefaultTarget(fromGameObject); var fromPos = fromPosition.Value; if (fromGo != null) { fromPos.x += fromGo.transform.position.x; fromPos.y += fromGo.transform.position.y; } if (minDepth.IsNone && maxDepth.IsNone) { return(Physics2D.OverlapCircleAll(fromPos, radius.Value, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value))); } var _minDepth = minDepth.IsNone? Mathf.NegativeInfinity:minDepth.Value; var _maxDepth = maxDepth.IsNone? Mathf.Infinity:maxDepth.Value; return(Physics2D.OverlapCircleAll(fromPos, radius.Value, ActionHelpers.LayerArrayToLayerMask(layerMask, invertMask.Value), _minDepth, _maxDepth)); }
void doCheck() { if (!UpdateCache(Fsm.GetOwnerDefaultTarget(gameObject))) { return; } var isDetected = sensor.IsDetected(checkGameObject.Value); if (!storeResult.IsNone) { storeResult.Value = isDetected; } if (isDetected) { Fsm.Event(detectedEvent); } else { Fsm.Event(notDetectedEvent); } }
public override void OnGUI() { bool buttonPressed; if (string.IsNullOrEmpty(style.Value)) { buttonPressed = GUILayout.Button(new GUIContent(text.Value, image.Value, tooltip.Value), LayoutOptions); } else { buttonPressed = GUILayout.Button(new GUIContent(text.Value, image.Value, tooltip.Value), style.Value, LayoutOptions); } if (buttonPressed) { Fsm.Event(sendEvent); } if (storeButtonState != null) { storeButtonState.Value = buttonPressed; } }
void DoTouchGUIEvent() { if (Input.touchCount > 0) { var go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { return; } guiElement = go.GetComponent <GUITexture>() ?? (GUIElement)go.GetComponent <GUIText>(); if (guiElement == null) { return; } foreach (var touch in Input.touches) { DoTouch(touch); } } }
public override void OnUpdate() { if (wwwObject == null || !string.IsNullOrEmpty(wwwObject.error)) { errorString.Value = "WWW Object is Null!"; Finish(); Fsm.Event(isError); return; } progress.Value = wwwObject.progress; if (progress.Value.Equals(1f)) { errorString.Value = wwwObject.error; jsonSearchResult.Value = wwwObject.text; Fsm.Event(string.IsNullOrEmpty(errorString.Value) ? isDone : isError); Finish(); } }
// Code that runs on entering the state. public override void OnEnter() { // get the animator component var go = Fsm.GetOwnerDefaultTarget(gameObject); if (go == null) { Finish(); return; } _animator = go.GetComponent <Animator>(); if (_animator == null) { Finish(); return; } GetApplyMotionRoot(); Finish(); }
public static object GetParseValueFromFsmVar(Fsm fsm,FsmVar fsmVar) { PlayMakerUtils.RefreshValueFromFsmVar(fsm,fsmVar); if (fsmVar.Type == VariableType.Bool) { return fsmVar.boolValue; }else if (fsmVar.Type == VariableType.Float) { return fsmVar.floatValue; }else if (fsmVar.Type == VariableType.Int) { return fsmVar.intValue; }else if (fsmVar.Type == VariableType.String) { return fsmVar.stringValue; }else if (fsmVar.Type == VariableType.Color) { return PlayMakerUtils.ParseValueToString(fsmVar.colorValue); }else if (fsmVar.Type == VariableType.GameObject) { return PlayMakerUtils.ParseValueToString(fsmVar.gameObjectValue); }else if (fsmVar.Type == VariableType.Material) { return PlayMakerUtils.ParseValueToString(fsmVar.materialValue); }else if (fsmVar.Type == VariableType.Quaternion) { return PlayMakerUtils.ParseValueToString(fsmVar.quaternionValue); }else if (fsmVar.Type == VariableType.Rect) { return PlayMakerUtils.ParseValueToString(fsmVar.rectValue); }else if (fsmVar.Type == VariableType.Texture) { return PlayMakerUtils.ParseValueToString(fsmVar.textureValue); }else if (fsmVar.Type == VariableType.Vector2) { return PlayMakerUtils.ParseValueToString(fsmVar.vector2Value); } else if (fsmVar.Type == VariableType.Vector3) { return PlayMakerUtils.ParseValueToString(fsmVar.vector3Value); } return false; }
public static bool SetParsePropertyFromFsmVar(ParseObject _object,string property,Fsm fsm,FsmVar fsmVar) { if (_object==null ) { Debug.Log("Parse Object null"); return false; } if (string.IsNullOrEmpty(property) ) { Debug.Log("property null"); return false; } if (! _object.ContainsKey(property)) { // return false; } PlayMakerUtils.RefreshValueFromFsmVar(fsm,fsmVar); if (fsmVar.Type == VariableType.Bool) { _object[property] = fsmVar.boolValue; }else if (fsmVar.Type == VariableType.Float) { _object[property] = fsmVar.floatValue; }else if (fsmVar.Type == VariableType.Int) { _object[property] = fsmVar.intValue; }else if (fsmVar.Type == VariableType.String) { _object[property] = fsmVar.stringValue; }else if (fsmVar.Type == VariableType.Color) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.colorValue); }else if (fsmVar.Type == VariableType.GameObject) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.gameObjectValue); }else if (fsmVar.Type == VariableType.Material) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.materialValue); }else if (fsmVar.Type == VariableType.Quaternion) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.quaternionValue); }else if (fsmVar.Type == VariableType.Rect) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.rectValue); }else if (fsmVar.Type == VariableType.Texture) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.textureValue); }else if (fsmVar.Type == VariableType.Vector2) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.vector2Value); } else if (fsmVar.Type == VariableType.Vector3) { _object[property] = PlayMakerUtils.ParseValueToString(fsmVar.vector3Value); } return true; }
public static bool EditFsmPropertiesStorage(Fsm fsm,FsmXmlPropertiesStorage target) { FsmEditorGUILayout.LightDivider(); bool edited = false; int count = 0; if (target !=null && target.properties !=null && target.propertiesVariables !=null) { count = target.properties.Length; for(int i=0;i<count;i++) { GUILayout.BeginHorizontal(); GUILayout.Label("Property item "+i); GUILayout.FlexibleSpace(); if (FsmEditorGUILayout.DeleteButton()) { ArrayUtility.RemoveAt(ref target.properties,i); ArrayUtility.RemoveAt(ref target.propertiesVariables,i); return true; // we must not continue, an entry is going to be deleted so the loop is broken here. next OnGui, all will be well. } GUILayout.EndHorizontal(); target.properties[i] = VariableEditor.FsmStringField(new GUIContent("Property"),fsm,target.properties[i],null); //target.propertiesVariables[i] = VariableEditor.FsmVarPopup(new GUIContent("Value"),fsm,target.propertiesVariables[i]); bool fsmVariableChangedFlag =false; target.propertiesVariables[i] = PlayMakerInspectorUtils.EditorGUILayout_FsmVarPopup("Value",fsm.Variables.GetAllNamedVariables(),target.propertiesVariables[i],out fsmVariableChangedFlag); } } string _addButtonLabel = "Get a Property"; if (count>0) { _addButtonLabel = "Get another Property"; } GUILayout.BeginHorizontal(); GUILayout.Space(154); if ( GUILayout.Button(_addButtonLabel) ) { if (target.properties==null) { target.properties = new FsmString[0]; target.propertiesVariables = new FsmVar[0]; } ArrayUtility.Add<FsmString>(ref target.properties, new FsmString()); ArrayUtility.Add<FsmVar>(ref target.propertiesVariables,new FsmVar()); edited = true; } GUILayout.Space(21); GUILayout.EndHorizontal(); return edited || GUI.changed; }
public static bool GetParsePropertyToFsmVar(ParseObject _object,string property,Fsm fsm,FsmVar fsmVar) { if (_object==null || string.IsNullOrEmpty(property) ) { return false; } if (! _object.ContainsKey(property)) { return false; } if (fsmVar.Type == VariableType.Bool) { PlayMakerUtils.ApplyValueToFsmVar(fsm,fsmVar,_object[property]); }else if (fsmVar.Type == VariableType.Float) { PlayMakerUtils.ApplyValueToFsmVar(fsm,fsmVar,_object[property]); }else if (fsmVar.Type == VariableType.Int) { PlayMakerUtils.ApplyValueToFsmVar(fsm,fsmVar,_object[property]); }else if (fsmVar.Type == VariableType.String) { PlayMakerUtils.ApplyValueToFsmVar(fsm,fsmVar,_object[property]); }else if (fsmVar.Type == VariableType.Color) { fsmVar.colorValue = (Color) PlayMakerUtils.ParseValueFromString( (string)_object[property] ); }else if (fsmVar.Type == VariableType.GameObject) { fsmVar.gameObjectValue = (GameObject) PlayMakerUtils.ParseValueFromString( (string)_object[property] ); }else if (fsmVar.Type == VariableType.Material) { fsmVar.materialValue = (Material)PlayMakerUtils.ParseValueFromString( (string)_object[property] ); }else if (fsmVar.Type == VariableType.Quaternion) { fsmVar.quaternionValue = (Quaternion)PlayMakerUtils.ParseValueFromString( (string)_object[property] ); }else if (fsmVar.Type == VariableType.Rect) { fsmVar.rectValue = (Rect)PlayMakerUtils.ParseValueFromString( (string)_object[property] ); }else if (fsmVar.Type == VariableType.Texture) { fsmVar.textureValue = (Texture2D)PlayMakerUtils.ParseValueFromString( (string)_object[property] ); }else if (fsmVar.Type == VariableType.Vector2) { fsmVar.vector2Value = (Vector2)PlayMakerUtils.ParseValueFromString( (string)_object[property] ); }else if (fsmVar.Type == VariableType.Vector3) { fsmVar.vector3Value = (Vector3)PlayMakerUtils.ParseValueFromString( (string)_object[property] ); } return true; }
public override void Reset() { fsmTemplateControl = new FsmTemplateControl(); storeID = null; runFsm = null; }
public static bool EditFsmXmlPropertiesTypes(Fsm fsm,FsmXmlPropertiesTypes target) { FsmEditorGUILayout.LightDivider(); bool edited = false; int count = 0; if (target.properties !=null && target.propertiesTypes !=null) { count = target.properties.Length; for(int i=0;i<count;i++) { GUILayout.BeginHorizontal(); GUILayout.Label("Property item "+i); GUILayout.FlexibleSpace(); if (FsmEditorGUILayout.DeleteButton()) { ArrayUtility.RemoveAt(ref target.properties,i); ArrayUtility.RemoveAt(ref target.propertiesTypes,i); return true; // we must not continue, an entry is going to be deleted so the loop is broken here. next OnGui, all will be well. } GUILayout.EndHorizontal(); target.properties[i] = VariableEditor.FsmStringField(new GUIContent("Property"),fsm,target.properties[i],null); target.propertiesTypes[i] = (VariableType)EditorGUILayout.EnumPopup(new GUIContent("Type"),target.propertiesTypes[i]); } } string _addButtonLabel = "Define a Property"; if (count>0) { _addButtonLabel = "Define another Property"; } GUILayout.BeginHorizontal(); GUILayout.Space(154); if ( GUILayout.Button(_addButtonLabel) ) { if (target.properties==null) { target.properties = new FsmString[0]; target.propertiesTypes = new VariableType[0]; } ArrayUtility.Add<FsmString>(ref target.properties, new FsmString()); ArrayUtility.Add<VariableType>(ref target.propertiesTypes,VariableType.Float); edited = true; } GUILayout.Space(21); GUILayout.EndHorizontal(); return edited || GUI.changed; }
public static object GetValueFromFsmVar(Fsm fromFsm, FsmVar fsmVar) { if (fsmVar.useVariable) { string _name = fsmVar.variableName; switch (fsmVar.Type) { case VariableType.Int: return fromFsm.Variables.GetFsmInt(_name).Value; case VariableType.Float: return fromFsm.Variables.GetFsmFloat(_name).Value; case VariableType.Bool: return fromFsm.Variables.GetFsmBool(_name).Value; case VariableType.Color: return fromFsm.Variables.GetFsmColor(_name).Value; case VariableType.Quaternion: return fromFsm.Variables.GetFsmQuaternion(_name).Value; case VariableType.Rect: return fromFsm.Variables.GetFsmRect(_name).Value; case VariableType.Vector2: return fromFsm.Variables.GetFsmVector2(_name).Value; case VariableType.Vector3: return fromFsm.Variables.GetFsmVector3(_name).Value; case VariableType.Texture: return fromFsm.Variables.GetFsmTexture(_name).Value; case VariableType.Material: return fromFsm.Variables.GetFsmMaterial(_name).Value; case VariableType.String: return fromFsm.Variables.GetFsmString(_name).Value; case VariableType.GameObject: return fromFsm.Variables.GetFsmGameObject(_name).Value; case VariableType.Object: return fromFsm.Variables.GetFsmObject(_name).Value; } } else { switch (fsmVar.Type) { case VariableType.Int: return fsmVar.intValue; case VariableType.Float: return fsmVar.floatValue; case VariableType.Bool: return fsmVar.boolValue; case VariableType.Color: return fsmVar.colorValue; case VariableType.Quaternion: return fsmVar.quaternionValue; case VariableType.Rect: return fsmVar.rectValue; case VariableType.Vector2: return fsmVar.vector2Value; case VariableType.Vector3: return fsmVar.vector3Value; case VariableType.Texture: return fsmVar.textureValue; case VariableType.Material: return fsmVar.materialValue; case VariableType.String: return fsmVar.stringValue; case VariableType.GameObject: return fsmVar.gameObjectValue; case VariableType.Object: return fsmVar.objectReference; } } return null; }
public FsmAdapter(Fsm target) { _target = target; }
public static bool ApplyValueToFsmVar(Fsm fromFsm, FsmVar fsmVar, object value) { System.Type valueType = value.GetType(); //Debug.Log("valueType "+valueType); System.Type storageType = null; //Debug.Log("fsmVar type "+fsmVar.Type); switch (fsmVar.Type) { case VariableType.Int: storageType = typeof(int); break; case VariableType.Float: storageType = typeof(float); break; case VariableType.Bool: storageType = typeof(bool); break; case VariableType.Color: storageType = typeof(Color); break; case VariableType.GameObject: storageType = typeof(GameObject); break; case VariableType.Quaternion: storageType = typeof(Quaternion); break; case VariableType.Rect: storageType = typeof(Rect); break; case VariableType.String: storageType = typeof(string); break; case VariableType.Texture: storageType = typeof(Texture2D); break; case VariableType.Vector2: storageType = typeof(Vector2); break; case VariableType.Vector3: storageType = typeof(Vector3); break; case VariableType.Object: storageType = typeof(Object); break; case VariableType.Material: storageType = typeof(Material); break; } if (!storageType.Equals(valueType)) { if (valueType.Equals(typeof(ProceduralMaterial))) { // we are still ok. } else { Debug.LogError("The fsmVar value <" + storageType + "> doesn't match the value <" + valueType + ">"); return false; } } if (valueType == typeof(bool)) { FsmBool _target = fromFsm.Variables.GetFsmBool(fsmVar.variableName); _target.Value = (bool)value; } else if (valueType == typeof(Color)) { FsmColor _target = fromFsm.Variables.GetFsmColor(fsmVar.variableName); _target.Value = (Color)value; } else if (valueType == typeof(int)) { FsmInt _target = fromFsm.Variables.GetFsmInt(fsmVar.variableName); _target.Value = (int)value; } else if (valueType == typeof(float)) { FsmFloat _target = fromFsm.Variables.GetFsmFloat(fsmVar.variableName); _target.Value = (float)value; } else if (valueType == typeof(GameObject)) { FsmGameObject _target = fromFsm.Variables.GetFsmGameObject(fsmVar.variableName); _target.Value = (GameObject)value; } else if (valueType == typeof(Material)) { FsmMaterial _target = fromFsm.Variables.GetFsmMaterial(fsmVar.variableName); _target.Value = (Material)value; } else if (valueType == typeof(ProceduralMaterial)) { FsmMaterial _target = fromFsm.Variables.GetFsmMaterial(fsmVar.variableName); _target.Value = (ProceduralMaterial)value; } else if (valueType == typeof(Object)) { FsmObject _target = fromFsm.Variables.GetFsmObject(fsmVar.variableName); _target.Value = (Object)value; } else if (valueType == typeof(Quaternion)) { FsmQuaternion _target = fromFsm.Variables.GetFsmQuaternion(fsmVar.variableName); _target.Value = (Quaternion)value; } else if (valueType == typeof(Rect)) { FsmRect _target = fromFsm.Variables.GetFsmRect(fsmVar.variableName); _target.Value = (Rect)value; } else if (valueType == typeof(string)) { FsmString _target = fromFsm.Variables.GetFsmString(fsmVar.variableName); _target.Value = (string)value; } else if (valueType == typeof(Texture2D)) { FsmTexture _target = fromFsm.Variables.GetFsmTexture(fsmVar.variableName); _target.Value = (Texture2D)value; } else if (valueType == typeof(Vector2)) { FsmVector2 _target = fromFsm.Variables.GetFsmVector2(fsmVar.variableName); _target.Value = (Vector2)value; } else if (valueType == typeof(Vector3)) { FsmVector3 _target = fromFsm.Variables.GetFsmVector3(fsmVar.variableName); _target.Value = (Vector3)value; } else { Debug.LogWarning("?!?!" + valueType); // don't know, should I put in FsmObject? } return true; }
public static string ParseFsmVarToString(Fsm fsm,FsmVar fsmVar) { if (fsmVar==null) { return ""; } object item = PlayMakerUtils.GetValueFromFsmVar(fsm,fsmVar); if (item==null) { return ""; } if(fsmVar.Type==VariableType.String) { return (string) item; } if(fsmVar.Type==VariableType.Bool) { return (bool)item?"1":"0"; } if(fsmVar.Type==VariableType.Float) { float _val= float.Parse(item.ToString()); return _val.ToString(); } if(fsmVar.Type==VariableType.Int) { int _val= int.Parse(item.ToString()); return _val.ToString(); } if(fsmVar.Type==VariableType.Vector2) { Vector2 _val= (Vector2)item; return _val.x+","+_val.y; } if(fsmVar.Type==VariableType.Vector3) { Vector3 _val= (Vector3)item; return _val.x+","+_val.y+","+_val.z; } if(fsmVar.Type==VariableType.Quaternion) { Quaternion _val= (Quaternion)item; return _val.x+","+_val.y+","+_val.z+","+_val.w; } if(fsmVar.Type==VariableType.Rect) { Rect _val= (Rect)item; return _val.x+","+_val.y+","+_val.width+","+_val.height; } if(fsmVar.Type==VariableType.Color) { Color _val= (Color)item; return _val.r+","+_val.g+","+_val.b+","+_val.a; } if(fsmVar.Type==VariableType.GameObject) { GameObject _val= (GameObject)item; //Debug.Log("GameObject "+_val.GetInstanceID().ToString()); //return "gameObject("+_val.GetInstanceID().ToString()+")"; return _val.name; } if(fsmVar.Type==VariableType.Material) { Material _val= (Material)item; //Debug.Log("GameObject "+_val.GetInstanceID().ToString()); //return "gameObject("+_val.GetInstanceID().ToString()+")"; return _val.name; } if(fsmVar.Type==VariableType.Texture) { Texture2D _val= (Texture2D)item; //Debug.Log("GameObject "+_val.GetInstanceID().ToString()); //return "gameObject("+_val.GetInstanceID().ToString()+")"; return _val.name; } Debug.LogWarning("ParseValueToString type not supported "+item.GetType()); return "<"+fsmVar.Type+"> not supported"; }
public static bool ApplyValueToFsmVar(Fsm fromFsm,FsmVar fsmVar, object value) { if (fromFsm==null) { return false; } if (fsmVar==null) { return false; } if (value==null) { if (fsmVar.Type == VariableType.Bool ){ FsmBool _target= fromFsm.Variables.GetFsmBool(fsmVar.variableName); _target.Value = false; }else if(fsmVar.Type == VariableType.Color ){ FsmColor _target= fromFsm.Variables.GetFsmColor(fsmVar.variableName); _target.Value = Color.black; }else if(fsmVar.Type == VariableType.Int ){ FsmInt _target= fromFsm.Variables.GetFsmInt(fsmVar.variableName); _target.Value = 0; }else if(fsmVar.Type == VariableType.Float ){ FsmFloat _target= fromFsm.Variables.GetFsmFloat(fsmVar.variableName); _target.Value = 0f; }else if(fsmVar.Type == VariableType.GameObject ){ FsmGameObject _target= fromFsm.Variables.GetFsmGameObject(fsmVar.variableName); _target.Value = null; }else if(fsmVar.Type == VariableType.Material ){ FsmMaterial _target= fromFsm.Variables.GetFsmMaterial(fsmVar.variableName); _target.Value = null; }else if(fsmVar.Type == VariableType.Object ){ FsmObject _target= fromFsm.Variables.GetFsmObject(fsmVar.variableName); _target.Value = null; }else if(fsmVar.Type == VariableType.Quaternion ){ FsmQuaternion _target= fromFsm.Variables.GetFsmQuaternion(fsmVar.variableName); _target.Value = Quaternion.identity; }else if(fsmVar.Type == VariableType.Rect ){ FsmRect _target= fromFsm.Variables.GetFsmRect(fsmVar.variableName); _target.Value = new Rect(0,0,0,0); }else if(fsmVar.Type == VariableType.String ){ FsmString _target= fromFsm.Variables.GetFsmString(fsmVar.variableName); _target.Value = ""; }else if(fsmVar.Type == VariableType.String ){ FsmTexture _target= fromFsm.Variables.GetFsmTexture(fsmVar.variableName); _target.Value = null; }else if(fsmVar.Type == VariableType.Vector2 ){ FsmVector2 _target= fromFsm.Variables.GetFsmVector2(fsmVar.variableName); _target.Value = Vector2.zero; }else if(fsmVar.Type == VariableType.Vector3 ){ FsmVector3 _target= fromFsm.Variables.GetFsmVector3(fsmVar.variableName); _target.Value = Vector3.zero; } #if PLAYMAKER_1_8 else if(fsmVar.Type == VariableType.Enum ){ FsmEnum _target= fromFsm.Variables.GetFsmEnum(fsmVar.variableName); _target.ResetValue(); }else if(fsmVar.Type == VariableType.Array ){ FsmArray _target= fromFsm.Variables.GetFsmArray(fsmVar.variableName); _target.Reset(); } #endif return true; } System.Type valueType = value.GetType(); //Debug.Log("valueType "+valueType); System.Type storageType = null; // Debug.Log("fsmVar type "+fsmVar.Type); switch (fsmVar.Type) { case VariableType.Int: storageType = typeof(int); break; case VariableType.Float: storageType = typeof(float); break; case VariableType.Bool: storageType = typeof(bool); break; case VariableType.Color: storageType = typeof(Color); break; case VariableType.GameObject: storageType = typeof(GameObject); break; case VariableType.Quaternion: storageType = typeof(Quaternion); break; case VariableType.Rect: storageType = typeof(Rect); break; case VariableType.String: storageType = typeof(string); break; case VariableType.Texture: storageType = typeof(Texture2D); break; case VariableType.Vector2: storageType = typeof(Vector2); break; case VariableType.Vector3: storageType = typeof(Vector3); break; case VariableType.Object: storageType = typeof(Object); break; case VariableType.Material: storageType = typeof(Material); break; #if PLAYMAKER_1_8 case VariableType.Enum: storageType = typeof(System.Enum); break; case VariableType.Array: storageType = typeof(System.Array); break; #endif } bool ok = true; if (! storageType.Equals(valueType)) { ok = false; if (storageType.Equals(typeof(Object))) // we are ok { ok = true; } #if PLAYMAKER_1_8 if (storageType.Equals(typeof(System.Enum))) // we are ok { ok = true; } #endif if (!ok) { #if UNITY_WEBGL // proceduralMaterial not supported #else if (valueType.Equals(typeof(ProceduralMaterial))) // we are ok { ok = true; } #endif if (valueType.Equals(typeof(double))) // we are ok { ok = true; } if (valueType.Equals(typeof(System.Int64))) // we are ok { ok = true; } if (valueType.Equals(typeof(System.Byte))) // we are ok { ok = true; } } } if (!ok) { Debug.LogError("The fsmVar value <"+storageType+"> doesn't match the value <"+valueType+"> on state"+fromFsm.ActiveStateName+" on fsm:"+fromFsm.Name+" on GameObject:"+fromFsm.GameObjectName); return false; } if (valueType == typeof(bool) ){ FsmBool _target= fromFsm.Variables.GetFsmBool(fsmVar.variableName); _target.Value = (bool)value; }else if(valueType == typeof(Color) ){ FsmColor _target= fromFsm.Variables.GetFsmColor(fsmVar.variableName); _target.Value = (Color)value; }else if(valueType == typeof(int)){ FsmInt _target= fromFsm.Variables.GetFsmInt(fsmVar.variableName); _target.Value = System.Convert.ToInt32(value); }else if(valueType == typeof(byte)){ FsmInt _target= fromFsm.Variables.GetFsmInt(fsmVar.variableName); _target.Value = System.Convert.ToInt32(value); }else if(valueType == typeof(System.Int64)){ if (fsmVar.Type == VariableType.Int) { FsmInt _target= fromFsm.Variables.GetFsmInt(fsmVar.variableName); _target.Value = System.Convert.ToInt32(value); }else if (fsmVar.Type == VariableType.Float) { FsmFloat _target= fromFsm.Variables.GetFsmFloat(fsmVar.variableName); _target.Value = System.Convert.ToSingle(value); } }else if(valueType == typeof(float) ){ FsmFloat _target= fromFsm.Variables.GetFsmFloat(fsmVar.variableName); _target.Value = (float)value; }else if(valueType == typeof(double) ){ FsmFloat _target= fromFsm.Variables.GetFsmFloat(fsmVar.variableName); _target.Value = System.Convert.ToSingle(value); }else if(valueType == typeof(GameObject) ){ FsmGameObject _target= fromFsm.Variables.GetFsmGameObject(fsmVar.variableName); _target.Value = (GameObject)value; }else if(valueType == typeof(Material) ){ FsmMaterial _target= fromFsm.Variables.GetFsmMaterial(fsmVar.variableName); _target.Value = (Material)value; #if UNITY_WEBGL // proceduralMaterial not supported #else }else if(valueType == typeof(ProceduralMaterial) ){ FsmMaterial _target= fromFsm.Variables.GetFsmMaterial(fsmVar.variableName); _target.Value = (ProceduralMaterial)value; #endif }else if(valueType == typeof(Object) || storageType == typeof(Object) ){ FsmObject _target= fromFsm.Variables.GetFsmObject(fsmVar.variableName); _target.Value = (Object)value; }else if(valueType == typeof(Quaternion) ){ FsmQuaternion _target= fromFsm.Variables.GetFsmQuaternion(fsmVar.variableName); _target.Value = (Quaternion)value; }else if(valueType == typeof(Rect) ){ FsmRect _target= fromFsm.Variables.GetFsmRect(fsmVar.variableName); _target.Value = (Rect)value; }else if(valueType == typeof(string) ){ FsmString _target= fromFsm.Variables.GetFsmString(fsmVar.variableName); _target.Value = (string)value; }else if(valueType == typeof(Texture2D) ){ FsmTexture _target= fromFsm.Variables.GetFsmTexture(fsmVar.variableName); _target.Value = (Texture2D)value; }else if(valueType == typeof(Vector2) ){ FsmVector2 _target= fromFsm.Variables.GetFsmVector2(fsmVar.variableName); _target.Value = (Vector2)value; }else if(valueType == typeof(Vector3) ){ FsmVector3 _target= fromFsm.Variables.GetFsmVector3(fsmVar.variableName); _target.Value = (Vector3)value; #if PLAYMAKER_1_8 }else if(valueType.BaseType == typeof(System.Enum) ){ FsmEnum _target= fromFsm.Variables.GetFsmEnum(fsmVar.variableName); _target.Value = (System.Enum)value; #endif }else{ Debug.LogWarning("?!?!"+valueType); // don't know, should I put in FsmObject? } return true; }
public static bool ApplyValueToFsmVar(Fsm fromFsm,FsmVar fsmVar, object[] value) { if (fromFsm==null) { return false; } if (fsmVar==null) { return false; } FsmArray _target; if (value==null || value.Length == 0) { if(fsmVar.Type == VariableType.Array ){ _target= fromFsm.Variables.GetFsmArray(fsmVar.variableName); _target.Reset(); } return true; } if (fsmVar.Type != VariableType.Array) { Debug.LogError("The fsmVar value <"+fsmVar.Type+"> doesn't match the value <FsmArray> on state"+fromFsm.ActiveStateName+" on fsm:"+fromFsm.Name+" on GameObject:"+fromFsm.GameObjectName); return false; } _target= fromFsm.Variables.GetFsmArray(fsmVar.variableName); _target.Values = value; return true; }
public static bool EditFsmXpathQueryVariablesProperties(Fsm fsm,FsmXpathQuery target) { if (target==null) { target = new FsmXpathQuery(); } bool edited = false; int count = 0; if (target.xPathVariables !=null) { count = target.xPathVariables.Length; for(int i=0;i<count;i++) { GUILayout.BeginHorizontal(); bool fsmVariableChangedFlag; target.xPathVariables[i] = PlayMakerInspectorUtils.EditorGUILayout_FsmVarPopup("Variable _"+i+"_",fsm.Variables.GetAllNamedVariables(),target.xPathVariables[i],out fsmVariableChangedFlag); // PlayMaker api is now not working on 1.8 and shoudl become private //target.xPathVariables[i] = VariableEditor.FsmVarPopup(new GUIContent("Variable _"+i+"_"),fsm,target.xPathVariables[i]); edited = edited || fsmVariableChangedFlag; if (i+1==count) { if (FsmEditorGUILayout.DeleteButton()) { ArrayUtility.RemoveAt(ref target.xPathVariables,i); return true; // we must not continue, an entry is going to be deleted so the loop is broken here. next OnGui, all will be well. } }else{ GUILayout.Space(21); } GUILayout.EndHorizontal(); } } string _addButtonLabel = "Add a variable"; if (count>0) { _addButtonLabel = "Add another variable"; } GUILayout.BeginHorizontal(); GUILayout.Space(154); if ( GUILayout.Button(_addButtonLabel) ) { if (target.xPathVariables==null) { target.xPathVariables = new FsmVar[0]; } ArrayUtility.Add<FsmVar>(ref target.xPathVariables, new FsmVar()); edited = true; } GUILayout.Space(21); GUILayout.EndHorizontal(); return edited || GUI.changed; }