internal Data(string option_text, Property.Type type, Category category, System.Object init_value, bool user_defined) : this() { userDefined = user_defined; optionText = option_text; currentValue = init_value.ToString(); propertyType = type; associatedEnumType = typeof(void).FullName; propertyCategory = category;; }
public Data() { userDefined = true; changed = false; isStepFlag = false; propertyFlag = ""; optionText = ""; currentValue = ""; propertyType = Type.GROUP; associatedEnumType = ""; processStep = (aiPostProcessSteps)0; propertyCategory = Category.None;; customOption = SelfDefinedOption.NONE; }
private static System.Object InitValue(SelfDefinedOption option, Property.Type type, System.Object default_value) { string key_name = Enum.GetName(typeof(SelfDefinedOption), option); if (PlayerPrefs.HasKey(key_name)) { return(PlayerPrefs.GetString(key_name)); } else { if (type == Property.Type.FLAG) { return((int)default_value); // Must be cast explicitely to int to avoid ToString conversion of enums } else { return(default_value); } } }
private static System.Object InitValue(Importer importer, string key_name, Property.Type type, System.Object default_value) { if (PlayerPrefs.HasKey(key_name)) { return(PlayerPrefs.GetString(key_name)); } else { try { switch (type) { case Property.Type.FLAG: case Property.Type.INT: return(importer.Assimp.GetProperty <int>(key_name)); case Property.Type.BOOL: // Do not check importer value because we can not determine if a value is present, so use default value instead. //return importer.GetProperty<bool>(key_name); return(default_value); case Property.Type.FLOAT: return(importer.Assimp.GetProperty <float>(key_name)); case Property.Type.STRING: return(importer.Assimp.GetProperty <string>(key_name)); case Property.Type.MATRIX: string value; using (aiMatrix4x4 matrix = importer.Assimp.GetProperty <aiMatrix4x4>(key_name)) { using (aiVector3D position = new aiVector3D()) { using (aiVector3D scaling = new aiVector3D()) { using (aiQuaternion rot = new aiQuaternion()) { matrix.Decompose(scaling, rot, position); Quaternion rotation = Model.Type.Assimp.Convert.AssimpToUnity.Quaternion(rot); Vector3 angles = rotation.eulerAngles; value = UI.List.Serialize(new List <string> { position.x.ToString(), position.y.ToString(), position.z.ToString(), angles.x.ToString(), angles.y.ToString(), angles.z.ToString(), scaling.x.ToString(), scaling.y.ToString(), scaling.z.ToString() }); } } } } return(value); } } catch (Module.Import.Assimp.NotDefinedException) { if (type == Property.Type.FLAG) { return((int)default_value); // Must be cast explicitely to int to avoid ToString conversion of enums } else { return(default_value); } } } Debug.LogWarning("Incorrect type of property (" + key_name + ", " + type + "): unable to initialize it."); return(""); }
internal Data(SelfDefinedOption option, Property.Type type, Category category, System.Type enum_type, System.Object init_value) : this(Enum.GetName(typeof(SelfDefinedOption), option), type, category, InitValue(option, type, (int)init_value), true) { customOption = option; associatedEnumType = enum_type.ToString(); }
internal Data(SelfDefinedOption option, Property.Type type, Category category, System.Object init_value) : this(option, type, category, init_value, true) { }
internal Data(SelfDefinedOption option, Property.Type type, Category category, System.Object init_value, bool user_defined) : this(Enum.GetName(typeof(SelfDefinedOption), option), type, category, InitValue(option, type, init_value), user_defined) { customOption = option; }
internal Data(Importer importer, string property_flag, string option_text, Property.Type type, Category category, System.Type enum_type, System.Object init_value) : this(importer, property_flag, option_text, type, category, enum_type, (int)init_value, true) { }
internal Data(Importer importer, string property_flag, string option_text, Property.Type type, Category category, System.Type enum_type, System.Object init_value, bool user_defined) : this(importer, property_flag, option_text, type, category, (int)init_value, user_defined) { associatedEnumType = enum_type.ToString(); }
internal Data(Importer importer, string property_flag, string option_text, Property.Type type, Category category, System.Object init_value, bool user_defined) : this(option_text, type, category, InitValue(importer, property_flag, type, init_value), user_defined) { propertyFlag = property_flag; }
public override void OnInspectorGUI() { shot = (Shot)target; shot.NumberOfActors = EditorGUILayout.IntSlider ("Number Of Actors", shot.NumberOfActors, 0, 4); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Lock"); shot.LockX = EditorGUILayout.ToggleLeft("X",shot.LockX,GUILayout.MaxWidth(30)); shot.LockY = EditorGUILayout.ToggleLeft("Y",shot.LockY,GUILayout.MaxWidth(30)); shot.LockZ = EditorGUILayout.ToggleLeft("Z",shot.LockZ,GUILayout.MaxWidth(30)); EditorGUILayout.EndHorizontal(); for (int i = 0; i<shot.NumberOfActors; i++) { EditorGUILayout.LabelField("Actor "+i+" volume of interest:"); shot.VolumesOfInterestPosition [i] = EditorGUILayout.Vector3Field (" Position", shot.VolumesOfInterestPosition [i]); shot.VolumesOfInterestSize [i] = EditorGUILayout.Vector3Field (" Size", shot.VolumesOfInterestSize [i]); } if (shot.NumberOfActors > 0) { shot.FixPropertiesType(); EditorGUILayout.Separator (); EditorGUILayout.LabelField ("Properties",EditorStyles.largeLabel); Property toRemove = null; foreach (Property p in shot.Properties) { EditorGUILayout.BeginHorizontal (); EditorGUILayout.LabelField (p.PropertyType.ToString ()+" (Actor "+p.MainSubjectIndex+") ",GUILayout.MinWidth(140)); switch (p.PropertyType) { case Property.Type.ProjectionSize: EditorGUILayout.LabelField("Size",GUILayout.Width(30)); ((ProjectionSize)p).DesiredSize = EditorGUILayout.FloatField(((ProjectionSize)p).DesiredSize,GUILayout.MaxWidth(30)); break; case Property.Type.VantageAngle: EditorGUILayout.LabelField("H",EditorStyles.wordWrappedLabel); ((VantageAngle)p).DesiredHorizontalAngle = EditorGUILayout.FloatField(((VantageAngle)p).DesiredHorizontalAngle,GUILayout.MaxWidth(30)); EditorGUILayout.LabelField("V",EditorStyles.wordWrappedLabel); ((VantageAngle)p).DesiredVerticalAngle = EditorGUILayout.FloatField(((VantageAngle)p).DesiredVerticalAngle,GUILayout.MaxWidth(30)); break; case Property.Type.PositionOnScreen: EditorGUILayout.LabelField("X",EditorStyles.wordWrappedLabel); ((PositionOnScreen)p).DesiredHorizontalPosition = EditorGUILayout.FloatField(((PositionOnScreen)p).DesiredHorizontalPosition,GUILayout.MaxWidth(30)); EditorGUILayout.LabelField("Y",EditorStyles.wordWrappedLabel); ((PositionOnScreen)p).DesiredVerticalPosition = EditorGUILayout.FloatField(((PositionOnScreen)p).DesiredVerticalPosition,GUILayout.MaxWidth(30)); break; case Property.Type.RelativePosition: ((RelativePosition)p).DesiredPosition = (RelativePosition.Position)EditorGUILayout.EnumPopup(((RelativePosition)p).DesiredPosition); EditorGUILayout.LabelField(" (Actor "+((RelativePosition)p).SecondaryActorIndex+")",GUILayout.MinWidth(30)); break; } EditorGUILayout.LabelField("Weight",GUILayout.Width(45)); p.Weight = EditorGUILayout.FloatField(p.Weight,GUILayout.MaxWidth(30)); if (GUILayout.Button ("-",GUILayout.Width(30))) toRemove = p; EditorGUILayout.EndHorizontal (); } if (toRemove != null) shot.Properties.Remove(toRemove); EditorGUILayout.BeginHorizontal (); if (GUILayout.Button ("Add")) { switch (propertyToAdd) { case Property.Type.PositionOnScreen: shot.Properties.Add (new PositionOnScreen (targetSubject, 0.5f, 0.5f, 1)); break; case Property.Type.ProjectionSize: shot.Properties.Add (new ProjectionSize (targetSubject, 1, 1)); break; case Property.Type.VantageAngle: shot.Properties.Add (new VantageAngle (targetSubject, 0, 0, 1)); break; case Property.Type.RelativePosition: shot.Properties.Add (new RelativePosition (targetSubject, RelativePosition.Position.InFrontOf, secondaryTarget, 1)); break; } } Property.Type tmp = (Property.Type)EditorGUILayout.EnumPopup (propertyToAdd); if (tmp != Property.Type.RelativePosition || shot.NumberOfActors > 1) propertyToAdd = tmp; string[] options = new string[shot.NumberOfActors]; for (int i=0; i<options.Length; i++) options [i] = "Actor " + i.ToString (); if (targetSubject > options.Length - 1) targetSubject--; targetSubject = EditorGUILayout.Popup (targetSubject, options); if (propertyToAdd == Property.Type.RelativePosition) secondaryTarget = EditorGUILayout.Popup (secondaryTarget, options); EditorGUILayout.EndHorizontal (); } EditorUtility.SetDirty (shot); }