public void DynamicTexture_Free(Component_Image texture) { var item = dynamicTexturesAllocated.Find(i => i.image == texture); //RenderTargetItem item = null; //foreach( var i in renderTargetsAllocated ) //{ // if( i.target == renderTarget ) // { // item = i; // break; // } //} ////can be created for MRT. such render targets can't free. //if( item == null ) // return; if (item == null) { Log.Fatal("ViewportRenderingContext: DynamicTexture_Free: Dynamic texture is not allocated."); } if (dynamicTexturesFree.Contains(item)) { Log.Fatal("ViewportRenderingContext: DynamicTexture_Free: Dynamic texture is already free."); } dynamicTexturesFree.Add(item); }
static void CheckMissingSummaries() { //ESet<string> toSkip = new ESet<string>(); //toSkip.Add( "NeoAxis.Component.T property: Enabled" ); //toSkip.Add( "NeoAxis.Component.T property: Name" ); bool titleWasAdded = false; ESet <Metadata.Member> processed = new ESet <Metadata.Member>(8000); foreach (var type in MetadataManager.NetTypes.ToArray()) { if (typeof(Component).IsAssignableFrom(type.GetNetType()) && type.GetNetType().IsPublic) { Metadata.GetMembersContext context = new Metadata.GetMembersContext(); context.filter = false; foreach (var member in type.MetadataGetMembers(context)) { string missingText = null; var property = member as Metadata.Property; if (property != null && property.Browsable && !processed.Contains(property)) { processed.AddWithCheckAlreadyContained(property); var id = GetMemberId(member); if (!string.IsNullOrEmpty(id)) { if (string.IsNullOrEmpty(GetMemberSummary(id))) { var text = type.Name + " " + "property: " + member.Name; //if( !toSkip.Contains( text ) ) missingText = text; } } } //!!!!events if (missingText != null) { if (!titleWasAdded) { Log.InvisibleInfo("-----------------------------"); Log.InvisibleInfo("Missing type descriptions:"); titleWasAdded = true; } Log.InvisibleInfo(missingText); } } } } if (titleWasAdded) { Log.InvisibleInfo("-----------------------------"); } }
public void UpdateCells() { var actualControls = new ESet <Component>(Rows * Columns); //add new cells for (int nRow = 0; nRow < Rows; nRow++) { for (int nColumn = 0; nColumn < Columns; nColumn++) { var name = string.Format("Cell {0} {1}", nRow, nColumn); var control = Components.GetByName(name); if (control == null) { control = CreateComponent <UIControl>(); control.Name = name; } actualControls.Add(control); } } var toDelete = new ESet <Component>(); foreach (var c in GetCells()) { if (!actualControls.Contains(c)) { toDelete.Add(c); } } //delete old foreach (var c in toDelete) { c.RemoveFromParent(false); } if (AutoPosition) { UpdateCellsPositionAndSize(); } }
public static List <Component> GetComponentsWithoutChildren(ICollection <Component> list) { var set = new ESet <Component>(list.Count); set.AddRangeWithCheckAlreadyContained(list); var newList = new List <Component>(list.Count); foreach (var obj in list) { var allParents = obj.GetAllParents(false); if (!allParents.Any(p => set.Contains(p))) { newList.Add(obj); } } return(newList); }
internal static void LoadFileForType(Metadata.TypeInfo type) { try { var assembly = type.GetNetType().Assembly; if (assembly == null) { return; } if (parsedAssemblies.Contains(assembly)) { return; } parsedAssemblies.Add(assembly); var fileName = Path.GetFileName(assembly.Location); if (!string.IsNullOrEmpty(fileName)) { var xmlFileName = Path.ChangeExtension(fileName, ".xml"); Load(xmlFileName); } } catch { } }
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// //!!!! public static bool CanBeShaderParameter(Type type) { if (shaderParameterTypesSupported == null) { shaderParameterTypesSupported = new ESet <Type>(); shaderParameterTypesSupported.Add(typeof(bool)); shaderParameterTypesSupported.Add(typeof(sbyte)); shaderParameterTypesSupported.Add(typeof(byte)); shaderParameterTypesSupported.Add(typeof(char)); shaderParameterTypesSupported.Add(typeof(short)); shaderParameterTypesSupported.Add(typeof(ushort)); shaderParameterTypesSupported.Add(typeof(int)); shaderParameterTypesSupported.Add(typeof(uint)); //shaderParameterTypesSupported.Add( typeof( long ) ); //shaderParameterTypesSupported.Add( typeof( ulong ) ); shaderParameterTypesSupported.Add(typeof(float)); shaderParameterTypesSupported.Add(typeof(double)); shaderParameterTypesSupported.Add(typeof(Vector2F)); shaderParameterTypesSupported.Add(typeof(RangeF)); shaderParameterTypesSupported.Add(typeof(Vector3F)); shaderParameterTypesSupported.Add(typeof(Vector4F)); //shaderParameterTypesSupported.Add( typeof( BoundsF ) ); shaderParameterTypesSupported.Add(typeof(QuaternionF)); shaderParameterTypesSupported.Add(typeof(ColorValue)); shaderParameterTypesSupported.Add(typeof(ColorValuePowered)); shaderParameterTypesSupported.Add(typeof(SphericalDirectionF)); shaderParameterTypesSupported.Add(typeof(Vector2I)); shaderParameterTypesSupported.Add(typeof(Vector3I)); shaderParameterTypesSupported.Add(typeof(Vector4I)); shaderParameterTypesSupported.Add(typeof(RectangleF)); shaderParameterTypesSupported.Add(typeof(RectangleI)); shaderParameterTypesSupported.Add(typeof(DegreeF)); shaderParameterTypesSupported.Add(typeof(RadianF)); shaderParameterTypesSupported.Add(typeof(Vector2)); shaderParameterTypesSupported.Add(typeof(Range)); shaderParameterTypesSupported.Add(typeof(RangeI)); shaderParameterTypesSupported.Add(typeof(Vector3)); shaderParameterTypesSupported.Add(typeof(Vector4)); //shaderParameterTypesSupported.Add( typeof( Bounds ) ); shaderParameterTypesSupported.Add(typeof(Quaternion)); shaderParameterTypesSupported.Add(typeof(SphericalDirection)); shaderParameterTypesSupported.Add(typeof(Rectangle)); shaderParameterTypesSupported.Add(typeof(Degree)); shaderParameterTypesSupported.Add(typeof(Radian)); shaderParameterTypesSupported.Add(typeof(AnglesF)); shaderParameterTypesSupported.Add(typeof(Angles)); shaderParameterTypesSupported.Add(typeof(Matrix2F)); shaderParameterTypesSupported.Add(typeof(Matrix2)); shaderParameterTypesSupported.Add(typeof(Matrix3F)); shaderParameterTypesSupported.Add(typeof(Matrix3)); shaderParameterTypesSupported.Add(typeof(Matrix4F)); shaderParameterTypesSupported.Add(typeof(Matrix4)); shaderParameterTypesSupported.Add(typeof(PlaneF)); shaderParameterTypesSupported.Add(typeof(Plane)); } return(shaderParameterTypesSupported.Contains(type) || typeof(Component_Image).IsAssignableFrom(type)); }
public bool BuildArchive() //string writeToDirectory ) { var destFileName = Path.Combine(writeToDirectory, GetIdentifier() + "-" + GetVersion() + ".neoaxispackage"); //check file already exists if (File.Exists(destFileName)) { var text = $"The file with name \'{destFileName}\' is already exists. Overwrite?"; if (EditorMessageBox.ShowQuestion(text, EMessageBoxButtons.OKCancel) == EDialogResult.Cancel) { return(false); } } try { var sourceDirectory = Path.GetDirectoryName(VirtualPathUtility.GetRealPathByVirtual(ComponentUtility.GetOwnedFileNameOfComponent(this))); //make zip if (File.Exists(destFileName)) { File.Delete(destFileName); } //prepare Package.info var packageInfoTempFileName = Path.GetTempFileName(); { var block = new TextBlock(); block.SetAttribute("Identifier", GetIdentifier()); block.SetAttribute("Title", Title.Value); block.SetAttribute("Version", GetVersion()); //!!!! block.SetAttribute("Author", "Share CC Attribution"); block.SetAttribute("Description", ShortDescription); //"ShortDescription" block.SetAttribute("FullDescription", FullDescription.Value); string license = ""; switch (License.Value) { case LicenseEnum.MIT: license = "MIT"; break; case LicenseEnum.CCAttribution: license = "CC Attribution"; break; case LicenseEnum.FreeToUse: license = "Free To Use"; break; case LicenseEnum.PaidPerSeat: license = "Paid Per Seat"; break; } block.SetAttribute("License", license); if (License.Value == LicenseEnum.PaidPerSeat) { block.SetAttribute("Cost", Cost.Value.ToString()); } { var s = ""; foreach (CategoryEnum flag in GetFlags(Categories.Value)) { if (flag != 0) { if (s.Length != 0) { s += ", "; } s += TypeUtility.DisplayNameAddSpaces(flag.ToString()); } } block.SetAttribute("Categories", s); } block.SetAttribute("Tags", Tags.Value); //!!!! var openAfterInstall = sourceDirectory.Substring(VirtualFileSystem.Directories.Assets.Length + 1); block.SetAttribute("OpenAfterInstall", openAfterInstall); //MustRestart = True //AddCSharpFilesToProject = "Store\\Simple Level Generator" File.WriteAllText(packageInfoTempFileName, block.DumpToString()); } string[] files; using (var archive = ZipFile.Open(destFileName, ZipArchiveMode.Create)) { files = Directory.GetFiles(sourceDirectory, "*", SearchOption.AllDirectories); foreach (var file in files) { if (Path.GetExtension(file) == ".store") { continue; } var entryName = file.Substring(VirtualFileSystem.Directories.Project.Length + 1); //var entryName = file.Substring( sourceDirectory.Length + 1 ); archive.CreateEntryFromFile(file, entryName); } archive.CreateEntryFromFile(packageInfoTempFileName, "Package.info"); } if (File.Exists(packageInfoTempFileName)) { File.Delete(packageInfoTempFileName); } //write info json { var jsonFileName = destFileName + ".json"; var sw = new StringWriter(); using (JsonWriter writer = new JsonTextWriter(sw)) { writer.Formatting = Formatting.Indented; writer.WriteStartObject(); writer.WritePropertyName("Author"); //!!!! //writer.WriteValue( "3" ); writer.WriteValue("Share CC Attribution"); writer.WritePropertyName("Identifier"); writer.WriteValue(GetIdentifier()); writer.WritePropertyName("Title"); writer.WriteValue(Title.Value); writer.WritePropertyName("License"); switch (License.Value) { case LicenseEnum.MIT: writer.WriteValue("MIT"); break; case LicenseEnum.CCAttribution: writer.WriteValue("CC Attribution"); break; case LicenseEnum.FreeToUse: writer.WriteValue("Free To Use"); break; case LicenseEnum.PaidPerSeat: writer.WriteValue("Paid Per Seat"); break; } //writer.WriteValue( License.Value.ToString() ); writer.WritePropertyName("Cost"); writer.WriteValue(Cost.Value.ToString()); writer.WritePropertyName("ShortDescription"); writer.WriteValue(ShortDescription.Value); writer.WritePropertyName("FullDescription"); writer.WriteValue(FullDescription.Value); { writer.WritePropertyName("Categories"); var s = ""; foreach (CategoryEnum flag in GetFlags(Categories.Value)) { if (flag != 0) { if (s.Length != 0) { s += ", "; } s += TypeUtility.DisplayNameAddSpaces(flag.ToString()); } } writer.WriteValue(s); //writer.WriteValue( Categories.Value.ToString() ); } writer.WritePropertyName("Tags"); writer.WriteValue(Tags.Value); writer.WritePropertyName("Version"); writer.WriteValue(GetVersion()); //writer.WriteEnd(); writer.WriteEndObject(); } File.WriteAllText(jsonFileName, sw.ToString()); } //try to create screenshots if (CreateScreenshots) { //find in the folder one import file (FBX, etc). make screenshot of 'Mesh' object inside the import file. var resourceType = ResourceManager.GetTypeByName("Import 3D"); var importExtensions = new ESet <string>(); foreach (var e in resourceType.FileExtensions) { importExtensions.AddWithCheckAlreadyContained("." + e); } var importVirtualFileNames = new List <string>(); foreach (var file in files) { var ext = Path.GetExtension(file); if (!string.IsNullOrEmpty(ext) && importExtensions.Contains(ext)) { var virtualFileName = VirtualPathUtility.GetVirtualPathByReal(file); if (!string.IsNullOrEmpty(virtualFileName)) { importVirtualFileNames.Add(virtualFileName); } } } if (importVirtualFileNames.Count == 1) { var import3D = ResourceManager.LoadResource <Component_Import3D>(importVirtualFileNames[0]); if (import3D != null) { var mesh = import3D.GetComponent <Component_Mesh>("Mesh"); if (mesh != null) { var generator = new MeshImageGenerator(); generator.Generate(mesh, destFileName + ".logo.png"); } } } } } catch (Exception e) { EditorMessageBox.ShowWarning(e.Message); return(false); } return(true); }
public static RegisteredAssemblyItem RegisterAssembly(Assembly assembly, string registerTypeNamesWithIncludedAssemblyName) { lock ( registeredAssemblies ) { RegisteredAssemblyItem item2 = GetRegisteredAssembly(assembly); if (item2 != null) { return(item2); } if (disableAssemblyRegistration == null) { ParseDisableAssemblyNamespaceRegistration(); } RegisteredAssemblyItem item = new RegisteredAssemblyItem(); item.assembly = assembly; item.registerTypeNamesWithIncludedAssemblyName = registerTypeNamesWithIncludedAssemblyName; registeredAssemblies.Add(assembly, item); string name = assembly.GetName().Name; if (name.EndsWith(".STUB")) { name = name.Replace(".STUB", ""); } bool enabled = !disableAssemblyRegistration.Contains(name); Log.InvisibleInfo("Register assembly: {0}{1}", (enabled ? "" : "[DISABLED] "), assembly.FullName); //Log.InvisibleInfo( "AssemblyUtils: RegisterAssembly: {0} {1}", ( enabled ? "" : "[DISABLED]" ), assembly.FullName ); //Log.InvisibleInfo( "AssemblyUtils: RegisterAssembly: [{0}] {1}", ( enabled ? "ENABLED" : "DISABLED" ), assembly.FullName ); if (enabled) { StartupTiming.CounterStart("Register assembly \'" + name + "\'"); try { var types = assembly.GetExportedTypes(); //optimization var isBaseNetAssembly = assembly == typeof(string).Assembly || assembly == typeof(Uri).Assembly; MetadataManager.RegisterTypesOfAssembly(assembly, types); if (!isBaseNetAssembly) { //Android: 8 seconds. MetadataManager.RegisterAutoConvertItemsForAssembly(assembly, types); MetadataManager.RegisterExtensions(assembly, types); //invoke AssemblyRegistration classes foreach (Type type in types) { if (!type.IsAbstract && typeof(AssemblyRegistration).IsAssignableFrom(type)) { ConstructorInfo constructor = type.GetConstructor(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, new Type[0] { }, null); AssemblyRegistration ins = (AssemblyRegistration)constructor.Invoke(new object[0]); item.registrationObjects.Add(ins); ins.OnRegister(); } } } if (EngineApp.ApplicationType == EngineApp.ApplicationTypeEnum.Editor) { EditorUtility.RegisterEditorExtensions(assembly); ResourcesWindowItems.RegisterAssembly(assembly); } RegisterAssemblyEvent?.Invoke(assembly); } catch (Exception e) { Log.Error("Unable to register assembly \'" + name + "\'. " + e.Message); } finally { StartupTiming.CounterEnd("Register assembly \'" + name + "\'"); } } return(item); } }
public bool DoUpdate(ReimportSettings reimportSettings, out string error) { try { insideDoUpdate = true; if (reimportSettings == null) { reimportSettings = new ReimportSettings(); } error = ""; //bool createDocumentConfig = Components.Count == 0; //disable _Import3D bool wasEnabled = Enabled; Enabled = false; try { var settings = new ImportGeneral.Settings(); settings.updateMaterials = reimportSettings.UpdateMaterials; settings.updateMeshes = reimportSettings.UpdateMeshes; settings.updateObjectsInSpace = reimportSettings.UpdateObjectsInSpace; //remove old objects if (settings.updateObjectsInSpace) { var c = GetComponent("Object In Space"); if (c != null) { RemoveComponent(c, false); } c = GetComponent("Objects In Space"); if (c != null) { RemoveComponent(c, false); } } if (settings.updateMeshes) { var c = GetComponent("Mesh"); if (c != null) { RemoveComponent(c, false); } c = GetComponent("Meshes"); if (c != null) { RemoveComponent(c, false); } } if (settings.updateMaterials) { var c = GetComponent("Material"); if (c != null) { RemoveComponent(c, false); } c = GetComponent("Materials"); if (c != null) { RemoveComponent(c, false); } } if (Parent != null || ParentRoot.HierarchyController == null || ParentRoot.HierarchyController.CreatedByResource == null || !ParentRoot.HierarchyController.CreatedByResource.Owner.LoadFromFile) { error = "This component must be root of the resource."; return(false); } var virtualFileName = ParentRoot.HierarchyController.CreatedByResource.Owner.Name; settings.component = this; settings.virtualFileName = virtualFileName; if (Path.GetExtension(virtualFileName).ToLower() == ".json") { //Quixel Megascans ImportMegascans.DoImport(settings, out error); if (!string.IsNullOrEmpty(error)) { return(false); } } else if (Path.GetExtension(virtualFileName).ToLower() == ".fbx") { //FBX //settings.loadAnimations = true; //!!!!to options? settings.frameStep = .25; Import.FBX.ImportFBX.DoImport(settings, out error); if (!string.IsNullOrEmpty(error)) { return(false); } } else { //Assimp //settings.loadAnimations = false; ImportAssimp.DoImport(settings, out error); if (!string.IsNullOrEmpty(error)) { return(false); } } UpdatePostProcess?.Invoke(this, settings); //DeleteUnusedMaterials if (settings.updateMaterials && DeleteUnusedMaterials && !settings.disableDeletionUnusedMaterials) { var usedMaterials = new ESet <Component_Material>(); foreach (var meshGeometry in GetComponents <Component_MeshGeometry>(false, true)) { var material = meshGeometry.Material.Value; if (material != null) { usedMaterials.AddWithCheckAlreadyContained(material); } } again: foreach (var material in GetComponents <Component_Material>(false, true)) { if (!usedMaterials.Contains(material)) { material.RemoveFromParent(false); material.Dispose(); goto again; } } } } finally { //enable _Import3D if (wasEnabled) { Enabled = true; } } //set EditorDocumentConfiguration //if( createDocumentConfig ) { //!!!!что еще при Mode = Scene var toSelect = new List <Component>(); //root object toSelect.Add(this); //mesh var mesh = GetComponent("Mesh") as Component_Mesh; if (mesh != null) { toSelect.Add(mesh); } //materials var materials = GetComponents <Component_Material>(false, true); if (materials.Length <= 4) { foreach (var material in materials) { var graph = material.GetComponent <Component_FlowGraph>(); if (graph != null && graph.TypeSettingsIsPublic()) { toSelect.Add(graph); } } } //select window with mesh or select window with root object var selectObject = mesh != null ? (Component)mesh : this; EditorDocumentConfiguration = KryptonConfigGenerator.CreateEditorDocumentXmlConfiguration(toSelect, selectObject); //update windows //!!!!какие-то еще проверки? if (EngineApp.ApplicationType == EngineApp.ApplicationTypeEnum.Editor) { var document = EditorAPI.GetDocumentByObject(this); if (document != null) { ////close old windows //EditorAPI.CloseAllDocumentWindowsOnSecondLevel( document ); //open windows foreach (var obj in toSelect) { if (obj != this) { EditorAPI.OpenDocumentWindowForObject(document, obj); } } //delete old windows EditorAPI.CloseAllDocumentWindowsOnSecondLevelWithDeletedObjects(document); //select window var windows = EditorAPI.FindDocumentWindowsWithObject(selectObject); if (windows.Count != 0) { EditorAPI.SelectDockWindow(windows[0]); } } //!!!!or restore window configuration from EditorDocumentConfiguration } } } finally { insideDoUpdate = false; } return(true); }
// public static void Load(string xmlFile) { if (triedLoadFiles.Contains(xmlFile)) { return; } triedLoadFiles.Add(xmlFile); var path = Path.Combine(VirtualFileSystem.Directories.Binaries, xmlFile); if (File.Exists(path)) { try { var document = new XmlDocument(); document.Load(path); foreach (XmlNode docNode in document.SelectNodes("doc")) { foreach (XmlNode membersNode in docNode.SelectNodes("members")) { foreach (XmlNode childNode in membersNode.ChildNodes) { if (childNode.Name == "member") { var name = childNode.Attributes["name"].Value; XmlNode summaryNode = null; try { summaryNode = childNode.SelectSingleNode("summary"); } catch { } if (summaryNode != null) { string summary = null; if (summaryNode.InnerText != null) { //Occurs when the < see cref = "P:NeoAxis.Component.Enabled" /> property value changes. summary = summaryNode.InnerXml.Trim(); //remove <see> tags try { do { var startIndex = summary.IndexOf("<see "); if (startIndex == -1) { break; } { int endIndex = summary.IndexOf("/>", startIndex + 1); if (endIndex != -1) { var str = summary.Substring(startIndex, endIndex - startIndex + 2); var v1 = str.LastIndexOf('.'); var v2 = str.LastIndexOf('"'); if (v1 == -1 || v2 == -1) { break; } var newStr = str.Substring(v1 + 1, v2 - v1 - 1); newStr = TypeUtility.DisplayNameAddSpaces(newStr); summary = summary.Replace(str, newStr); continue; } } { int endIndex = summary.IndexOf(">", startIndex + 1); int endIndex2 = summary.IndexOf("</see>", startIndex + 1); if (endIndex != -1 && endIndex2 != -1) { var s = summary; summary = s.Substring(0, startIndex) + s.Substring(endIndex + 1, endIndex2 - endIndex - 1) + s.Substring(endIndex2 + "</see>".Length); continue; } } break; } while(true); } catch { } //summary = summaryNode.InnerText.Trim(); } if (!string.IsNullOrEmpty(summary)) { memberSummaries[name] = summary; } } } } } } } catch (Exception e) { Log.Warning("XmlDocumentationData: Load: Unable to parse file \'{0}\'. Error: \'{1}\'", path, e.Message); } } }
static bool UpdateProjectFile_ManualParser(ICollection <string> addFiles, ICollection <string> removeFiles, out bool wasUpdated, out string error) { wasUpdated = false; error = ""; try { var xmldoc = new XmlDocument(); xmldoc.Load(GetProjectFileName()); if (removeFiles != null) { var removeFilesSet = new ESet <string>(); foreach (var fileName in removeFiles) { var fixedPath = fileName; if (Path.IsPathRooted(fixedPath)) { fixedPath = fixedPath.Replace(ProjectDir + Path.DirectorySeparatorChar, ""); } removeFilesSet.AddWithCheckAlreadyContained(fixedPath); } var nodesToRemove = new List <XmlNode>(); var list = xmldoc.SelectNodes("//Compile"); foreach (XmlNode node in list) { var name = node.Attributes["Include"].Value; if (removeFilesSet.Contains(name)) { nodesToRemove.Add(node); wasUpdated = true; } } foreach (var node in nodesToRemove.GetReverse()) { node.ParentNode.RemoveChild(node); } } if (addFiles != null) { XmlNode itemGroupNode = null; { var list = xmldoc.SelectNodes("//Compile"); foreach (XmlNode node in list) { itemGroupNode = node.ParentNode; break; } } if (itemGroupNode == null) { XmlNode projectNode = null; { var list = xmldoc.SelectNodes("//Project"); foreach (XmlNode node in list) { projectNode = node; break; } } if (projectNode == null) { throw new Exception("Project node not found."); } itemGroupNode = xmldoc.CreateNode(XmlNodeType.Element, "ItemGroup", null); projectNode.AppendChild(itemGroupNode); } foreach (var fileName in addFiles) { var fixedPath = fileName; if (Path.IsPathRooted(fixedPath)) { fixedPath = fixedPath.Replace(ProjectDir + Path.DirectorySeparatorChar, ""); } var node = xmldoc.CreateNode(XmlNodeType.Element, "Compile", null); var includeAttribute = xmldoc.CreateAttribute("Include"); includeAttribute.Value = fixedPath; node.Attributes.Append(includeAttribute); itemGroupNode.AppendChild(node); wasUpdated = true; } } if (wasUpdated) { xmldoc.Save(GetProjectFileName()); } } catch (Exception e) { error = e.Message; return(false); } return(true); }