public override void OnInspectorGUI() { PlayMakerHashTableProxy proxy = (PlayMakerHashTableProxy)target; proxy.referenceName = EditorGUILayout.TextField(new GUIContent("Reference", "Unique Reference of this Hashtable. Use it if more than one Hashtable is dropped on this game Object"), proxy.referenceName); //BuildEventsInspectorGUI(); // Switch between the two, because we don't need them when they can't be of any help and also would be misleading since changes would not persists if (Application.isPlaying) { BuildPreviewInspectorGUI(); } else { BuildPreFillInspectorGUI(true); // build prefill inspector with keys } if (GUI.changed) { EditorUtility.SetDirty(proxy); } } // OnInspectorGUI
private void DoAddPlayMakerHashTable() { var go = Fsm.GetOwnerDefaultTarget(gameObject); PlayMakerHashTableProxy proxy = GetHashTableProxyPointer(go, reference.Value, true); if (proxy != null) { Fsm.Event(alreadyExistsEvent); } else { addedComponent = (PlayMakerHashTableProxy)go.AddComponent("PlayMakerHashTableProxy"); if (addedComponent == null) { Debug.LogError("Can't add PlayMakerHashTableProxy"); } else { addedComponent.referenceName = reference.Value; } } } // DoAddPlayMakerHashTable
void Awake() { GameObject stagingWheel = Instantiate(GameObject.Find("HAYOSIKO(1500kg, 250)").transform.Find("StagingWheel").gameObject); stagingWheel.name = "StagingWheel"; stagingWheel.transform.parent = transform.root; stagingWheel.transform.localPosition = new Vector3(0f, 0.74f, 1.21f); stagingWheel.transform.localEulerAngles = Vector3.zero; stagingWheel.transform.localScale = Vector3.one; PlayMakerFSM data = stagingWheel.GetComponent <PlayMakerFSM>(); Car = data.FsmVariables.FindFsmString("Car"); ID = data.FsmVariables.FindFsmInt("ID"); Name = data.FsmVariables.FindFsmString("Name"); Car.Value = "'90 EDM 500LX"; ID.Value = 14; PlayerName = PlayMakerGlobals.Instance.Variables.FindFsmString("PlayerName"); string[] stringProxies = new string[] { "Speeds", "Cars", "Names", "ResultsTimes", "ResultsSpeeds", "ResultsNames", "ResultsCars" }; proxyLists = GameObject.Find("DRAGRACE").transform.Find("LOD/DRAGSTRIP/DragTiming").GetComponents <PlayMakerArrayListProxy>(); foreach (PlayMakerArrayListProxy proxy in proxyLists) { if (proxy.referenceName == "Times") { proxy.preFillCount++; proxy.preFillFloatList.Add(0f); if (proxy._arrayList != null && proxy._arrayList.Count > 0) { proxy._arrayList.Add(0f); } continue; } if (stringProxies.Contains(proxy.referenceName)) { proxy.preFillCount++; proxy.preFillStringList.Add(""); if (proxy._arrayList != null && proxy._arrayList.Count > 0) { proxy._arrayList.Add(""); } continue; } } PlayMakerHashTableProxy hashTable = GameObject.Find("DRAGRACE").transform.Find("LOD/DRAGSTRIP/DragTiming").GetComponents <PlayMakerHashTableProxy>().FirstOrDefault(x => x.referenceName == "Results"); hashTable.preFillCount++; hashTable.preFillKeyList.Add(""); hashTable.preFillFloatList.Add(0f); if (hashTable._hashTable != null && hashTable._hashTable.Count > 0) { hashTable._hashTable.Add("", 0f); } }
public override void Enter() { _proxy = CollectionsActions.GetHashTableProxyPointer(Fsm.GetOwnerDefaultTarget(gameObject), reference.Value, false); if (_proxy != null) { Execute(); } }
protected bool SetUpHashTableProxyPointer(GameObject aProxyGO, string nameReference) { if (aProxyGO == null) { return(false); } this.proxy = base.GetHashTableProxyPointer(aProxyGO, nameReference, false); return(this.proxy != null); }
protected bool SetUpHashTableProxyPointer(GameObject aProxyGO,string nameReference) { if (aProxyGO == null){ return false; } proxy = GetHashTableProxyPointer(aProxyGO,nameReference,false); return proxy!=null; }
// not clever enough to work out how to use <T> properly to have only one function for both hashtable and arrayList... protected bool SetUpHashTableProxyPointer(PlayMakerHashTableProxy aProxy,string nameReference) { if (aProxy == null){ return false; } proxy = GetHashTableProxyPointer(aProxy.gameObject,nameReference,false); return proxy!=null; }
protected bool SetUpHashTableProxyPointer(PlayMakerHashTableProxy aProxy, string nameReference) { if (aProxy == null) { return(false); } this.proxy = base.GetHashTableProxyPointer(aProxy.gameObject, nameReference, false); return(this.proxy != null); }
protected PlayMakerHashTableProxy GetHashTableProxyPointer(GameObject aProxy, string nameReference, bool silent) { if (aProxy == null) { if (!silent) { Debug.LogError("Null Proxy"); } return(null); } PlayMakerHashTableProxy[] components = aProxy.GetComponents <PlayMakerHashTableProxy>(); if (components.Length > 1) { if (nameReference == string.Empty && !silent) { Debug.LogWarning("Several HashTable Proxies coexists on the same GameObject and no reference is given to find the expected HashTable"); } PlayMakerHashTableProxy[] array = components; for (int i = 0; i < array.Length; i++) { PlayMakerHashTableProxy playMakerHashTableProxy = array[i]; if (playMakerHashTableProxy.referenceName == nameReference) { return(playMakerHashTableProxy); } } if (nameReference != string.Empty) { if (!silent) { Debug.LogError("HashTable Proxy not found for reference <" + nameReference + ">"); } return(null); } } else if (components.Length > 0) { if (nameReference != string.Empty && nameReference != components[0].referenceName) { if (!silent) { Debug.LogError("HashTable Proxy reference do not match"); } return(null); } return(components[0]); } if (!silent) { Debug.LogError("HashTable not found"); } return(null); }
protected bool SetUpHashTableProxyPointer(GameObject aProxyGO, string nameReference) { // UnityEngine.Debug.Log(aProxyGO); if (aProxyGO == null) { return(false); } proxy = GetHashTableProxyPointer(aProxyGO, nameReference, false); return(proxy != null); }
private void DoDestroyHashTable(GameObject go) { PlayMakerHashTableProxy[] components = this.proxy.GetComponents <PlayMakerHashTableProxy>(); PlayMakerHashTableProxy[] array = components; for (int i = 0; i < array.Length; i++) { PlayMakerHashTableProxy playMakerHashTableProxy = array[i]; if (playMakerHashTableProxy.referenceName == this.reference.Value) { UnityEngine.Object.Destroy(playMakerHashTableProxy); base.Fsm.Event(this.successEvent); return; } } base.Fsm.Event(this.notFoundEvent); }
public override void OnEnter() { PlayMakerHashTableProxy _proxy = GetHashTableProxyPointer(Fsm.GetOwnerDefaultTarget(gameObject), reference.Value, true); bool _isEmpty = _proxy.hashTable.Count == 0; isEmpty.Value = _isEmpty; if (_isEmpty) { Fsm.Event(isEmptyEvent); } else { Fsm.Event(isNotEmptyEvent); } Finish(); }
public override void OnEnter() { PlayMakerHashTableProxy _proxy = GetHashTableProxyPointer(Fsm.GetOwnerDefaultTarget(gameObject), reference.Value, true); bool exists = _proxy != null; doesExists.Value = exists; if (exists) { Fsm.Event(doesExistsEvent); } else { Fsm.Event(doesNotExistsEvent); } Finish(); }
private void DoAddPlayMakerHashTable() { var go = Fsm.GetOwnerDefaultTarget(gameObject); PlayMakerHashTableProxy proxy = GetHashTableProxyPointer(go,reference.Value,true); if (proxy!=null) { Fsm.Event(alreadyExistsEvent); }else{ addedComponent = (PlayMakerHashTableProxy)go.AddComponent("PlayMakerHashTableProxy"); if (addedComponent == null) { Debug.LogError("Can't add PlayMakerHashTableProxy"); }else{ addedComponent.referenceName = reference.Value; } } }
private void DoAddPlayMakerHashTable() { GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.gameObject); PlayMakerHashTableProxy hashTableProxyPointer = base.GetHashTableProxyPointer(ownerDefaultTarget, this.reference.Value, true); if (hashTableProxyPointer != null) { base.Fsm.Event(this.alreadyExistsEvent); } else { this.addedComponent = ownerDefaultTarget.AddComponent<PlayMakerHashTableProxy>(); if (this.addedComponent == null) { Debug.LogError("Can't add PlayMakerHashTableProxy"); } else { this.addedComponent.referenceName = this.reference.Value; } } }
private void DoAddPlayMakerHashTable() { GameObject ownerDefaultTarget = base.Fsm.GetOwnerDefaultTarget(this.gameObject); PlayMakerHashTableProxy hashTableProxyPointer = base.GetHashTableProxyPointer(ownerDefaultTarget, this.reference.Value, true); if (hashTableProxyPointer != null) { base.Fsm.Event(this.alreadyExistsEvent); } else { this.addedComponent = ownerDefaultTarget.AddComponent <PlayMakerHashTableProxy>(); if (this.addedComponent == null) { Debug.LogError("Can't add PlayMakerHashTableProxy"); } else { this.addedComponent.referenceName = this.reference.Value; } } }
} // OnInspectorGUI public void BuildPreviewInspectorGUI() //public override void OnInspectorGUI() { PlayMakerHashTableProxy proxy = (PlayMakerHashTableProxy)target; if (proxy.hashTable == null) { return; } int count = proxy.hashTable.Count; BuildPreviewInspectorHeaderGUI(count); if (!proxy.showContent) { return; } if (proxy.hashTable != null) { int start = proxy.contentPreviewStartIndex; int last = Mathf.Min(count, proxy.contentPreviewStartIndex + proxy.contentPreviewMaxRows); ArrayList keysList = new ArrayList(proxy.hashTable.Keys); string label; for (int i = start; i < last; i++) { label = keysList[i].ToString(); if (proxy.hashTable[keysList[i]] != null) { EditorGUILayout.BeginHorizontal(); if (proxy.hashTable[keysList[i]].GetType() == typeof(bool)) { proxy.hashTable[keysList[i]] = (bool)EditorGUILayout.Toggle(label, (bool)proxy.hashTable[keysList[i]]); } else if (proxy.hashTable[keysList[i]].GetType() == typeof(Color)) { proxy.hashTable[keysList[i]] = (Color)EditorGUILayout.ColorField(label, (Color)proxy.hashTable[keysList[i]]); } else if (proxy.hashTable[keysList[i]].GetType() == typeof(float)) { proxy.hashTable[keysList[i]] = (float)EditorGUILayout.FloatField(label, (float)proxy.hashTable[keysList[i]]); } else if (proxy.hashTable[keysList[i]].GetType() == typeof(GameObject)) { proxy.hashTable[keysList[i]] = (GameObject)EditorGUILayout.ObjectField(label, (GameObject)proxy.hashTable[keysList[i]], typeof(GameObject), true); } else if (proxy.hashTable[keysList[i]].GetType() == typeof(int)) { proxy.hashTable[keysList[i]] = (int)EditorGUILayout.IntField(label, (int)proxy.hashTable[keysList[i]]); } else if (proxy.hashTable[keysList[i]].GetType() == typeof(Material)) { proxy.hashTable[keysList[i]] = (Material)EditorGUILayout.ObjectField(label, (Material)proxy.hashTable[keysList[i]], typeof(Material), false); } else if (proxy.hashTable[keysList[i]].GetType() == typeof(Object)) { proxy.hashTable[keysList[i]] = (Object)EditorGUILayout.ObjectField(label, (Object)proxy.hashTable[keysList[i]], typeof(Object), true); } else if (proxy.hashTable[keysList[i]].GetType() == typeof(Quaternion)) { Quaternion q = (Quaternion)proxy.hashTable[keysList[i]]; Vector4 quat = new Vector4(q[0], q[1], q[2], q[3]); quat = EditorGUILayout.Vector4Field(label, quat); q[0] = quat[0]; q[1] = quat[1]; q[2] = quat[2]; q[3] = quat[3]; proxy.hashTable[keysList[i]] = q; } else if (proxy.hashTable[keysList[i]].GetType() == typeof(Rect)) { proxy.hashTable[keysList[i]] = (Rect)EditorGUILayout.RectField(label, (Rect)proxy.hashTable[keysList[i]]); } else if (proxy.hashTable[keysList[i]].GetType() == typeof(string)) { proxy.hashTable[keysList[i]] = (string)EditorGUILayout.TextField(label, (string)proxy.hashTable[keysList[i]]); } else if (proxy.hashTable[keysList[i]].GetType() == typeof(Texture2D)) { GUILayout.BeginHorizontal(); GUILayout.Space(15); GUILayout.Label(label); GUILayout.FlexibleSpace(); if (proxy.TextureElementSmall) { proxy.hashTable[keysList[i]] = (Texture2D)EditorGUILayout.ObjectField((Texture2D)proxy.hashTable[keysList[i]], typeof(Texture2D), false); } else { proxy.hashTable[keysList[i]] = (Texture2D)EditorGUILayout.ObjectField("", (Texture2D)proxy.hashTable[keysList[i]], typeof(Texture2D), false); } GUILayout.Space(10); GUILayout.EndHorizontal(); } else if (proxy.hashTable[keysList[i]].GetType() == typeof(Vector2)) { proxy.hashTable[keysList[i]] = (Vector2)EditorGUILayout.Vector2Field(label, (Vector2)proxy.hashTable[keysList[i]]); } else if (proxy.hashTable[keysList[i]].GetType() == typeof(Vector3)) { proxy.hashTable[keysList[i]] = (Vector3)EditorGUILayout.Vector3Field(label, (Vector3)proxy.hashTable[keysList[i]]); } else if (proxy.hashTable[keysList[i]].GetType() == typeof(AudioClip)) { proxy.hashTable[keysList[i]] = (AudioClip)EditorGUILayout.ObjectField(label, (AudioClip)proxy.hashTable[keysList[i]], typeof(AudioClip), true); } else if (proxy.hashTable[keysList[i]].GetType() == typeof(byte)) { int _val = System.Convert.ToInt32(proxy.hashTable[keysList[i]]); proxy.hashTable[keysList[i]] = (byte)EditorGUILayout.IntField(label, _val); } else if (proxy.hashTable[keysList[i]].GetType() == typeof(Sprite)) { proxy.hashTable[keysList[i]] = (Sprite)EditorGUILayout.ObjectField(label, (Sprite)proxy.hashTable[keysList[i]], typeof(Sprite), true); } else { // OUPS Debug.Log(proxy.hashTable[keysList[i]].GetType()); // EditorGUILayout.TextField(label, (string)proxy.hashTable[keysList[i]]); } } else { EditorGUILayout.LabelField(label, "-- NULL --"); } EditorGUILayout.EndHorizontal(); if (Application.isPlaying && GUI.changed) { proxy.InspectorEdit(i); } } } else { EditorGUILayout.LabelField("", ""); } if (proxy.liveUpdate) { Repaint(); } }
public void OnEnable() { PlayMakerHashTableProxy proxy = (PlayMakerHashTableProxy)target; proxy.cleanPrefilledLists(); }
public override void OnEnter() { if (string.IsNullOrEmpty(jsonString.Value)) { LogWarning("json raw string is empty"); Fsm.Event(failureEvent); Finish(); return; } Hashtable jsonHash; try { jsonHash = (Hashtable)JSON.JsonDecode(jsonString.Value); if (jsonHash == null) { LogWarning("json content is null"); return; } } catch (System.Exception e) { LogError("Json parsing error " + e.Message); Fsm.Event(failureEvent); Finish(); return; } if (jsonHash == null) { LogError("Json parsing failed "); Fsm.Event(failureEvent); Finish(); return; } int i = 0; foreach (FsmString _key in keys) { object _val = jsonHash[_key.Value]; if (_val != null) { //Debug.Log(_val.GetType().Name); if (_val.GetType() == typeof(Hashtable)) { if (values[i].Type == VariableType.GameObject) { // we put it into a hashtable with a proper reference to it; PlayMakerHashTableProxy _proxy = GetHashTableProxyPointer(values[i].gameObjectValue, _key.Value, true); if (_proxy != null) { Hashtable _table = (Hashtable)_val; foreach (DictionaryEntry _entry in _table) { if (_entry.Value.GetType() == typeof(Hashtable) || _entry.Value.GetType() == typeof(ArrayList)) { _proxy.hashTable[_entry.Key] = JSON.JsonEncode(_entry.Value); } else { _proxy.hashTable[_entry.Key] = _entry.Value; } } } } else if (values[i].Type == VariableType.String) { PlayMakerUtils.ApplyValueToFsmVar(Fsm, values[i], JSON.JsonEncode(_val)); } } else if (_val.GetType() == typeof(ArrayList)) { if (values[i].Type == VariableType.GameObject) { // we put it into a arraylist with a proper reference to it; PlayMakerArrayListProxy _proxy = GetArrayListProxyPointer(values[i].gameObjectValue, "", true); if (_proxy != null) { // Debug.Log("We are in"); ArrayList _list = (ArrayList)_val; foreach (object _entry in _list) { // Debug.Log(_entry); if (_entry.GetType() == typeof(Hashtable) || _entry.GetType() == typeof(ArrayList)) { _proxy.arrayList.Add(JSON.JsonEncode(_entry)); } else { _proxy.arrayList.Add(_entry); } } } } else if (values[i].Type == VariableType.String) { PlayMakerUtils.ApplyValueToFsmVar(Fsm, values[i], JSON.JsonEncode(_val)); } } else { PlayMakerUtils.ApplyValueToFsmVar(Fsm, values[i], _val); } } i++; } Fsm.Event(successEvent); Finish(); }