// Constructs a reflected ES3Type, only serializing members which are in the provided members array. public ES3ReflectedType(Type type, string[] members) { this.type = type; this.isValueType = ES3Reflection.IsValueType(type); isReflectedType = true; GetMembers(false, members); }
protected ES3Type(Type type) { ES3TypeMgr.Add(type, this); this.type = type; this.isValueType = ES3Reflection.IsValueType(type); }
private void Generate() { var type = types[selectedType].type; if (type == null) { EditorUtility.DisplayDialog("Type not selected", "Type not selected. Please ensure you select a type", "Ok"); return; } // Get the serializable fields of this class. //var fields = ES3Reflection.GetSerializableES3Fields(type); // The string that we suffix to the class name. i.e. UnityEngine_UnityEngine_Transform. string es3TypeSuffix = type.Name; // The string for the full C#-safe type name. This name must be suitable for going inside typeof(). string fullType = GetFullTypeName(type); // The list of WriteProperty calls to write the properties of this type. string writes = GenerateWrites(); // The list of case statements and Read calls to read the properties of this type. string reads = GenerateReads(); // A comma-seperated string of fields we've supported in this type. string propertyNames = ""; bool first = true; for (int i = 0; i < fields.Length; i++) { if (!fieldSelected[i]) { continue; } if (first) { first = false; } else { propertyNames += ", "; } propertyNames += "\"" + fields[i].Name + "\""; } var easySaveEditorPath = ES3EditorUtility.PathToEasySaveFolder() + "Editor/"; // Insert the relevant strings into the template. string template; if (typeof(Component).IsAssignableFrom(type)) { template = File.ReadAllText(easySaveEditorPath + componentTemplateFile); } else if (ES3Reflection.IsValueType(type)) { template = File.ReadAllText(easySaveEditorPath + valueTemplateFile); } else { template = File.ReadAllText(easySaveEditorPath + classTemplateFile); } template = template.Replace("[es3TypeSuffix]", es3TypeSuffix); template = template.Replace("[fullType]", fullType); template = template.Replace("[writes]", writes); template = template.Replace("[reads]", reads); template = template.Replace("[propertyNames]", propertyNames); // Create the output file. string outputFilePath = GetOutputPath(type); var fileInfo = new FileInfo(outputFilePath); fileInfo.Directory.Create(); File.WriteAllText(outputFilePath, template); AssetDatabase.Refresh(); }
protected ES3Type(Type type) { this.type = type; this.isValueType = ES3Reflection.IsValueType(type); }
public ES3ReflectedType(Type type) { this.type = type; this.isValueType = ES3Reflection.IsValueType(type); isReflectedType = true; }