public void OnFileSelectionClicked() { string[] extensions = { "All PiXYZ files", "pxz,fbx,igs,iges,stp,step,stpz,stepz,ifc,u3d,CATProduct,CATPart,cgr,CATShape,model,session,sldasm,sldprt,prt,asm*,prt*,neu,neu*,xas,xas*,xpr,xpr*,asm,par,pwd,psm,ipt,iam,ipj,sat,sab," /* ptx,xyz,*/ + " vda,3dm,3dxml,wrl,vrml,dae,stl," /* e57,pts,*/ + " jt,x_t,x_b,p_t,p_b,xmt,xmt_txt,xmt_bin,plmxml,obj,csb,wire,skp,pdf,prc,3ds,dwg,dxf", "FBX files", "fbx", "IGES files", "igs,iges", "STEP files", "stp,step,stepz", "IFC files", "ifc", "U3D files", "u3d", "CATIA files", "CATProduct,CATPart,cgr,CATShape", "SolidWorks files", "sldasm,sldprt", "Creo files", "prt,asm*,prt*,neu,neu*,xas,xas*,xpr,xpr*", "SolidEdge", "asm,par,pwd,psm", "ACIS SAT files", "sat,sab", "VDA-FS files", "vda", "Rhino files", "3dm", "3dxml files", "3dxml", "VRML files", "wrl,vrml", "COLLADA files", "dae", "Stereolithography files", "stl", "JT files", "jt", "Parasolid files", "x_t,x_b,p_t,p_b,xmt,xmt_txt,xmt_bin", "PLMXML files", "plmxml", "OBJ files", "obj", "CSB files", "csb", "Alias files", "wire", "Sketchup files", "skp", "Pdf files", "pdf", "Prc files", "prc", "3DS files", "3ds", "AutoCAD files", "dwg,dxf" }; try { PiXYZ4UnityWrapper.initialize(); } catch (Exception) { if (EditorUtility.DisplayDialog("Invalid license", "Your license is inexistant or invalid.", "Open license manager", "Close")) { PiXYZLicenseManager.Init(); } return; } string file = EditorUtility.OpenFilePanelWithFilters("Select File", "", extensions); if (file.Length != 0) { isFileNameValid = true; selectedFile = file; } else if (selectedFile.Length == 0) { isFileNameValid = false; } if (EditorPrefs.GetBool("PiXYZ.AutoUpdate", true)) { PiXYZUpdate.checkForUpdate(pixyzImport: this); } }
public bool loadFile(string filePath, bool editor, UnityEngine.Object prefab) { if (editor) { loadedObject.Clear(); } m_PartsCount = 0; m_PolyCount = 0; progressStatus = "Initializing PiXYZ"; progress = 0.0f; try { errorMsg = ""; PiXYZ4UnityWrapper.setResourcesFolder(Application.dataPath + "\\PiXYZ\\Resources\\"); PiXYZ4UnityWrapper.initialize(); progressStatus = "Importing file in PiXYZ"; progress += 0.05f; int assembly = -1; m_PartsToLoadCount = PiXYZ4UnityWrapper.importFile(filePath, out assembly); progress = 0.5f; materials = new Dictionary <int, Material>(); PiXYZ4UnityWrapper.ScenePath root = null; if (assembly > 0) { int[] path = new int[2]; path[0] = PiXYZ4UnityWrapper.getSceneRoot(); path[1] = assembly; root = new PiXYZ4UnityWrapper.ScenePath(path); } else { root = new PiXYZ4UnityWrapper.ScenePath(PiXYZ4UnityWrapper.getSceneRoot()); } progressStatus = "Importing into Unity"; //PiXYZ4UnityWrapper.removeSymmetryMatrices(root.node()); //used to fix odd negative scale Dictionary <int, List <Renderer> > renderers = new Dictionary <int, List <Renderer> >(); Dictionary <int, double> lodToThreshold = new Dictionary <int, double>(); loadSubTree(null, root, 0, editor, prefab, false, -1, ref renderers, ref lodToThreshold); progress = 1.0f; progressStatus = "Finalizing"; } catch (Exception e) { PiXYZ4UnityWrapper.clear(); Debug.LogException(e); return(false); } PiXYZ4UnityWrapper.clear(); return(true); }
public IEnumerator loadFileRuntime(GameObject rootObject, string filePath, bool editor, UnityEngine.Object prefab) { if (editor) { loadedObject.Clear(); } int assembly = -1; PiXYZ4UnityWrapper.setResourcesFolder(Application.dataPath + "/PiXYZ/Resources/"); Thread _thread = new Thread(() => importThread(filePath, out assembly)); m_PartsCount = 0; m_PolyCount = 0; _thread.Start(); while (_thread.IsAlive) { progress = progress >= 0.05f ? 0.05f + (float)(PiXYZ4UnityWrapper.getProgress() * 0.45f) : progress; progressStatus = PiXYZ4UnityWrapper.getProgressStatus(); yield return(null); } if (getErrorMessage() != "") { yield break; } materials = new Dictionary <int, Material>(); PiXYZ4UnityWrapper.ScenePath root = null; if (assembly > 0) { int[] path = new int[2]; path[0] = PiXYZ4UnityWrapper.getSceneRoot(); path[1] = assembly; root = new PiXYZ4UnityWrapper.ScenePath(path); } else { root = new PiXYZ4UnityWrapper.ScenePath(PiXYZ4UnityWrapper.getSceneRoot()); } //PiXYZ4UnityWrapper.removeSymmetryMatrices(root.node()); //used to fix odd negative scale Dictionary <int, List <Renderer> > renderers = new Dictionary <int, List <Renderer> >(); Dictionary <int, double> lodToThreshold = new Dictionary <int, double>(); loadSubTree(null, root, 0, editor, prefab, false, -1, ref renderers, ref lodToThreshold); foreach (KeyValuePair <int, Material> kvpair in PiXYZ4UnityWrapper.getCreatedMaterials()) { if (!materials.ContainsKey(kvpair.Key)) { materials.Add(kvpair.Key, kvpair.Value); } } PiXYZ4UnityWrapper.clear(); }
void OnGUI() { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(GUILayout.Height(Screen.width - 40)); EditorGUILayout.LabelField(""); EditorGUILayout.EndVertical(); Rect rectangle = GUILayoutUtility.GetLastRect(); EditorGUILayout.EndHorizontal(); { rectangle.y = (rectangle.height - rectangle.width) / 2; rectangle.height = rectangle.width; GUI.DrawTexture(rectangle, Resources.Load("Icon/pixyz_banner", typeof(Texture2D)) as Texture2D); //PiXYZUtils.drawGroupBox(rectangle, "test"); } showLicenseInfos(false); GUILayout.FlexibleSpace(); EditorGUILayout.BeginVertical(); { GUIStyle centeredBold = new GUIStyle(EditorStyles.boldLabel); centeredBold.alignment = TextAnchor.UpperCenter; EditorGUILayout.LabelField("Plugin version: " + PiXYZ4UnityWrapper.getVersion(), centeredBold); } { GUIStyle boldRich = new GUIStyle(EditorStyles.boldLabel); boldRich.alignment = TextAnchor.MiddleCenter; boldRich.normal.textColor = Color.blue; //GUI.Label(new Rect(0, Screen.height * 3 / 4 - 10, Screen.width, Screen.height / 4), "Click to see Terms & Conditions", boldRich); string str = "Click to see Terms & Conditions"; TextGenerationSettings settings = new TextGenerationSettings(); settings.fontSize = boldRich.fontSize; settings.fontStyle = boldRich.fontStyle; settings.font = boldRich.font; settings.color = boldRich.normal.textColor; settings.pivot = Vector2.zero; if (GUILayout.Button(str, boldRich)) { Application.OpenURL("https://www.pixyz-software.com/general-and-products-terms-and-conditions/"); } TextGenerator a = new TextGenerator(); Rect buttonRect = GUILayoutUtility.GetLastRect(); EditorGUIUtility.AddCursorRect(buttonRect, MouseCursor.Link); Rect underlineRect = new Rect(buttonRect); underlineRect.width = a.GetPreferredWidth(str, settings); underlineRect.x = Screen.width / 2 - underlineRect.width / 2; underlineRect.y += underlineRect.height - 2; underlineRect.height = 1; PiXYZUtils.GUIDrawRect(underlineRect, Color.blue); } { GUIStyle italic = new GUIStyle(); italic.fontStyle = FontStyle.Italic; italic.alignment = TextAnchor.MiddleCenter; italic.fontSize = 10; italic.wordWrap = true; EditorGUILayout.LabelField("PiXYZ Software solutions are edited by Metaverse Technologies France", italic); } EditorGUILayout.EndVertical(); }
void OnDestroy() { try { PiXYZ4UnityWrapper.clear(); } catch (Exception) { } }
//!isPart && !isAssembly => Light or camera bool isAssembly(int node) { if (PiXYZ4UnityWrapper.getSceneNodeType(node) != PiXYZ4UnityWrapper.SceneNodeType.COMPONENT) { return(true); } return(PiXYZ4UnityWrapper.getComponentType(node) == PiXYZ4UnityWrapper.ComponentType.ASSEMBLY); }
bool isPart(int node) { if (PiXYZ4UnityWrapper.getSceneNodeType(node) != PiXYZ4UnityWrapper.SceneNodeType.COMPONENT) { return(false); } return(PiXYZ4UnityWrapper.getComponentType(node) == PiXYZ4UnityWrapper.ComponentType.PART); }
void licenseServer() { float spacing = position.height * 0.15f; string savedAddress = ""; int savedPort = 0; GUIStyle sheetStyle = new GUIStyle(); sheetStyle.margin.right = 5; PiXYZ4UnityWrapper.getLicenseServer(out savedAddress, out savedPort); if (address == "") { address = savedAddress; } if (port == 0) { port = savedPort; } GUILayout.BeginArea(new Rect(position.width * 0.1f, position.height * 0.20f, position.width * 0.80f, position.height * 0.70f), sheetStyle); { GUILayout.BeginVertical(); { GUIStyle buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.margin.right = 5; GUILayout.FlexibleSpace(); GUILayout.Label("Address"); address = GUILayout.TextField(address); GUILayout.Space(spacing); GUILayout.Label("Port"); var newPort = GUILayout.TextField(port.ToString()); int temp; if (int.TryParse(newPort, out temp)) { port = Math.Max(0, temp); } GUILayout.FlexibleSpace(); GUI.enabled = (address != savedAddress) || (port != savedPort); if (GUILayout.Button("Apply", buttonStyle)) { if (PiXYZ4UnityWrapper.configureLicenseServer(address, port)) { EditorUtility.DisplayDialog("Success", "License server has been successfuly configured", "Ok"); } else { EditorUtility.DisplayDialog("License server error", PiXYZ4UnityWrapper.getLastError(), "Ok"); } } GUI.enabled = true; GUILayout.FlexibleSpace(); } GUILayout.EndVertical(); } GUILayout.EndArea(); }
public static void Display() { PiXYZAboutMenu window = (PiXYZAboutMenu)EditorWindow.GetWindow(typeof(PiXYZAboutMenu), true, "About PiXYZ PLUGIN for Unity"); window.position = new Rect((Screen.currentResolution.width - window.position.width) / 2, (Screen.currentResolution.height - window.position.height) / 2, 430.0f, 600.0f); window.maxSize = new Vector2(window.position.width, window.position.height); window.minSize = new Vector2(window.position.width, window.position.height); window.Show(); PiXYZ4UnityWrapper.initialize(); }
public static void Init() { PiXYZLicenseManager window = (PiXYZLicenseManager)EditorWindow.GetWindow(typeof(PiXYZLicenseManager), true, "PiXYZ License manager"); window.position = new Rect(10000.0f, 0, 450.0f, 300.0f); //out of screen right window.maxSize = new Vector2(window.position.width, window.position.height); window.minSize = new Vector2(window.position.width, window.position.height); window.CenterOnMainWin(); window.Show(); try { PiXYZ4UnityWrapper.initialize(); } catch (Exception) {} }
public bool CheckLicense() { try { PiXYZ4UnityWrapper.initialize(); } catch (Exception) { Debug.Log("License not found"); return(false); } PiXYZ4UnityWrapper.clear(); return(true); }
public static void OpenTutorialPDF() { if (Application.internetReachability == NetworkReachability.NotReachable) { Application.OpenURL(Application.dataPath + "/PiXYZ/Resources/[DOC]-PiXYZ-PLUGIN-for-Unity_2018_1.pdf"); string text = "A PDF documentation will be open because you are currently offline (no internet connection). If you wish to access an up-to-date online documentation, please connect here: https://pixyz-software.com/documentations/PiXYZ4Unity/ "; if (!EditorPrefs.GetBool("PiXYZ.DoNotShowAgainDocumentationPopup", false)) { EditorPrefs.SetBool("PiXYZ.DoNotShowAgainDocumentationPopup", EditorUtility.DisplayDialog("Internet not reachable", text, "Do not show again", "Ok")); } } else { Application.OpenURL(PiXYZ4UnityWrapper.getProductDocumentationURL()); } }
Material getMaterial(int id, bool editor, UnityEngine.Object prefab) { Material material; if (materials.TryGetValue(id, out material)) { return(material); } bool cloned; material = PiXYZ4UnityWrapper.getMaterial(id, out cloned); materials.Add(id, material); //AssetDatabase.AddObjectToAsset(material, prefab); return(material); }
public static void checkForUpdate(bool automaticUpdate = true, PiXYZImportMenu pixyzImport = null) { try { _automaticUpdate = automaticUpdate; _pixyzImport = pixyzImport; updateNeeded = PiXYZ4UnityWrapper.checkForUpdate(out version, out link, automaticUpdate); if (updateNeeded) { createWindow(); } } catch (Exception e) { errorMessage = e.Message; return; } }
private void importThread(string filePath, out int assembly) { errorMsg = ""; progress = 0; progressStatus = "Initializing PiXYZ"; try { PiXYZ4UnityWrapper.initialize(); progressStatus = "Importing file in PiXYZ"; progress += 0.05f; m_PartsToLoadCount = PiXYZ4UnityWrapper.importFile(filePath, out assembly); } catch (Exception e) { assembly = -1; errorMsg = e.Message; return; } }
bool creds() { GUILayout.BeginArea(new Rect(position.width * 0.05f, position.height * 0.36f, position.width * 0.90f, position.height * 0.24f)); GUILayout.BeginHorizontal(); GUILayout.Label("Username: "******"", username, GUILayout.MaxWidth(position.width / 2)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); GUILayout.Label("Password: "******"", password, GUILayout.MaxWidth(position.width / 2)); GUILayout.EndHorizontal(); EditorGUI.BeginDisabledGroup(username.Length == 0 || password.Length == 0); if (GUILayout.Button("Connect")) { bool connected = username.Length != 0 && password.Length != 0 && PiXYZ4UnityWrapper.connectToLicenseServer(username, password); //PiXYZ4UnityWrapper.availableLicensesCount(); if (connected) { return(true); } else { m_Informations.target = true; } } EditorGUI.EndDisabledGroup(); if (EditorGUILayout.BeginFadeGroup(m_Informations.faded)) { EditorGUI.indentLevel++; GUIStyle a = new GUIStyle(); a.normal.textColor = Color.red; GUILayout.Label("Credentials error", a); EditorGUI.indentLevel--; EditorGUILayout.EndFadeGroup(); } GUILayout.EndArea(); return(false); }
void offlineTab() { float spacing = position.height * 0.15f; GUIStyle sheetStyle = new GUIStyle(); sheetStyle.margin.right = 5; GUILayout.BeginArea(new Rect(position.width * 0.1f, position.height * 0.20f, position.width * 0.80f, position.height * 0.70f), sheetStyle); GUILayout.BeginVertical(); GUIStyle buttonStyle = new GUIStyle(GUI.skin.button); buttonStyle.margin.right = 5; GUILayout.FlexibleSpace(); GUILayout.Label("Generate an activation code and upload it on PiXYZ website"); if (GUILayout.Button("Generate activation code", buttonStyle)) { var path = EditorUtility.SaveFilePanel( "Save activation code", "", "PiXYZ_activationCode.bin", "Binary file;*.bin"); if (path.Length != 0) { if (PiXYZ4UnityWrapper.generateActivationCode(path) == 0) { EditorUtility.DisplayDialog("Generation succeed", "The activation code has been successfully generated.", "Ok"); } else { EditorUtility.DisplayDialog("Generation failed", "An error occured while generating the file: " + PiXYZ4UnityWrapper.getLastError(), "Ok"); } } } GUILayout.Space(spacing); GUILayout.Label("Install a new license"); if (GUILayout.Button("Install license", buttonStyle)) { var path = EditorUtility.OpenFilePanel( "Open installation code (*.bin) or license file (*.lic)", "", "Install file;*.bin;*.lic"); if (path.Length != 0) { if (path.ToLower().EndsWith(".bin") || path.ToLower().EndsWith(".lic")) { if (PiXYZ4UnityWrapper.installActivationCode(path) == 0) { EditorUtility.DisplayDialog("Installation succeed", "The installation code has been installed.", "Ok"); } else { EditorUtility.DisplayDialog("Installation failed", "An error occured while installing: " + PiXYZ4UnityWrapper.getLastError(), "Ok"); } } else { EditorUtility.DisplayDialog("Error", "The file must be an installation code (bin file) or a license file (lic file)", "Ok"); } } } GUILayout.Space(spacing); GUILayout.Label("Generate a release code and upload it on PiXYZ website"); if (GUILayout.Button("Generate release code", buttonStyle)) { if (EditorUtility.DisplayDialog("Warning", "Release (or uninstall) current license lets you install it on another computer. This action is available only once.\n\nAre you sure you want to release this license ?", "Yes", "No")) { var path = EditorUtility.SaveFilePanel( "Save release code as BIN", "", "PiXYZ_releaseCode.bin", "Binary file;*.bin"); if (path.Length != 0) { if (PiXYZ4UnityWrapper.generateDeactivationCode(path) == 0) { EditorUtility.DisplayDialog("Generation succeed", "The release code has been successfully generated.", "Ok"); } else { EditorUtility.DisplayDialog("Generation failed", "An error occured while generating the file: " + PiXYZ4UnityWrapper.getLastError(), "Ok"); } } } } GUILayout.FlexibleSpace(); GUILayout.EndVertical(); GUILayout.EndArea(); }
void loadPart(GameObject obj, int part, int currentMaterialId, bool editor, UnityEngine.Object prefab, bool importLines, int curLOD, ref Dictionary <int, List <Renderer> > lodToRenderers) { uint tessRep = (uint)PiXYZ4UnityWrapper.getPartActiveShape(part); if (tessRep < 0) { return; } int tessellation = PiXYZ4UnityWrapper.getTessellatedShapeTessellation(tessRep); if (tessellation < 0) { errorMsg = "No tessellation found for part : " + part + "(tessellation id : " + tessellation + ")"; return; } ++m_PartsCount; progress = 0.5f + ((float)m_PartsCount / (float)m_PartsToLoadCount) * 0.5f; progressStatus = "Loading part " + m_PartsCount + "/" + m_PartsToLoadCount; obj.name = PiXYZ4UnityWrapper.getNodeName(part); if (obj.name.Length == 0) { obj.name = "Mesh"; } MeshRenderer renderer = null; List <Material> materials = null; Material material = null; Mesh mesh; bool cloned = false; try { if (currentMaterialId != 0) { material = getMaterial(currentMaterialId, editor, prefab); } if (_meshes.TryGetValue((uint)tessellation, out mesh)) { cloned = true; _meshesMaterials.TryGetValue((uint)tessellation, out materials); } else { mesh = PiXYZ4UnityWrapper.getTriangleTessellation((uint)tessellation, material == null, out materials); _meshes.Add((uint)tessellation, mesh); _meshesMaterials.Add((uint)tessellation, materials); } if (mesh != null) { mesh.name = tessRep.ToString() + "_" + tessellation.ToString(); renderer = obj.AddComponent <MeshRenderer>(); m_PolyCount += mesh.triangles.Length; if (editor) { if (materials != null) { renderer.sharedMaterials = materials.ToArray(); } else { renderer.sharedMaterial = material; } } else { if (materials != null) { renderer.materials = materials.ToArray(); } else { renderer.material = material; } } } if (renderer) { MeshFilter filter = obj.AddComponent <MeshFilter>(); if (editor) { if (!cloned) { loadedObject.Add(mesh); } filter.sharedMesh = mesh; } else { filter.mesh = mesh; } PiXYZ4UnityWrapper.afterPartUsed(part); } } catch (Exception e) { string msg = "Load part failed on part \"" + part.ToString() + "\": " + e.Message; Debug.LogError(msg); } if (curLOD >= 0 && (lodToRenderers != null)) { if (!lodToRenderers.ContainsKey(curLOD)) { lodToRenderers.Add(curLOD, new List <Renderer>()); } lodToRenderers[curLOD].Add(renderer); } }
void loadSubTree(GameObject parent, PiXYZ4UnityWrapper.ScenePath subTree, int currentMateriaId, bool editor, UnityEngine.Object prefab, bool importLines, int curLOD, ref Dictionary <int, List <Renderer> > lodToRenderers, ref Dictionary <int, double> lodToThreshold, bool isMaterialOverride = false) { if (!isPart(subTree.node()) && !isAssembly(subTree.node()) || isHidden(subTree)) //Last part is HOOPS workaround. { return; //no light or camera } GameObject obj = new GameObject(); Transform parentTransform = parent != null ? parent.transform : null; obj.name = PiXYZ4UnityWrapper.getNodeName(subTree.node()); obj.transform.parent = parentTransform; Matrix4x4 matrix = PiXYZ4UnityWrapper.getLocalMatrix(subTree.node()); int parentInstance = subTree.parentInstance(); if (parentInstance > 0) { Matrix4x4 parentMatrix = PiXYZ4UnityWrapper.getLocalMatrix(parentInstance); matrix = parentMatrix * matrix; } SetTransformFromMatrix(obj.transform, ref matrix); if (parent == null) //apply mirror and rotation once { lastImportedObject = obj; obj.transform.localScale *= _scale; if (_mirrorX) { obj.transform.localScale = new Vector3(-obj.transform.localScale.x, obj.transform.localScale.y, obj.transform.localScale.z); } if (_rotation.eulerAngles.sqrMagnitude > 0) { obj.transform.localRotation = _rotation; } } if (!isMaterialOverride || isAssembly(subTree.node()) || currentMateriaId == 0) { int materialId = PiXYZ4UnityWrapper.getOccurrenceMaterial(subTree); if (materialId > 0) { currentMateriaId = materialId; } } int lodCount = 0; bool isLodGroup = PiXYZ4UnityWrapper.isLODGroup(subTree.node(), out lodCount); if (_lodsMode != LODsMode.NONE) { if (isLodGroup) { lodToRenderers.Clear(); lodToThreshold.Clear(); } if (PiXYZ4UnityWrapper.isLOD(subTree.node())) { double threshold; curLOD = PiXYZ4UnityWrapper.getLODNumber(subTree.node(), out threshold); if (!lodToThreshold.ContainsKey(curLOD)) { lodToThreshold.Add(curLOD, threshold); } } } if (isPart(subTree.node())) { loadPart(obj, subTree.node(), currentMateriaId, editor, prefab, importLines, curLOD, ref lodToRenderers); } else if (isAssembly(subTree.node())) { foreach (PiXYZ4UnityWrapper.ScenePath child in PiXYZ4UnityWrapper.getChildren(subTree)) { try { loadSubTree(obj, child, currentMateriaId, editor, prefab, importLines, curLOD, ref lodToRenderers, ref lodToThreshold, isMaterialOverride || isAssembly(subTree.node())); } catch (KeyNotFoundException knf) { Debug.LogError("Key not found: " + knf.ToString()); } } } if (_lodsMode != LODsMode.NONE && isLodGroup) { LOD[] lods = new LOD[lodCount]; const double e = 0.00001; double minThreshold = 1; for (int iLOD = 0; iLOD < lodCount; ++iLOD) { double threshold = Math.Min(lodToThreshold[iLOD], minThreshold); if (!lodToRenderers.ContainsKey(iLOD)) { Debug.LogError("Key '" + iLOD + "' not found."); continue; } Renderer[] renderers = new Renderer[lodToRenderers[iLOD].Count]; for (int iRenderer = 0; iRenderer < lodToRenderers[iLOD].Count; ++iRenderer) { renderers[iRenderer] = lodToRenderers[iLOD][iRenderer]; } lods.SetValue(new LOD((float)threshold, renderers), iLOD); minThreshold = threshold - e; } LODGroup lodGroup = obj.AddComponent <LODGroup>(); lodGroup.SetLODs(lods); lodToRenderers.Clear(); lodToThreshold.Clear(); } }
//HOOPS workaround bool isHidden(PiXYZ4UnityWrapper.ScenePath subTree) { return(PiXYZ4UnityWrapper.isHidden(subTree)); }
void OnGUI() { string[] titles = { "Current license", "Online", "Offline", "License server", "Tokens" }; selectedTab = PiXYZUtils.Tabs(titles, selectedTab); switch (selectedTab) { case 0: //current { currentLicenseTab(); break; } case 1: //online { showCredentials.target = !connected; showOnlineTab.target = connected; if (!connected) { if (EditorGUILayout.BeginFadeGroup(showCredentials.faded)) { connected = creds(); EditorGUILayout.EndFadeGroup(); } } else { if (EditorGUILayout.BeginFadeGroup(showOnlineTab.faded)) { onlineTab(); EditorGUILayout.EndFadeGroup(); } } break; } case 2: //offline { offlineTab(); break; } case 3: //server { licenseServer(); break; } case 4: //tokens { tokens(); break; } } //Outter calls if (doRelease) { doRelease = false; if (PiXYZ4UnityWrapper.releaseLicense(username, password, index)) { EditorUtility.DisplayDialog("Release complete", "The license release has been completed.", "Ok"); } else { EditorUtility.DisplayDialog("Release failed", "An error has occured while releasing the license: " + PiXYZ4UnityWrapper.getLastError(), "Ok"); PiXYZ4UnityWrapper.requestLicense(username, password, index); } } else if (doRequest) { doRequest = false; if (PiXYZ4UnityWrapper.requestLicense(username, password, index)) { EditorUtility.DisplayDialog("Installation complete", "The license installation has been completed.", "Ok"); } else { EditorUtility.DisplayDialog("Installation failed", "An error occured while installing the license: " + PiXYZ4UnityWrapper.getLastError(), "Ok"); } } }
void tokens() { bool newAllSelected = GUILayout.Toggle(allSelected, "Select all"); bool selectAll = newAllSelected && !allSelected; bool deselectAll = !newAllSelected && allSelected; allSelected = true; _scrollViewPosition = GUILayout.BeginScrollView(_scrollViewPosition, GUILayout.MaxHeight(Screen.height - 30)); { int[] tokens = PiXYZ4UnityWrapper.getTokens(); foreach (int token in tokens) { if (selectAll) { PiXYZ4UnityWrapper.addWantedToken(token); } else if (deselectAll && !PiXYZ4UnityWrapper.isMandatoryToken(token)) { PiXYZ4UnityWrapper.removeWantedToken(token); } bool required = PiXYZ4UnityWrapper.isTokenRequired(token); if (required) { var oldColor = GUI.backgroundColor; bool valid = false; if (!validToken.ContainsKey(token)) { validToken[token] = PiXYZ4UnityWrapper.isTokenValid(token); } valid = validToken[token]; GUI.backgroundColor = valid ? Color.green : Color.red; if (PiXYZ4UnityWrapper.isMandatoryToken(token)) { GUILayout.Toggle(true, PiXYZ4UnityWrapper.getTokenName(token), "Button"); } else if (!GUILayout.Toggle(true, PiXYZ4UnityWrapper.getTokenName(token), "Button")) { PiXYZ4UnityWrapper.removeWantedToken(token); allSelected = false; } GUI.backgroundColor = oldColor; } else { validToken.Remove(token); allSelected = false; PiXYZ4UnityWrapper.releaseToken(token); if (GUILayout.Toggle(false, PiXYZ4UnityWrapper.getTokenName(token), "Button")) { PiXYZ4UnityWrapper.addWantedToken(token); } } } /*GUILayout.Toggle(true, "Unity", "Button"); * for(int i = 0; i < 15; ++i) * { * var oldColor = GUI.backgroundColor; * GUI.backgroundColor = tokensSelected[i] ? (i % 7 == 0 ? Color.red : Color.green) : oldColor; * * GUIStyle style = new GUIStyle("Button"); * tokensSelected[i] = GUILayout.Toggle(tokensSelected[i], "Token " + i, "Button"); * GUI.backgroundColor = oldColor; * }*/ } GUILayout.EndScrollView(); }
public void configure(bool orient, double mapUV3dSize, TreeProcessType treeProcess, LODsMode lodsMode, List <PiXYZLODSettings> lods, bool support32BytesIndex, bool useMergeFinalAssemblies) { _lodsMode = lodsMode; PiXYZ4UnityWrapper.configure(orient, mapUV3dSize, treeProcess, lodsMode, lods, support32BytesIndex, useMergeFinalAssemblies); }
public static void showLicenseInfos(bool center = true) { EditorGUILayout.BeginVertical(); { if (center) { GUILayout.FlexibleSpace(); } if (PiXYZ4UnityWrapper.checkLicense()) { String[] names; String[] values; if (PiXYZ4UnityWrapper.isFloatingLicense()) { string server; int port; PiXYZ4UnityWrapper.getLicenseServer(out server, out port); names = new String[] { "License", "", "Server address", "Port" }; values = new String[] { "Floating", "", server, port.ToString() }; } else { names = new String[] { "Start date", "End date", "Company name", "Name", "E-mail" }; values = new String[] { PiXYZ4UnityWrapper.getCurrentLicenseStartDate(), PiXYZ4UnityWrapper.getCurrentLicenseEndDate().Length == 0 ? "Perpetual" : PiXYZ4UnityWrapper.getCurrentLicenseEndDate(), PiXYZ4UnityWrapper.getCurrentLicenseCompany(), PiXYZ4UnityWrapper.getCurrentLicenseName(), PiXYZ4UnityWrapper.getCurrentLicenseEmail(), }; } GUIStyle bold = new GUIStyle(EditorStyles.boldLabel); GUIStyle labelStyle = new GUIStyle(EditorStyles.label); labelStyle.alignment = TextAnchor.MiddleLeft; labelStyle.fontSize = 10; bold.alignment = TextAnchor.MiddleLeft; bold.fontSize = 10; PiXYZUtils.beginGroupBox("License informations"); for (int i = 0; i < names.Length; ++i) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(names[i].Length > 0 ? names[i] + ": " : "", labelStyle, GUILayout.Width((int)(Screen.width * 0.28))); EditorGUILayout.LabelField(values[i], bold); EditorGUILayout.EndHorizontal(); } PiXYZUtils.endGroupBox(); } else { GUIStyle boldRed = new GUIStyle(EditorStyles.boldLabel); boldRed.alignment = TextAnchor.MiddleCenter; boldRed.fontSize = 18; boldRed.wordWrap = true; PiXYZUtils.beginGroupBox(""); { EditorGUILayout.LabelField(""); EditorGUILayout.LabelField("Your license is inexistant or invalid.", boldRed); EditorGUILayout.LabelField(""); } PiXYZUtils.endGroupBox(); } if (center) { GUILayout.FlexibleSpace(); } } EditorGUILayout.EndVertical(); }
void onlineTab() { if (lastIndex == -1) { waitEvent = true; } if (lastOptionLength != options.Length && Event.current.type != EventType.Layout) { return; } else if (lastOptionLength != options.Length && Event.current.type == EventType.Layout) { lastOptionLength = options.Length; } GUILayout.Space(10); EditorGUILayout.LabelField("Select your license", EditorStyles.boldLabel); GUILayout.BeginHorizontal(); { EditorGUI.BeginDisabledGroup(options.Length < 1); { if (Event.current.type == EventType.Layout) //Updates on layout event { lastIndex = index; } EditorStyles.popup.richText = true; index = EditorGUILayout.Popup(index, options); EditorStyles.popup.richText = false; if (lastIndex != index) { waitEvent = true; } } EditorGUI.EndDisabledGroup(); GUILayout.Space(10); GUIStyle buttonStyle = new GUIStyle(EditorStyles.miniButton); if (GUILayout.Button("Refresh", buttonStyle, GUILayout.MaxWidth(Screen.width * 0.2f))) { PiXYZ4UnityWrapper.connectToLicenseServer(username, password); } } GUILayout.EndHorizontal(); GUILayout.Space(5); bool installed = false; if (index < options.Length) { string productName, validity, licenseUse, currentlyInstalled; int usedIndex = index; if (waitEvent) { if (Event.current.type != EventType.Layout) { usedIndex = lastIndex; } else { waitEvent = false; } } int daysRemaining = Math.Max(0, (Convert.ToDateTime(PiXYZ4UnityWrapper.licenseValidity(usedIndex)) - DateTime.Now).Days + 1); string remainingTextColor = daysRemaining > 185 ? "green" : daysRemaining > 92 ? "orange" : "red"; installed = PiXYZ4UnityWrapper.licenseOnMachine(usedIndex); productName = PiXYZ4UnityWrapper.licenseProduct(usedIndex); validity = PiXYZ4UnityWrapper.licenseValidity(usedIndex) + " (<color='" + remainingTextColor + "'><b>" + daysRemaining + "</b> Day" + (daysRemaining > 1 ? "s" : "") + " remaining</color>)"; licenseUse = "" + PiXYZ4UnityWrapper.licenseInUse(usedIndex) + " / " + PiXYZ4UnityWrapper.licenseCount(usedIndex); currentlyInstalled = installed ? "<color='green'>true</color>" : "false"; GUIStyle italic = new GUIStyle(GUI.skin.label); italic.fontStyle = FontStyle.Italic; EditorGUI.indentLevel = 1; EditorGUILayout.LabelField("License informations", italic); EditorGUI.indentLevel = 2; EditorStyles.label.richText = true; EditorGUILayout.LabelField("Product name: ", productName); EditorGUILayout.LabelField("Validity: ", validity); EditorGUILayout.LabelField("License use: ", licenseUse); EditorGUILayout.LabelField("Currently installed: ", currentlyInstalled); GUI.skin.label.richText = false; EditorGUI.indentLevel = 0; } else if (options.Length == 0) { GUIStyle labelStyle = new GUIStyle(EditorStyles.label); labelStyle.alignment = TextAnchor.MiddleCenter; labelStyle.fontStyle = FontStyle.Bold; labelStyle.normal.textColor = Color.red; GUILayout.BeginVertical(); { GUILayout.FlexibleSpace(); GUILayout.BeginHorizontal(); { GUILayout.FlexibleSpace(); GUILayout.Label("No license available in your account.", labelStyle); GUILayout.FlexibleSpace(); } GUILayout.EndHorizontal(); GUILayout.FlexibleSpace(); GUILayout.Space(30); } GUILayout.EndVertical(); } EditorGUI.BeginDisabledGroup(index >= options.Length); { GUIStyle btnContainerStyle = new GUIStyle(); btnContainerStyle.margin.right = 5; GUILayout.BeginArea(new Rect(position.width * 0.05f, position.height - 30, position.width * 0.90f, 30), btnContainerStyle); { GUILayout.BeginHorizontal(); string installName = installed ? "Reinstall" : "Install"; if (GUILayout.Button(installName)) { //Unity don't like calls to precompiled function while in layout // => delayed call to outside of layouts doRequest = true; } if (installed) { GUILayout.Space(40); if (GUILayout.Button("Release")) { if (EditorUtility.DisplayDialog("Warning", "Release (or uninstall) current license lets you install it on another computer. This action is available only once.\n\nAre you sure you want to release this license ?", "Yes", "No")) { //Unity don't like calls to precompiled function while in layout // => delayed call to outside of layouts doRelease = true; } } } GUILayout.EndHorizontal(); } GUILayout.EndArea(); } EditorGUI.EndDisabledGroup(); if (username.Length > 0 && password.Length > 0) { options = new string[PiXYZ4UnityWrapper.availableLicensesCount()]; for (int i = 0; i < PiXYZ4UnityWrapper.availableLicensesCount(); ++i) { options[i] = "License " + (i + 1) + ": " + PiXYZ4UnityWrapper.licenseProduct(i) + " [" + PiXYZ4UnityWrapper.licenseValidity(i) + "]"; if (PiXYZ4UnityWrapper.licenseOnMachine(i)) { options[i] += " (installed)"; } } } }