public override void AddTo(FsmVariables variables) { FsmColor v = new FsmColor(name); variables.ColorVariables = variables.ColorVariables.Concat( new FsmColor[] { v }).ToArray(); }
/// <summary> /// A template can change since it was selected. /// This method refreshes the UI to reflect any changes /// while keeping any variable overrides that the use has made /// </summary> void RefreshTemplate() { if (fsmTemplate == null || Application.isPlaying) { return; } // we want to keep the existing overrides // so we copy the current FsmVariables var currentValues = new FsmVariables(fsmComponent.Fsm.Variables); // then we update the template fsmComponent.SetFsmTemplate(fsmTemplate); // finally we apply the original overrides back to the new FsmVariables fsmComponent.Fsm.Variables.OverrideVariableValues(currentValues); // and refresh the UI BuildFsmVariableList(); FsmEditor.RefreshInspector(); }
public bool GetVariable(PlayMakerFsmVariableTarget variableTarget) { initialized = true; targetUndefined = true; if (variableTarget.FsmVariables != null) { targetUndefined = false; variableNameToUse = string.IsNullOrEmpty(variableName)?defaultVariableName:variableName; fsmVariables = variableTarget.FsmVariables; _namedVariable = fsmVariables.GetVariable(variableNameToUse); if (_namedVariable != null) { #if PLAYMAKER_1_8 selectedType = _namedVariable.VariableType; #else selectedType = GetTypeFromChoice(variableSelectionChoice); #endif return(true); } } selectedType = VariableType.Unknown; return(false); }
public override void AddTo(FsmVariables variables) { FsmMaterial v = new FsmMaterial(name); variables.MaterialVariables = variables.MaterialVariables.Concat( new FsmMaterial[] { v }).ToArray(); }
protected override void InitGDE() { FsmVariables vars = PlayMakerGlobals.Instance.Variables; if (isGDEInitialized == null) { isGDEInitialized = vars.GetVariable("gde_initialized") as FsmBool; } if (isGDEInitialized != null && isGDEInitialized.Value == true) { single_bool = vars.GetVariable("single_bool") as FsmBool; single_custom_bool = vars.GetVariable("single_custom_bool") as FsmBool; single_float = vars.GetVariable("single_float") as FsmFloat; single_custom_float = vars.GetVariable("single_custom_float") as FsmFloat; single_int = vars.GetVariable("single_int") as FsmInt; single_custom_int = vars.GetVariable("single_custom_int") as FsmInt; single_string = vars.GetVariable("single_string") as FsmString; single_custom_string = vars.GetVariable("single_custom_string") as FsmString; single_custom = vars.GetVariable("single_custom") as FsmString; single_vec2 = vars.GetVariable("single_vector2") as FsmVector2; single_custom_vec2 = vars.GetVariable("single_custom_vector2") as FsmVector2; single_vec3 = vars.GetVariable("single_vector3") as FsmVector3; single_custom_vec3 = vars.GetVariable("single_custom_vector3") as FsmVector3; single_color = vars.GetVariable("single_color") as FsmColor; single_custom_color = vars.GetVariable("single_custom_color") as FsmColor; } }
public override void AddTo(FsmVariables variables) { FsmString v = new FsmString(name); variables.StringVariables = variables.StringVariables.Concat( new FsmString[] { v }).ToArray(); }
public override void AddTo(FsmVariables variables) { FsmTexture v = new FsmTexture(name); variables.TextureVariables = variables.TextureVariables.Concat( new FsmTexture[] { v }).ToArray(); }
public override void AddTo(FsmVariables variables) { FsmGameObject v = new FsmGameObject(name); variables.GameObjectVariables = variables.GameObjectVariables.Concat( new FsmGameObject[] { v }).ToArray(); }
public override void AddTo(FsmVariables variables) { FsmInt v = new FsmInt(name); variables.IntVariables = variables.IntVariables.Concat( new FsmInt[] { v }).ToArray(); }
public override void AddTo(FsmVariables variables) { FsmEnum v = new FsmEnum(name); variables.EnumVariables = variables.EnumVariables.Concat( new FsmEnum[] { v }).ToArray(); }
public override void AddTo(FsmVariables variables) { FsmQuaternion v = new FsmQuaternion(name); variables.QuaternionVariables = variables.QuaternionVariables.Concat( new FsmQuaternion[] { v }).ToArray(); }
public override void AddTo(FsmVariables variables) { FsmBool v = new FsmBool(name); variables.BoolVariables = variables.BoolVariables.Concat( new FsmBool[] { v }).ToArray(); }
public override void AddTo(FsmVariables variables) { FsmVector3 v = new FsmVector3(name); variables.Vector3Variables = variables.Vector3Variables.Concat( new FsmVector3[] { v }).ToArray(); }
void VerifyTemplateVariables() { var currentValues = new FsmVariables(fsmComponent.Fsm.Variables); CopyTemplateVariables(); fsmComponent.Fsm.Variables.OverrideVariableValues(currentValues); }
public static string GetAllRectFsmVariables(FsmVariables fsmVariables) { string text = ""; foreach (FsmRect fsmRect in fsmVariables.RectVariables) { text += "fsmRect name: " + fsmRect.Name + ":" + fsmRect.Value + "\n"; } return(text); }
public static string GetAllVector3FsmVariables(FsmVariables fsmVariables) { string text = ""; foreach (FsmVector3 fsmVector3 in fsmVariables.Vector3Variables) { text += "fsmVector3 name: " + fsmVector3.Name + ":" + fsmVector3.Value + "\n"; } return(text); }
public static string GetAllTextureFsmVariables(FsmVariables fsmVariables) { string text = ""; foreach (FsmTexture fsmTexture in fsmVariables.TextureVariables) { text += "fsmTexture name: " + fsmTexture.Name + ":" + fsmTexture.Value + "\n"; } return(text); }
public static string GetAllGameObjectFsmVariables(FsmVariables fsmVariables) { string text = ""; foreach (FsmGameObject fsmGameObject in fsmVariables.GameObjectVariables) { text += "fsmGameObject name: " + fsmGameObject.Name + ":" + GameObjectUtil.GetGameObjectPath(fsmGameObject.Value) + "\n"; } return(text); }
public static string GetAllFloatFsmVariables(FsmVariables fsmVariables) { string text = ""; foreach (FsmFloat fsmFloat in fsmVariables.FloatVariables) { text += "fsmFloat name: " + fsmFloat.Name + ":" + fsmFloat.Value + "\n"; } return(text); }
public static string GetAllColorFsmVariables(FsmVariables fsmVariables) { string text = ""; foreach (FsmColor fsmColor in fsmVariables.ColorVariables) { text += "fsmColor name: " + fsmColor.Name + ":" + fsmColor.Value + "\n"; } return(text); }
public static string GetAllBooleanFsmVariables(FsmVariables fsmVariables) { string text = ""; foreach (FsmBool fsmBool in fsmVariables.BoolVariables) { text += "fsmBool name: " + fsmBool.Name + ":" + fsmBool.Value + "\n"; } return(text); }
public static string GetAllFsmVariablesGlobalVariablesNames(FsmVariables fsmVariables) { string text = ""; foreach (NamedVariable namedVariable in fsmVariables.GetAllNamedVariables()) { text += "namedVariable name: " + namedVariable.Name + "\n"; } return(text); }
public static string GetAllStringFsmVariables(FsmVariables fsmVariables) { string text = ""; foreach (FsmString fsmString in fsmVariables.StringVariables) { text += "fsmString name: " + fsmString.Name + ":" + fsmString.Value + "\n"; } return(text); }
public static string GetAllVector2FsmVariables(FsmVariables fsmVariables) { string text = ""; foreach (FsmVector2 fsmVector2 in fsmVariables.Vector2Variables) { text += "fsmVector2 name: " + fsmVector2.Name + ":" + fsmVector2.Value + "\n"; } return(text); }
public static string GetAllMaterialFsmVariables(FsmVariables fsmVariables) { string text = ""; foreach (FsmMaterial fsmMaterial in fsmVariables.MaterialVariables) { text += "fsmMaterial name: " + fsmMaterial.Name + ":" + fsmMaterial.Value + "\n"; } return(text); }
public static string GetAllQuaternionFsmVariables(FsmVariables fsmVariables) { string text = ""; foreach (FsmQuaternion fsmQuaternion in fsmVariables.QuaternionVariables) { text += "fsmQuaternion name: " + fsmQuaternion.Name + ":" + fsmQuaternion.Value + "\n"; } return(text); }
public void Initialize(bool forceRefresh = false) { //Debug.Log("Initializing "+variableTarget+" _initialized:"+_initialized+" forceRefresh:"+forceRefresh); if (_initialized && !forceRefresh) { return; } _initialized = true; _fsmVariables = null; if (variableTarget == ProxyFsmVariableTarget.GlobalVariable) { _fsmVariables = PlayMaker.FsmVariables.GlobalVariables; // Debug.LogWarning("Setting FsmVariables for "+variableTarget); } else { if (variableTarget == ProxyFsmVariableTarget.FsmComponent) { if (_fsmComponent != null) { _fsmVariables = _fsmComponent.FsmVariables; Debug.LogWarning("Setting FsmVariables for " + variableTarget + " _fsmComponent= " + _fsmComponent); } return; } if (gameObject != null) { fsmComponent = PlayMakerUtils.FindFsmOnGameObject(gameObject, fsmName); } if (fsmComponent == null) { _fsmVariables = null; //Debug.LogError("Initialized with no FsmComponent found"); } else { _fsmVariables = _fsmComponent.FsmVariables; //Debug.LogWarning("Setting FsmVariables for "+variableTarget+" _fsmComponent= "+_fsmComponent); } } //Debug.Log("Initialized with fsmComponent<"+fsmComponent.FsmName+">"); }
void SelectFsmVariableGUI(FsmVariables fsmVariables) { NamedVariable[] _list = new NamedVariable[0]; if (_target.fsmVariableSetup.variableType == VariableType.Bool) { _list = fsmVariables.GetNames(typeof(FsmBool)); } else if (_target.fsmVariableSetup.variableType == VariableType.Int) { _list = fsmVariables.GetNames(typeof(FsmInt)); } else if (_target.fsmVariableSetup.variableType == VariableType.Float) { _list = fsmVariables.GetNames(typeof(FsmFloat)); } else if (_target.fsmVariableSetup.variableType == VariableType.Vector2) { _list = fsmVariables.GetNames(typeof(FsmVector2)); } else if (_target.fsmVariableSetup.variableType == VariableType.String) { _list = fsmVariables.GetNames(typeof(FsmString)); } _variableChoices = new string[_list.Length]; for (int i = 0; i < _list.Length; i++) { _variableChoices[i] = _list[i].Name; } if (_variableChoices.Length == 0) { ErrorFeedbackGui("No " + _target.fsmVariableSetup.variableType + " variable on Fsm"); } else { int _choiceIndex = EditorGUILayout.Popup(_target.fsmVariableSetup.variableType.ToString() + " Variable", _target.fsmVariableSetup.variableIndex, _variableChoices); if (_choiceIndex != _target.fsmVariableSetup.variableIndex || string.IsNullOrEmpty(_target.fsmVariableSetup.variableName)) { _target.fsmVariableSetup.variableIndex = _choiceIndex; _target.fsmVariableSetup.variableName = _variableChoices[_choiceIndex]; } } }
public static string GetAllFsmVariablesAndVaule(FsmVariables fsmVariables) { string text = ""; text += GetAllBooleanFsmVariables(fsmVariables) + "\n\n\n\n\n"; text += GetAllColorFsmVariables(fsmVariables) + "\n\n\n\n\n"; text += GetAllFloatFsmVariables(fsmVariables) + "\n\n\n\n\n"; text += GetAllGameObjectFsmVariables(fsmVariables) + "\n\n\n\n\n"; text += GetAllIntFsmVariables(fsmVariables) + "\n\n\n\n\n"; text += GetAllObjectFsmVariables(fsmVariables) + "\n\n\n\n\n"; text += GetAllQuaternionFsmVariables(fsmVariables) + "\n\n\n\n\n"; text += GetAllRectFsmVariables(fsmVariables) + "\n\n\n\n\n"; text += GetAllStringFsmVariables(fsmVariables) + "\n\n\n\n\n"; text += GetAllTextureFsmVariables(fsmVariables) + "\n\n\n\n\n"; text += GetAllVector2FsmVariables(fsmVariables) + "\n\n\n\n\n"; text += GetAllVector3FsmVariables(fsmVariables) + "\n\n\n\n\n"; return(text); }
void VerifyTemplateVariables() { var currentValues = new FsmVariables(fsmComponent.Fsm.Variables); CopyTemplateVariables(); fsmComponent.Fsm.Variables.OverrideVariableValues(currentValues); }
void SelectFsmVariableGUI(FsmVariables fsmVariables) { NamedVariable[] _list = new NamedVariable[0]; if (_target.fsmVariableSetup.variableType == VariableType.Bool) { _list = fsmVariables.GetNames(typeof(FsmBool)); }else if (_target.fsmVariableSetup.variableType == VariableType.Float) { _list = fsmVariables.GetNames(typeof(FsmFloat)); }else if (_target.fsmVariableSetup.variableType == VariableType.Vector2) { _list = fsmVariables.GetNames(typeof(FsmVector2)); }else if (_target.fsmVariableSetup.variableType == VariableType.String) { _list = fsmVariables.GetNames(typeof(FsmString)); } _variableChoices = new string[_list.Length]; for(int i=0;i<_list.Length;i++) { _variableChoices[i] = _list[i].Name; } if (_variableChoices.Length==0) { ErrorFeedbackGui("No "+_target.fsmVariableSetup.variableType+" variable on Fsm"); }else{ int _choiceIndex = EditorGUILayout.Popup(_target.fsmVariableSetup.variableType.ToString()+" Variable",_target.fsmVariableSetup.variableIndex,_variableChoices); if (_choiceIndex!=_target.fsmVariableSetup.variableIndex || string.IsNullOrEmpty(_target.fsmVariableSetup.variableName)) { _target.fsmVariableSetup.variableIndex =_choiceIndex; _target.fsmVariableSetup.variableName = _variableChoices[_choiceIndex]; } } }
/// <summary> /// A template can change since it was selected. /// This method refreshes the UI to reflect any changes /// while keeping any variable overrides that the use has made /// </summary> void RefreshTemplate() { if (fsmTemplate == null || Application.isPlaying) { return; } // we want to keep the existing overrides // so we copy the current FsmVariables var currentValues = new FsmVariables(fsmComponent.Fsm.Variables); // then we update the template fsmComponent.SetFsmTemplate(fsmTemplate); // finally we apply the original overrides back to the new FsmVariables fsmComponent.Fsm.Variables.OverrideVariableValues(currentValues); // and refresh the UI BuildFsmVariableList(); FsmEditor.RefreshInspector(); }
private static void NetworkSyncVariables(BitStream stream, FsmVariables variables) { FsmInt[] intVariables; FsmQuaternion[] quaternionVariables; FsmVector3[] vector3Variables; FsmColor[] colorVariables; FsmVector2[] vector2Variables; if (stream.isWriting) { FsmString[] stringVariables = variables.StringVariables; foreach (FsmString fsmString in stringVariables) { if (fsmString.NetworkSync) { char[] array = fsmString.Value.ToCharArray(); int value = array.Length; stream.Serialize(ref value); for (int j = 0; j < value; j++) { stream.Serialize(ref array[j]); } } } FsmBool[] boolVariables = variables.BoolVariables; foreach (FsmBool fsmBool in boolVariables) { if (fsmBool.NetworkSync) { bool value2 = fsmBool.Value; stream.Serialize(ref value2); } } FsmFloat[] floatVariables = variables.FloatVariables; foreach (FsmFloat fsmFloat in floatVariables) { if (fsmFloat.NetworkSync) { float value3 = fsmFloat.Value; stream.Serialize(ref value3); } } intVariables = variables.IntVariables; foreach (FsmInt fsmInt in intVariables) { if (fsmInt.NetworkSync) { int value4 = fsmInt.Value; stream.Serialize(ref value4); } } quaternionVariables = variables.QuaternionVariables; foreach (FsmQuaternion fsmQuaternion in quaternionVariables) { if (fsmQuaternion.NetworkSync) { Quaternion value5 = fsmQuaternion.Value; stream.Serialize(ref value5); } } vector3Variables = variables.Vector3Variables; foreach (FsmVector3 fsmVector in vector3Variables) { if (fsmVector.NetworkSync) { Vector3 value6 = fsmVector.Value; stream.Serialize(ref value6); } } colorVariables = variables.ColorVariables; foreach (FsmColor fsmColor in colorVariables) { if (fsmColor.NetworkSync) { Color value7 = fsmColor.Value; stream.Serialize(ref value7.r); stream.Serialize(ref value7.g); stream.Serialize(ref value7.b); stream.Serialize(ref value7.a); } } vector2Variables = variables.Vector2Variables; foreach (FsmVector2 fsmVector2 in vector2Variables) { if (fsmVector2.NetworkSync) { Vector2 value8 = fsmVector2.Value; stream.Serialize(ref value8.x); stream.Serialize(ref value8.y); } } return; } FsmString[] stringVariables2 = variables.StringVariables; foreach (FsmString fsmString2 in stringVariables2) { if (fsmString2.NetworkSync) { int value9 = 0; stream.Serialize(ref value9); char[] array2 = new char[value9]; for (int num5 = 0; num5 < value9; num5++) { stream.Serialize(ref array2[num5]); } fsmString2.Value = new string(array2); } } FsmBool[] boolVariables2 = variables.BoolVariables; foreach (FsmBool fsmBool2 in boolVariables2) { if (fsmBool2.NetworkSync) { bool value10 = false; stream.Serialize(ref value10); fsmBool2.Value = value10; } } FsmFloat[] floatVariables2 = variables.FloatVariables; foreach (FsmFloat fsmFloat2 in floatVariables2) { if (fsmFloat2.NetworkSync) { float value11 = 0f; stream.Serialize(ref value11); fsmFloat2.Value = value11; } } intVariables = variables.IntVariables; foreach (FsmInt fsmInt2 in intVariables) { if (fsmInt2.NetworkSync) { int value12 = 0; stream.Serialize(ref value12); fsmInt2.Value = value12; } } quaternionVariables = variables.QuaternionVariables; foreach (FsmQuaternion fsmQuaternion2 in quaternionVariables) { if (fsmQuaternion2.NetworkSync) { Quaternion value13 = Quaternion.identity; stream.Serialize(ref value13); fsmQuaternion2.Value = value13; } } vector3Variables = variables.Vector3Variables; foreach (FsmVector3 fsmVector3 in vector3Variables) { if (fsmVector3.NetworkSync) { Vector3 value14 = Vector3.zero; stream.Serialize(ref value14); fsmVector3.Value = value14; } } colorVariables = variables.ColorVariables; foreach (FsmColor fsmColor2 in colorVariables) { if (fsmColor2.NetworkSync) { float value15 = 0f; stream.Serialize(ref value15); float value16 = 0f; stream.Serialize(ref value16); float value17 = 0f; stream.Serialize(ref value17); float value18 = 0f; stream.Serialize(ref value18); fsmColor2.Value = new Color(value15, value16, value17, value18); } } vector2Variables = variables.Vector2Variables; foreach (FsmVector2 fsmVector4 in vector2Variables) { if (fsmVector4.NetworkSync) { float value19 = 0f; stream.Serialize(ref value19); float value20 = 0f; stream.Serialize(ref value20); fsmVector4.Value = new Vector2(value19, value20); } } }
public void Initialize(bool forceRefresh=false) { //Debug.Log("Initializing "+variableTarget+" _initialized:"+_initialized+" forceRefresh:"+forceRefresh); if (_initialized && !forceRefresh) { return; } _initialized = true; _fsmVariables = null; if (variableTarget == ProxyFsmVariableTarget.GlobalVariable) { _fsmVariables = PlayMaker.FsmVariables.GlobalVariables; // Debug.LogWarning("Setting FsmVariables for "+variableTarget); }else{ if (variableTarget == ProxyFsmVariableTarget.FsmComponent) { if (_fsmComponent!=null) { _fsmVariables = _fsmComponent.FsmVariables; Debug.LogWarning("Setting FsmVariables for "+variableTarget+" _fsmComponent= "+_fsmComponent); } return; } if (gameObject!=null) { fsmComponent = PlayMakerUtils.FindFsmOnGameObject(gameObject,fsmName); } if (fsmComponent==null) { _fsmVariables = null; //Debug.LogError("Initialized with no FsmComponent found"); }else{ _fsmVariables = _fsmComponent.FsmVariables; //Debug.LogWarning("Setting FsmVariables for "+variableTarget+" _fsmComponent= "+_fsmComponent); } } //Debug.Log("Initialized with fsmComponent<"+fsmComponent.FsmName+">"); }
public override void OnEnter() { try { ES2Settings settings = new ES2Settings(); settings.encrypt = encrypt.Value; settings.encryptionPassword = encryptionPassword.Value; if(usePlayerPrefs.Value) settings.saveLocation = ES2Settings.SaveLocation.PlayerPrefs; // Get FSMVariables objects required based on whether the user wants to save // local variables, global variables or both. FsmVariables[] fsmVariables; if(saveFsmVariables.Value && saveGlobalVariables.Value) fsmVariables = new FsmVariables[]{Fsm.Variables, FsmVariables.GlobalVariables}; else if(saveFsmVariables.Value && !saveGlobalVariables.Value) fsmVariables = new FsmVariables[]{Fsm.Variables}; else if(!saveFsmVariables.Value && saveGlobalVariables.Value) fsmVariables = new FsmVariables[]{FsmVariables.GlobalVariables}; else fsmVariables = new FsmVariables[0]; foreach(FsmVariables fsmVariable in fsmVariables) { // Variables are stored in seperate arrays based on their types. // Save each item in each array seperately. foreach(FsmBool fsmVar in fsmVariable.BoolVariables) { settings.tag = fsmVar.Name; ES2.Save(fsmVar.Value, filename.Value, settings); } foreach(FsmArray fsmVar in fsmVariable.ArrayVariables){ settings.tag=fsmVar.Name; EasySaveArrayTools.SaveArray(fsmVar,filename.Value,settings); } foreach(FsmFloat fsmVar in fsmVariable.FloatVariables) { settings.tag = fsmVar.Name; ES2.Save(fsmVar.Value, filename.Value, settings); } foreach(FsmInt fsmVar in fsmVariable.IntVariables) { settings.tag = fsmVar.Name; ES2.Save(fsmVar.Value, filename.Value, settings); } foreach(FsmString fsmVar in fsmVariable.StringVariables) { settings.tag = fsmVar.Name; ES2.Save(fsmVar.Value, filename.Value, settings); } foreach(FsmVector2 fsmVar in fsmVariable.Vector2Variables) { settings.tag = fsmVar.Name; ES2.Save(fsmVar.Value, filename.Value, settings); } foreach(FsmVector3 fsmVar in fsmVariable.Vector3Variables) { settings.tag = fsmVar.Name; ES2.Save(fsmVar.Value, filename.Value, settings); } foreach(FsmRect fsmVar in fsmVariable.RectVariables) { settings.tag = fsmVar.Name; ES2.Save(fsmVar.Value, filename.Value, settings); } foreach(FsmQuaternion fsmVar in fsmVariable.QuaternionVariables) { settings.tag = fsmVar.Name; ES2.Save(fsmVar.Value, filename.Value, settings); } foreach(FsmColor fsmVar in fsmVariable.ColorVariables) { settings.tag = fsmVar.Name; ES2.Save(fsmVar.Value, filename.Value, settings); } foreach(FsmMaterial fsmVar in fsmVariable.MaterialVariables) { settings.tag = fsmVar.Name; ES2.Save(fsmVar.Value, filename.Value, settings); } foreach(FsmTexture fsmVar in fsmVariable.TextureVariables) { settings.tag = fsmVar.Name; ES2.Save(fsmVar.Value as Texture2D, filename.Value, settings); } foreach(FsmObject fsmVar in fsmVariable.ObjectVariables) { settings.tag = fsmVar.Name; ES2.Save(fsmVar.Value, filename.Value, settings); } } Log("Saved to "+filename.Value); Finish(); } catch(Exception e) { if(ifError != null) Fsm.Event(ifError); else LogError (e.Message); } }
public override void OnEnter() { try { if(!ES2.Exists(filename.Value)) { Finish(); return; } ES2Settings settings = new ES2Settings(filename.Value); settings.encrypt = encrypt.Value; settings.encryptionPassword = encryptionPassword.Value; if(usePlayerPrefs.Value) settings.saveLocation = ES2Settings.SaveLocation.PlayerPrefs; ES2Data es2Data = ES2.LoadAll(filename.Value, settings); if(es2Data.loadedData.Count < 1) { Finish(); return; } // Get FSMVariables objects required based on whether the user wants to save // local variables, global variables or both. FsmVariables[] fsmVariables; if(loadFsmVariables.Value && loadGlobalVariables.Value) fsmVariables = new FsmVariables[]{Fsm.Variables, FsmVariables.GlobalVariables}; else if(loadFsmVariables.Value && !loadGlobalVariables.Value) fsmVariables = new FsmVariables[]{Fsm.Variables}; else if(!loadFsmVariables.Value && loadGlobalVariables.Value) fsmVariables = new FsmVariables[]{FsmVariables.GlobalVariables}; else fsmVariables = new FsmVariables[0]; foreach(KeyValuePair<string, object> entry in es2Data.loadedData) { bool arrayMark=false; ES2Type es2Type = ES2TypeManager.GetES2Type(entry.Value.GetType()); if(es2Type == null){ var obj=entry.Value; string fn=obj.GetType().FullName; if(obj.GetType()!=typeof(object[])) continue; arrayMark=true; } foreach(FsmVariables variable in fsmVariables) { if(arrayMark){ FsmArray thisVar=variable.FindFsmArray(entry.Key); if(thisVar!=null){ thisVar.Values=(object[])entry.Value; } continue; } if(es2Type.type == typeof(bool)) { FsmBool thisVar = variable.FindFsmBool(entry.Key); if(thisVar != null) thisVar.Value = es2Data.Load<bool>(entry.Key); } else if(es2Type.type == typeof(float)) { FsmFloat thisVar = variable.FindFsmFloat(entry.Key); if(thisVar != null) thisVar.Value = es2Data.Load<float>(entry.Key); } else if(es2Type.type == typeof(int)) { FsmInt thisVar = variable.FindFsmInt(entry.Key); if(thisVar != null) thisVar.Value =es2Data.Load<int>(entry.Key); } else if(es2Type.type == typeof(string)) { FsmString thisVar = variable.FindFsmString(entry.Key); if(thisVar != null) thisVar.Value = es2Data.Load<string>(entry.Key); } else if(es2Type.type == typeof(Vector2)) { FsmVector2 thisVar = variable.FindFsmVector2(entry.Key); if(thisVar != null) thisVar.Value =es2Data.Load<Vector2>(entry.Key); } else if(es2Type.type == typeof(Vector3)) { FsmVector3 thisVar = variable.FindFsmVector3(entry.Key); if(thisVar != null) thisVar.Value =es2Data.Load<Vector3>(entry.Key); } else if(es2Type.type == typeof(Rect)) { FsmRect thisVar = variable.FindFsmRect(entry.Key); if(thisVar != null) thisVar.Value = es2Data.Load<Rect>(entry.Key); } else if(es2Type.type == typeof(Quaternion)) { FsmQuaternion thisVar = variable.FindFsmQuaternion(entry.Key); if(thisVar != null) thisVar.Value =es2Data.Load<Quaternion>(entry.Key); } else if(es2Type.type == typeof(Color)) { FsmColor thisVar = variable.FindFsmColor(entry.Key); if(thisVar != null) thisVar.Value = es2Data.Load<Color>(entry.Key); } else if(es2Type.type == typeof(Material)) { FsmMaterial thisVar = variable.FindFsmMaterial(entry.Key); if(thisVar != null) thisVar.Value = es2Data.Load<Material>(entry.Key); } else if(es2Type.type == typeof(Texture2D)) { FsmTexture thisVar = variable.FindFsmTexture(entry.Key); if(thisVar != null) thisVar.Value = es2Data.Load<Texture2D>(entry.Key); } else { FsmObject thisVar = variable.FindFsmObject(entry.Key); if(thisVar != null) thisVar.Value = entry.Value as UnityEngine.Object; } } } Log("Loaded from "+filename.Value); Finish(); } catch(System.Exception e) { if(ifError != null) { LogError(e.Message); Fsm.Event(ifError); } } }
public bool GetVariable(PlayMakerFsmVariableTarget variableTarget) { initialized = true; targetUndefined = true; if (variableTarget.FsmVariables !=null) { targetUndefined = false; variableNameToUse = string.IsNullOrEmpty(variableName)?defaultVariableName:variableName; fsmVariables = variableTarget.FsmVariables; _namedVariable = fsmVariables.GetVariable(variableNameToUse); if (_namedVariable !=null) { #if PLAYMAKER_1_8 selectedType = _namedVariable.VariableType; #else selectedType = GetTypeFromChoice(variableSelectionChoice); #endif return true; } } selectedType = VariableType.Unknown; return false; }
/// <summary> /// Gets specific types variables list as strings from FsmVariables. /// Use this method to populate popup selection in inspectors. /// </summary> /// <returns>The list of variables of defined variableType as strings.</returns> /// <param name="fsmVariables">the List of Variables to filter</param> /// <param name="includeNone">If set to <c>true</c> include a "none" option. Useful for popup to select an event or not</param> /// <param name="variableType">Optional, default to Unknown, else will filter by specific type</param> public static string[] GetVariablesStringList(FsmVariables fsmVariables,bool includeNone = false, VariableType variableType = VariableType.Unknown) { string[] list = new string[0]; if (fsmVariables!=null) { //Debug.Log("GetVariablesStringList internal "+variableType+" "+fsmVariables.GetNamedVariables(variableType).Length); if (variableType == VariableType.Unknown) { NamedVariable[] namedVariables = fsmVariables.GetAllNamedVariables();// fsmVariables.GetNamedVariables(variableType);// PlayMakerGlobals.Instance.Variables.GetAllNamedVariables(); list = new string[namedVariables.Length]; int i=0; foreach(NamedVariable _variable in namedVariables) { list[i] = _variable.Name; i++; } } if (variableType == VariableType.Bool) { list = new string[fsmVariables.BoolVariables.Length]; int i=0; foreach(NamedVariable _variable in fsmVariables.BoolVariables) { list[i] = _variable.Name; i++; } } if (variableType == VariableType.Color) { list = new string[fsmVariables.ColorVariables.Length]; int i=0; foreach(NamedVariable _variable in fsmVariables.ColorVariables) { list[i] = _variable.Name; i++; } } if (variableType == VariableType.Float) { list = new string[fsmVariables.FloatVariables.Length]; int i=0; foreach(NamedVariable _variable in fsmVariables.FloatVariables) { list[i] = _variable.Name; i++; } } if (variableType == VariableType.GameObject) { list = new string[fsmVariables.GameObjectVariables.Length]; int i=0; foreach(NamedVariable _variable in fsmVariables.GameObjectVariables) { list[i] = _variable.Name; i++; } } if (variableType == VariableType.Int) { list = new string[fsmVariables.IntVariables.Length]; int i=0; foreach(NamedVariable _variable in fsmVariables.IntVariables) { list[i] = _variable.Name; i++; } } if (variableType == VariableType.Material) { list = new string[fsmVariables.MaterialVariables.Length]; int i=0; foreach(NamedVariable _variable in fsmVariables.MaterialVariables) { list[i] = _variable.Name; i++; } } if (variableType == VariableType.Object) { list = new string[fsmVariables.ObjectVariables.Length]; int i=0; foreach(NamedVariable _variable in fsmVariables.ObjectVariables) { list[i] = _variable.Name; i++; } } if (variableType == VariableType.Quaternion) { list = new string[fsmVariables.QuaternionVariables.Length]; int i=0; foreach(NamedVariable _variable in fsmVariables.QuaternionVariables) { list[i] = _variable.Name; i++; } } if (variableType == VariableType.Rect) { list = new string[fsmVariables.RectVariables.Length]; int i=0; foreach(NamedVariable _variable in fsmVariables.RectVariables) { list[i] = _variable.Name; i++; } } if (variableType == VariableType.String) { list = new string[fsmVariables.StringVariables.Length]; int i=0; foreach(NamedVariable _variable in fsmVariables.StringVariables) { list[i] = _variable.Name; i++; } } if (variableType == VariableType.Texture) { list = new string[fsmVariables.TextureVariables.Length]; int i=0; foreach(NamedVariable _variable in fsmVariables.TextureVariables) { list[i] = _variable.Name; i++; } } if (variableType == VariableType.Vector2) { list = new string[fsmVariables.Vector2Variables.Length]; int i=0; foreach(NamedVariable _variable in fsmVariables.Vector2Variables) { list[i] = _variable.Name; i++; } } if (variableType == VariableType.Vector3) { list = new string[fsmVariables.Vector3Variables.Length]; int i=0; foreach(NamedVariable _variable in fsmVariables.Vector3Variables) { list[i] = _variable.Name; i++; } } #if PLAYMAKER_1_8 if (variableType == VariableType.Array) { list = new string[fsmVariables.ArrayVariables.Length]; int i=0; foreach(NamedVariable _variable in fsmVariables.ArrayVariables) { list[i] = _variable.Name; i++; } } if (variableType == VariableType.Enum) { list = new string[fsmVariables.EnumVariables.Length]; int i=0; foreach(NamedVariable _variable in fsmVariables.EnumVariables) { list[i] = _variable.Name; i++; } } #endif } if (includeNone) { ArrayUtility.Insert<string>(ref list,0,"none"); } return list; }