// Execute the action public int Execute(HeroKitObject hko) { heroKitObject = hko; eventID = heroKitObject.heroStateData.eventBlock; AudioMixerSnapshot snapshot = ObjectValue.GetValue <AudioMixerSnapshot>(heroKitObject, 0); bool runThis = (snapshot != null); if (runThis) { snapshot.TransitionTo(.01f); } // show debug message if (heroKitObject.debugHeroObject) { string debugMessage = "Snapshot: " + snapshot; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { // get values heroKitObject = hko; SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false); Font font = ObjectValue.GetValue <Font>(heroKitObject, 2); // get the text box Text text = null; if (objectData.heroKitObject != null) { text = objectData.heroKitObject[0].GetHeroComponent <Text>("Text"); } else if (objectData.gameObject != null) { text = heroKitObject.GetGameObjectComponent <Text>("Text", false, objectData.gameObject[0]); } // change the font if (text != null) { text.font = font; } // show debug message if (heroKitObject.debugHeroObject) { string textName = (text != null) ? text.gameObject.name : ""; string debugMessage = "Font: " + font + "Text Object: " + textName; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
// Execute the action public int Execute(HeroKitObject hko) { // get values heroKitObject = hko; TextAsset csv = ObjectValue.GetValue <TextAsset>(heroKitObject, 0); bool runThis = (csv != null); if (runThis) { string text = csv.text; // save name of the localization file (used to play localized audio for messages) bool localizeAudio = BoolValue.GetValue(heroKitObject, 1); HeroKitCommonRuntime.localizatonDirectory = (localizeAudio) ? StringFieldValue.GetValueA(heroKitObject, 2) : ""; // get each line in the file string[] delimitersA = { "\r\n" }; string[] lines = text.Split(delimitersA, StringSplitOptions.RemoveEmptyEntries); // get key and value from each line List <KeyValuePair <string, string> > localizationList = new List <KeyValuePair <string, string> >(); char[] delimitersB = { ',' }; for (int i = 0; i < lines.Length; i++) { string[] textLine = lines[i].Split(delimitersB, 2); if (textLine.Length >= 2) { string key = textLine[0]; string value = textLine[1]; // if value is more than one word, remove quotes bool removeQuotes = value.Contains(" "); if (removeQuotes) { string trimmedValue = value.Trim('\"'); value = trimmedValue; } // add the key and value to the localization list localizationList.Add(new KeyValuePair <string, string>(key, value)); } } // add the key value pairs to the dictionary if (localizationList.Count > 0) { HeroKitDatabase.LocalizationDictionary = new Dictionary <string, string>(); HeroKitDatabase.AddLocalization(localizationList); } } // show debug message if (heroKitObject.debugHeroObject) { string fileName = (csv != null) ? csv.name : ""; string debugMessage = "CSV File: " + fileName; Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage)); } return(-99); }
/// <summary>show a field where the designer can either enter a value or choose a global variable</summary> public static ObjectValue GlobalObjectVarOrValueField(EditorWindow ed, string label, ObjectValue objectVal, System.Type objectType, bool allowSceneObject = true, int labelWidth = 100, int fieldWidth = 0) { if (objectVal == null) { Debug.LogWarning("GlobalObjectVarOrValueField: ObjectValue not initialised."); return objectVal; } EditorGUILayout.BeginHorizontal(); { if (!string.IsNullOrEmpty(label)) { if (labelWidth > 0) GUILayout.Label(label, GUILayout.Width(labelWidth)); else GUILayout.Label(label); EditorGUILayout.Space(); } if (!string.IsNullOrEmpty(objectVal.objectVarName)) { GUI.enabled = false; if (fieldWidth > 0) EditorGUILayout.TextField(objectVal.objectVarName, GUILayout.Width(fieldWidth)); else EditorGUILayout.TextField(objectVal.objectVarName); GUI.enabled = true; } else { if (fieldWidth > 0) objectVal.SetAsValue = EditorGUILayout.ObjectField(objectVal.GetValue(null), objectType, allowSceneObject, GUILayout.Width(fieldWidth)); else objectVal.SetAsValue = EditorGUILayout.ObjectField(objectVal.GetValue(null), typeof(Object), allowSceneObject); } if (GUILayout.Button(new GUIContent(UniRPGEdGui.Icon_Tag, "Select variable"), EditorStyles.miniButton, GUILayout.Width(25))) { GlobalVarSelectWiz.Show(objectVal, ed); } } EditorGUILayout.EndHorizontal(); return objectVal; }