VoxML LoadMarkup(VoxML v) { VoxML voxml = new VoxML(); try { voxml = v; AssignVoxMLValues(voxml); } catch (FileNotFoundException ex) { } return voxml; }
VoxML LoadMarkup(string text) { VoxML voxml = new VoxML(); try { voxml = VoxML.LoadFromText (text); AssignVoxMLValues(voxml); } catch (FileNotFoundException ex) { } return voxml; }
VoxML LoadMarkup(GameObject obj) { VoxML voxml = new VoxML(); try { voxml = VoxML.Load (obj.name + ".xml"); AssignVoxMLValues(voxml); } catch (FileNotFoundException ex) { } return voxml; }
void AssignVoxMLValues(VoxML voxml) { // assign VoxML values // ENTITY mlEntityType = voxml.Entity.Type; // PRED mlPred = voxml.Lex.Pred; mlTypes = new List<string>(voxml.Lex.Type.Split (new char[]{'*'})); mlTypeCount = mlTypes.Count; mlTypeSelectVisible = new List<int>(new int[]{-1}); mlTypeSelected = new List<int>(new int[]{-1}); mlRemoveType = new List<int>(new int[]{-1}); for (int i = 0; i < mlTypeCount; i++) { mlTypeSelectVisible.Add (-1); mlTypeSelected.Add (-1); mlRemoveType.Add (-1); } // TYPE mlHead = voxml.Type.Head; mlComponents = new List<string>(); foreach (VoxTypeComponent c in voxml.Type.Components) { mlComponents.Add (c.Value); } mlComponentCount = mlComponents.Count; mlConcavity = voxml.Type.Concavity; List <string> rotatSyms = new List<string>(voxml.Type.RotatSym.Split (new char[]{','})); mlRotatSymX = (rotatSyms.Contains("X")); mlRotatSymY = (rotatSyms.Contains("Y")); mlRotatSymZ = (rotatSyms.Contains("Z")); List<string> reflSyms = new List<string>(voxml.Type.ReflSym.Split (new char[]{','})); mlReflSymXY = (reflSyms.Contains ("XY")); mlReflSymXZ = (reflSyms.Contains ("XZ")); mlReflSymYZ = (reflSyms.Contains ("YZ")); mlArgs = new List<string>(); foreach (VoxTypeArg a in voxml.Type.Args) { mlArgs.Add (a.Value); } mlArgCount = mlArgs.Count; mlSubevents = new List<string>(); foreach (VoxTypeSubevent e in voxml.Type.Body) { mlSubevents.Add (e.Value); } mlSubeventCount = mlSubevents.Count; // HABITAT mlIntrHabitats = new List<string>(); foreach (VoxHabitatIntr i in voxml.Habitat.Intrinsic) { mlIntrHabitats.Add (i.Name + "=" + i.Value); } mlIntrHabitatCount = mlIntrHabitats.Count; mlExtrHabitats = new List<string>(); foreach (VoxHabitatExtr e in voxml.Habitat.Extrinsic) { mlExtrHabitats.Add (e.Name + "=" + e.Value); } mlExtrHabitatCount = mlExtrHabitats.Count; // AFFORD_STR mlAffordances = new List<string>(); foreach (VoxAffordAffordance a in voxml.Afford_Str.Affordances) { mlAffordances.Add (a.Formula); } mlAffordanceCount = mlAffordances.Count; // EMBODIMENT mlScale = voxml.Embodiment.Scale; mlMovable = voxml.Embodiment.Movable; }
public void OnGUI() { if (DrawInspector) { inspectorPositionAdjX = inspectorPosition.x; inspectorPositionAdjY = inspectorPosition.y; if (inspectorPosition.x + inspectorWidth > Screen.width) { if (inspectorPosition.y > Screen.height - inspectorMargin) { inspectorPositionAdjX = inspectorPosition.x - inspectorWidth; inspectorPositionAdjY = inspectorPosition.y - inspectorHeight; inspectorRect = new Rect (inspectorPosition.x - inspectorWidth, inspectorPosition.y - inspectorHeight, inspectorWidth, inspectorHeight); } else if (inspectorPosition.y + inspectorHeight > Screen.height) { inspectorPositionAdjX = inspectorPosition.x - inspectorWidth; inspectorRect = new Rect (inspectorPosition.x - inspectorWidth, inspectorPosition.y, inspectorWidth, Screen.height - inspectorPosition.y); } else { inspectorPositionAdjX = inspectorPosition.x - inspectorWidth; inspectorRect = new Rect (inspectorPosition.x - inspectorWidth, inspectorPosition.y, inspectorWidth, inspectorHeight); } } else if (inspectorPosition.y > Screen.height - inspectorMargin) { inspectorPositionAdjY = inspectorPosition.y - inspectorHeight; inspectorRect = new Rect (inspectorPosition.x, inspectorPosition.y - inspectorHeight, inspectorWidth, inspectorHeight); } else if (inspectorPosition.y + inspectorHeight > Screen.height) { inspectorRect = new Rect (inspectorPosition.x, inspectorPosition.y, inspectorWidth, Screen.height - inspectorPosition.y); } else { inspectorRect = new Rect (inspectorPosition.x, inspectorPosition.y, inspectorWidth, inspectorHeight); } /*#if UNITY_EDITOR || UNITY_STANDALONE if (File.Exists (inspectorObject.name + ".xml")) { if (!ObjectLoaded (inspectorObject)) { loadedObject = LoadMarkup (inspectorObject); markupCleared = false; } } else { if (!markupCleared) { InitNewMarkup (); loadedObject = new VoxML (); } } #endif #if UNITY_WEBPLAYER*/ // Resources load here TextAsset markup = Resources.Load (inspectorObject.name) as TextAsset; if (markup != null) { if (!ObjectLoaded (markup.text)) { loadedObject = LoadMarkup (markup.text); inspectorTitle = inspectorObject.name; markupCleared = false; } } else { if (!markupCleared) { InitNewMarkup (); loadedObject = new VoxML (); } } //#endif GUILayout.BeginArea (inspectorRect, GUI.skin.window); switch (mlEntityType) { case VoxEntity.EntityType.Object: DisplayObjectMarkup (); break; case VoxEntity.EntityType.Program: DisplayProgramMarkup (); break; case VoxEntity.EntityType.Attribute: DisplayAttributeMarkup (); break; case VoxEntity.EntityType.Relation: DisplayRelationMarkup (); break; case VoxEntity.EntityType.Function: DisplayFunctionMarkup (); break; default: break; } GUILayout.EndArea (); Vector2 textDimensions = GUI.skin.label.CalcSize (new GUIContent (inspectorTitle)); GUI.Label (new Rect (((2 * inspectorPositionAdjX + inspectorWidth) / 2) - textDimensions.x / 2, inspectorPositionAdjY, textDimensions.x, 25), inspectorObject.name); } }
protected override void OnGUI() { /*if (DrawInspector) { inspectorPositionAdjX = inspectorPosition.x; inspectorPositionAdjY = inspectorPosition.y; if (inspectorPosition.x + inspectorWidth > Screen.width) { if (inspectorPosition.y > Screen.height - inspectorMargin) { inspectorPositionAdjX = inspectorPosition.x - inspectorWidth; inspectorPositionAdjY = inspectorPosition.y - inspectorHeight; inspectorRect = new Rect (inspectorPosition.x - inspectorWidth, inspectorPosition.y - inspectorHeight, inspectorWidth, inspectorHeight); } else if (inspectorPosition.y + inspectorHeight > Screen.height) { inspectorPositionAdjX = inspectorPosition.x - inspectorWidth; inspectorRect = new Rect (inspectorPosition.x - inspectorWidth, inspectorPosition.y, inspectorWidth, Screen.height - inspectorPosition.y); } else { inspectorPositionAdjX = inspectorPosition.x - inspectorWidth; inspectorRect = new Rect (inspectorPosition.x - inspectorWidth, inspectorPosition.y, inspectorWidth, inspectorHeight); } } else if (inspectorPosition.y > Screen.height - inspectorMargin) { inspectorPositionAdjY = inspectorPosition.y - inspectorHeight; inspectorRect = new Rect (inspectorPosition.x, inspectorPosition.y - inspectorHeight, inspectorWidth, inspectorHeight); } else if (inspectorPosition.y + inspectorHeight > Screen.height) { inspectorRect = new Rect (inspectorPosition.x, inspectorPosition.y, inspectorWidth, Screen.height - inspectorPosition.y); } else { inspectorRect = new Rect (inspectorPosition.x, inspectorPosition.y, inspectorWidth, inspectorHeight); }*/ /*#if UNITY_EDITOR || UNITY_STANDALONE if (File.Exists (inspectorObject.name + ".xml")) { if (!ObjectLoaded (inspectorObject)) { loadedObject = LoadMarkup (inspectorObject); markupCleared = false; } } else { if (!markupCleared) { InitNewMarkup (); loadedObject = new VoxML (); } } #endif #if UNITY_WEBPLAYER*/ // Resources load here TextAsset markup = Resources.Load (InspectorVoxeme) as TextAsset; if (markup != null) { if (!ObjectLoaded (markup.text)) { loadedObject = LoadMarkup (markup.text); windowTitle = InspectorVoxeme; markupCleared = false; } } else { if (!markupCleared) { InitNewMarkup (); loadedObject = new VoxML (); } } //#endif //} base.OnGUI (); }
// Use this for initialization void Start() { // load in VoxML knowledge TextAsset markup = Resources.Load (gameObject.name) as TextAsset; if (markup != null) { voxml = VoxML.LoadFromText (markup.text); } // populate operational voxeme structure PopulateOperationalVoxeme(); // get movement blocking minYBound = Helper.GetObjectWorldSize(gameObject).min.y; // get rigging components rigging = gameObject.GetComponent<Rigging> (); targetPosition = transform.position; targetRotation = transform.eulerAngles; targetScale = transform.localScale; }