Esempio n. 1
0
 private void AddCreateGameObjectItemsToMenu(GenericMenu menu, UnityEngine.Object[] context, bool includeCreateEmptyChild)
 {
     string[] submenus = Unsupported.GetSubmenus("GameObject");
     string[] array    = submenus;
     for (int i = 0; i < array.Length; i++)
     {
         string text = array[i];
         UnityEngine.Object[] temporaryContext = context;
         if (includeCreateEmptyChild || !(text.ToLower() == "GameObject/Create Empty Child".ToLower()))
         {
             if (text.EndsWith("..."))
             {
                 temporaryContext = null;
             }
             if (text.ToLower() == "GameObject/Center On Children".ToLower())
             {
                 return;
             }
             MenuUtils.ExtractMenuItemWithPath(text, menu, text.Substring(11), temporaryContext);
         }
     }
 }
        private void CreateComponentTree()
        {
            GroupElement element2;

            string[]       submenus         = Unsupported.GetSubmenus("Component");
            string[]       submenusCommands = Unsupported.GetSubmenusCommands("Component");
            List <string>  list             = new List <string>();
            List <Element> list2            = new List <Element>();

            for (int i = 0; i < submenus.Length; i++)
            {
                if (submenusCommands[i] != "ADD")
                {
                    string   menuPath  = submenus[i];
                    char[]   separator = new char[] { '/' };
                    string[] strArray3 = menuPath.Split(separator);
                    while ((strArray3.Length - 1) < list.Count)
                    {
                        list.RemoveAt(list.Count - 1);
                    }
                    while ((list.Count > 0) && (strArray3[list.Count - 1] != list[list.Count - 1]))
                    {
                        list.RemoveAt(list.Count - 1);
                    }
                    while ((strArray3.Length - 1) > list.Count)
                    {
                        list2.Add(new GroupElement(list.Count, LocalizationDatabase.GetLocalizedString(strArray3[list.Count])));
                        list.Add(strArray3[list.Count]);
                    }
                    list2.Add(new ComponentElement(list.Count, LocalizationDatabase.GetLocalizedString(strArray3[strArray3.Length - 1]), menuPath, submenusCommands[i]));
                }
            }
            list2.Add(new NewScriptElement());
            this.m_Tree = list2.ToArray();
            if (this.m_Stack.Count == 0)
            {
                this.m_Stack.Add(this.m_Tree[0] as GroupElement);
                goto Label_02BE;
            }
Esempio n. 3
0
        void OnTargetedEditorConnectionChanged(EditorConnectionTarget change)
        {
            switch (change)
            {
            case EditorConnectionTarget.None:
            case EditorConnectionTarget.MainEditorProcessPlaymode:
                ProfilerDriver.profileEditor = false;
                break;

            case EditorConnectionTarget.MainEditorProcessEditmode:
                ProfilerDriver.profileEditor = true;
                break;

            default:
                ProfilerDriver.profileEditor = false;
                if (Unsupported.IsDeveloperMode())
                {
                    Debug.LogError($"{change} is not implemented!");
                }
                break;
            }
        }
Esempio n. 4
0
        private static ProcessStartInfo GetJamStartInfo(bool includeModules)
        {
            StringBuilder moduleArgs = new StringBuilder();

            moduleArgs.Append("jam.pl LiveReloadableEditorAssemblies");
            if (includeModules)
            {
                foreach (string target in ModuleManager.GetJamTargets())
                {
                    moduleArgs.Append(" ").Append(target);
                }
            }

            var psi = new ProcessStartInfo
            {
                WorkingDirectory       = Unsupported.GetBaseUnityDeveloperFolder(),
                RedirectStandardOutput = true,
                RedirectStandardError  = false,
                //The only reason jam.pl exists is that I cannot figure out how to call jam.bat, or jam.exe directly. magic.
                Arguments = moduleArgs.ToString(),
                FileName  = "perl",
            };

            var path = Environment.GetEnvironmentVariable("PATH") ?? "";

            // on macOS the typical mercurial path might not be in our environment variable, so add it for executing jam
            if (Application.platform == RuntimePlatform.OSXEditor)
            {
                var localBin = "/usr/local/bin";
                if (!path.Contains(localBin))
                {
                    path = $"{path}:{localBin}";
                }
            }
            psi.EnvironmentVariables["PATH"] = path;

            return(psi);
        }
Esempio n. 5
0
 private void DrawSpecialModeLabel()
 {
     if (Unsupported.IsBleedingEdgeBuild())
     {
         GUILayout.Space(k_SpaceBeforeProgress);
         m_SpecialModeLabel = "THIS IS AN UNTESTED BLEEDINGEDGE UNITY BUILD";
         var backup = GUI.color;
         GUI.color = Color.yellow;
         GUILayout.Label(m_SpecialModeLabel);
         GUI.color = backup;
     }
     else if (Unsupported.IsDeveloperMode())
     {
         GUILayout.Space(k_SpaceBeforeProgress);
         m_SpecialModeLabel = m_MiniMemoryOverview;
         GUILayout.Label(m_SpecialModeLabel, Styles.statusLabel);
         EditorGUIUtility.CleanCache(m_MiniMemoryOverview);
     }
     else
     {
         m_SpecialModeLabel = "";
     }
 }
        private static ProcessStartInfo GetJamStartInfo(bool includeModules)
        {
            StringBuilder moduleArgs = new StringBuilder();

            moduleArgs.Append("jam.pl LiveReloadableEditorAssemblies");
            if (includeModules)
            {
                foreach (string target in ModuleManager.GetJamTargets())
                {
                    moduleArgs.Append(" ").Append(target);
                }
            }

            return(new ProcessStartInfo
            {
                WorkingDirectory = Unsupported.GetBaseUnityDeveloperFolder(),
                RedirectStandardOutput = true,
                RedirectStandardError = false,
                //The only reason jam.pl exists is that I cannot figure out how to call jam.bat, or jam.exe directly. magic.
                Arguments = moduleArgs.ToString(),
                FileName = "perl",
            });
        }
Esempio n. 7
0
        public void Render(bool allowScriptableRenderPipeline = false, bool updatefov = true)
        {
            Light[] lights = this.lights;
            for (int i = 0; i < lights.Length; i++)
            {
                Light light = lights[i];
                light.enabled = true;
            }
            bool useScriptableRenderPipeline = Unsupported.useScriptableRenderPipeline;

            Unsupported.useScriptableRenderPipeline = allowScriptableRenderPipeline;
            float fieldOfView = this.camera.fieldOfView;

            if (updatefov)
            {
                float num = (this.m_RenderTexture.width > 0) ? Mathf.Max(1f, (float)this.m_RenderTexture.height / (float)this.m_RenderTexture.width) : 1f;
                this.camera.fieldOfView = Mathf.Atan(num * Mathf.Tan(this.camera.fieldOfView * 0.5f * 0.0174532924f)) * 57.29578f * 2f;
            }
            this.camera.Render();
            this.camera.fieldOfView = fieldOfView;
            Unsupported.useScriptableRenderPipeline = useScriptableRenderPipeline;
            Unsupported.RestoreOverrideRenderSettings();
        }
        public override void FetchData()
        {
            this.m_RootItem = new TreeViewItem(2147483647, 0, null, "Invisible Root Item");
            this.SetExpanded(this.m_RootItem, true);
            List <TreeViewItem> list            = new List <TreeViewItem>();
            int          assetsFolderInstanceID = ProjectBrowserColumnOneTreeViewDataSource.GetAssetsFolderInstanceID();
            int          num          = 0;
            string       displayName  = "Assets";
            TreeViewItem treeViewItem = new TreeViewItem(assetsFolderInstanceID, num, this.m_RootItem, displayName);

            this.ReadAssetDatabase(HierarchyType.Assets, treeViewItem, num + 1);
            TreeViewItem treeViewItem2 = null;

            if (Unsupported.IsDeveloperMode() && EditorPrefs.GetBool("ShowPackagesFolder"))
            {
                int    mainAssetOrInProgressProxyInstanceID = AssetDatabase.GetMainAssetOrInProgressProxyInstanceID(AssetDatabase.GetPackagesMountPoint());
                string packagesMountPoint = AssetDatabase.GetPackagesMountPoint();
                treeViewItem2 = new TreeViewItem(mainAssetOrInProgressProxyInstanceID, num, this.m_RootItem, packagesMountPoint);
                this.ReadAssetDatabase(HierarchyType.Packages, treeViewItem2, num + 1);
            }
            TreeViewItem treeViewItem3 = SavedSearchFilters.ConvertToTreeView();

            treeViewItem3.parent = this.m_RootItem;
            list.Add(treeViewItem3);
            list.Add(treeViewItem);
            if (treeViewItem2 != null)
            {
                list.Add(treeViewItem2);
            }
            this.m_RootItem.children = list;
            foreach (TreeViewItem current in this.m_RootItem.children)
            {
                bool @bool = EditorPrefs.GetBool(ProjectBrowserColumnOneTreeViewDataSource.kProjectBrowserString + current.displayName, true);
                this.SetExpanded(current, @bool);
            }
            this.m_NeedRefreshRows = true;
        }
Esempio n. 9
0
        public virtual void OnDisable()
        {
            AssetImporter assetImporter = base.target as AssetImporter;

            if (Unsupported.IsDestroyScriptableObject(this) && this.m_MightHaveModified && assetImporter != null && !InternalEditorUtility.ignoreInspectorChanges && this.HasModified() && !this.AssetWasUpdated())
            {
                string message = "Unapplied import settings for '" + assetImporter.assetPath + "'";
                if (base.targets.Length > 1)
                {
                    message = "Unapplied import settings for '" + base.targets.Length + "' files";
                }
                if (EditorUtility.DisplayDialog("Unapplied import settings", message, "Apply", "Revert"))
                {
                    this.Apply();
                    this.m_MightHaveModified = false;
                    AssetImporterInspector.ImportAssets(this.GetAssetPaths());
                }
            }
            if (this.m_SerializedObject != null && this.m_SerializedObject.hasModifiedProperties)
            {
                this.m_SerializedObject.Cache(base.GetInstanceID());
                this.m_SerializedObject = null;
            }
        }
 private void Init()
 {
     this.m_Object                = new SerializedObject(NavMeshBuilder.navMeshSettingsObject);
     this.m_AgentRadius           = this.m_Object.FindProperty("m_BuildSettings.agentRadius");
     this.m_AgentHeight           = this.m_Object.FindProperty("m_BuildSettings.agentHeight");
     this.m_AgentSlope            = this.m_Object.FindProperty("m_BuildSettings.agentSlope");
     this.m_LedgeDropHeight       = this.m_Object.FindProperty("m_BuildSettings.ledgeDropHeight");
     this.m_AgentClimb            = this.m_Object.FindProperty("m_BuildSettings.agentClimb");
     this.m_MaxJumpAcrossDistance = this.m_Object.FindProperty("m_BuildSettings.maxJumpAcrossDistance");
     this.m_MinRegionArea         = this.m_Object.FindProperty("m_BuildSettings.minRegionArea");
     this.m_ManualCellSize        = this.m_Object.FindProperty("m_BuildSettings.manualCellSize");
     this.m_CellSize              = this.m_Object.FindProperty("m_BuildSettings.cellSize");
     this.m_AccuratePlacement     = this.m_Object.FindProperty("m_BuildSettings.accuratePlacement");
     UnityEngine.Object serializedAssetInterfaceSingleton = Unsupported.GetSerializedAssetInterfaceSingleton("NavMeshAreas");
     this.m_NavMeshAreasObject = new SerializedObject(serializedAssetInterfaceSingleton);
     this.m_Areas = this.m_NavMeshAreasObject.FindProperty("areas");
     if (this.m_AreasList == null && this.m_NavMeshAreasObject != null && this.m_Areas != null)
     {
         this.m_AreasList = new ReorderableList(this.m_NavMeshAreasObject, this.m_Areas, false, false, false, false);
         this.m_AreasList.drawElementCallback = new ReorderableList.ElementCallbackDelegate(this.DrawAreaListElement);
         this.m_AreasList.drawHeaderCallback  = new ReorderableList.HeaderCallbackDelegate(this.DrawAreaListHeader);
         this.m_AreasList.elementHeight       = EditorGUIUtility.singleLineHeight + 2f;
     }
 }
        public void BeginStaticPreview(Rect r)
        {
            InitPreview(r);
            var color = new Color(82 / 255f, 82 / 255f, 82 / 255f, 1.0f);
            var darkGreyBackground = new Texture2D(1, 1, TextureFormat.RGBA32, true);

            darkGreyBackground.SetPixel(0, 0, color);
            darkGreyBackground.Apply();
            Graphics.DrawTexture(new Rect(0, 0, m_RenderTexture.width, m_RenderTexture.height), darkGreyBackground);
            Object.DestroyImmediate(darkGreyBackground);

            if (!EditorApplication.isUpdating)
            {
                var     oldProbe          = RenderSettings.ambientProbe;
                Texture defaultEnvTexture = ReflectionProbe.defaultTexture;
                if (Unsupported.SetOverrideLightingSettings(previewScene.scene))
                {
                    // Most preview windows just want the light probe from the main scene so by default we copy it here. It can then be overridden if user wants.
                    RenderSettings.ambientProbe          = oldProbe;
                    RenderSettings.defaultReflectionMode = UnityEngine.Rendering.DefaultReflectionMode.Custom;
                    RenderSettings.customReflection      = defaultEnvTexture as Cubemap;
                }
            }
        }
 private void AddCreateGameObjectItemsToMenu(GenericMenu menu, Object[] context, bool includeCreateEmptyChild, bool includeGameObjectInPath, int targetSceneHandle)
 {
     foreach (string str in Unsupported.GetSubmenus("GameObject"))
     {
         Object[] temporaryContext = context;
         if (includeCreateEmptyChild || (str.ToLower() != "GameObject/Create Empty Child".ToLower()))
         {
             if (str.EndsWith("..."))
             {
                 temporaryContext = null;
             }
             if (str.ToLower() == "GameObject/Center On Children".ToLower())
             {
                 return;
             }
             string replacementMenuString = str;
             if (!includeGameObjectInPath)
             {
                 replacementMenuString = str.Substring(11);
             }
             MenuUtils.ExtractMenuItemWithPath(str, menu, replacementMenuString, temporaryContext, targetSceneHandle, new Action <string, Object[], int>(this.BeforeCreateGameObjectMenuItemWasExecuted), new Action <string, Object[], int>(this.AfterCreateGameObjectMenuItemWasExecuted));
         }
     }
 }
Esempio n. 13
0
        public void DeveloperBuildSettingsGUI()
        {
            if (!Unsupported.IsDeveloperMode())
            {
                return;
            }

            Lightmapping.concurrentJobsType        = (Lightmapping.ConcurrentJobsType)EditorGUILayout.IntPopup(Styles.ConcurrentJobs, (int)Lightmapping.concurrentJobsType, Styles.ConcurrentJobsTypeStrings, Styles.ConcurrentJobsTypeValues);
            Lightmapping.enlightenForceUpdates     = EditorGUILayout.Toggle(Styles.ForceUpdates, Lightmapping.enlightenForceUpdates);
            Lightmapping.enlightenForceWhiteAlbedo = EditorGUILayout.Toggle(Styles.ForceWhiteAlbedo, Lightmapping.enlightenForceWhiteAlbedo);
            Lightmapping.filterMode = (FilterMode)EditorGUILayout.EnumPopup(EditorGUIUtility.TempContent("Filter Mode"), Lightmapping.filterMode);

            EditorGUILayout.Slider(m_BounceScale, 0.0f, 10.0f, Styles.BounceScale);
            EditorGUILayout.Slider(m_UpdateThreshold, 0.0f, 1.0f, Styles.UpdateThreshold);

            if (GUILayout.Button("Clear disk cache", GUILayout.Width(LightingWindow.kButtonWidth)))
            {
                Lightmapping.Clear();
                Lightmapping.ClearDiskCache();
            }

            if (GUILayout.Button("Print state to console", GUILayout.Width(LightingWindow.kButtonWidth)))
            {
                Lightmapping.PrintStateToConsole();
            }

            if (GUILayout.Button("Reset albedo/emissive", GUILayout.Width(LightingWindow.kButtonWidth)))
            {
                GIDebugVisualisation.ResetRuntimeInputTextures();
            }

            if (GUILayout.Button("Reset environment", GUILayout.Width(LightingWindow.kButtonWidth)))
            {
                DynamicGI.UpdateEnvironment();
            }
        }
        void AssetImportGUI()
        {
            EditorGUI.BeginChangeCheck();

            DoAutoRefreshMode();
            DoImportWorkerCount();
            DoDirectoryMonitoring();

            bool oldCompressOnImport = m_CompressAssetsOnImport;

            m_CompressAssetsOnImport = EditorGUILayout.Toggle(Properties.compressAssetsOnImport, oldCompressOnImport);
            m_VerifySavingAssets     = EditorGUILayout.Toggle(Properties.verifySavingAssets, m_VerifySavingAssets);
            m_EnterSafeModeDialog    = EditorGUILayout.Toggle(Properties.enterSafeModeDialog, m_EnterSafeModeDialog);

            if (EditorGUI.EndChangeCheck())
            {
                if (GUI.changed && m_CompressAssetsOnImport != oldCompressOnImport)
                {
                    Unsupported.SetApplicationSettingCompressAssetsOnImport(m_CompressAssetsOnImport);
                }
                WriteAssetImportPreferences();
                ReadAssetImportPreferences();
            }
        }
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (!ShaderUtil.hardwareSupportsRectRenderTexture || !SystemInfo.supports3DTextures)
            {
                if (Event.current.type == EventType.Repaint)
                {
                    EditorGUI.DropShadowLabel(new Rect(r.x, r.y, r.width, 40), "3D texture preview not supported");
                }
                return;
            }

            m_PreviewDir = PreviewGUI.Drag2D(m_PreviewDir, r);

            if (Event.current.type != EventType.Repaint)
            {
                return;
            }

            InitPreview();
            m_Material.mainTexture = target as Texture;

            m_PreviewUtility.BeginPreview(r, background);
            bool oldFog = RenderSettings.fog;

            Unsupported.SetRenderSettingsUseFogNoDirty(false);

            m_PreviewUtility.camera.transform.position = -Vector3.forward * 3.0f;
            m_PreviewUtility.camera.transform.rotation = Quaternion.identity;
            Quaternion rot = Quaternion.Euler(m_PreviewDir.y, 0, 0) * Quaternion.Euler(0, m_PreviewDir.x, 0);

            m_PreviewUtility.DrawMesh(m_Mesh, Vector3.zero, rot, m_Material, 0);
            m_PreviewUtility.Render();

            Unsupported.SetRenderSettingsUseFogNoDirty(oldFog);
            m_PreviewUtility.EndAndDrawPreview(r);
        }
Esempio n. 16
0
        void AssetImportGUI()
        {
            EditorGUI.BeginChangeCheck();
            bool collabEnabled = Collab.instance.IsCollabEnabledForCurrentProject();

            using (new EditorGUI.DisabledScope(collabEnabled))
            {
                if (collabEnabled)
                {
                    EditorGUILayout.Toggle(Properties.autoRefresh, true);               // Don't keep toggle value in m_AutoRefresh since we don't want to save the overwritten value
                    EditorGUILayout.HelpBox(Properties.autoRefreshHelpBox);
                }
                else
                {
                    m_AutoRefresh = EditorGUILayout.Toggle(Properties.autoRefresh, m_AutoRefresh);
                }
            }
            DoImportWorkerCount();
            DoDirectoryMonitoring();

            bool oldCompressOnImport = m_CompressAssetsOnImport;

            m_CompressAssetsOnImport = EditorGUILayout.Toggle(Properties.compressAssetsOnImport, oldCompressOnImport);
            m_VerifySavingAssets     = EditorGUILayout.Toggle(Properties.verifySavingAssets, m_VerifySavingAssets);
            m_EnterSafeModeDialog    = EditorGUILayout.Toggle(Properties.enterSafeModeDialog, m_EnterSafeModeDialog);

            if (EditorGUI.EndChangeCheck())
            {
                if (GUI.changed && m_CompressAssetsOnImport != oldCompressOnImport)
                {
                    Unsupported.SetApplicationSettingCompressAssetsOnImport(m_CompressAssetsOnImport);
                }
                WriteAssetImportPreferences();
                ReadAssetImportPreferences();
            }
        }
Esempio n. 17
0
 protected void AllowCursorLockAndHide(bool enable)
 {
     Unsupported.SetAllowCursorLock(enable, Unsupported.DisallowCursorLockReasons.Other);
     Unsupported.SetAllowCursorHide(enable);
 }
Esempio n. 18
0
 private void OnEnable()
 {
     ConsoleWindow.ms_ConsoleWindow = this;
     this.m_DevBuild = Unsupported.IsDeveloperBuild();
 }
Esempio n. 19
0
 internal void SwitchToAssetMode()
 {
     foreach (AvatarEditor.SceneStateCache current in this.m_SceneStates)
     {
         if (!(current.view == null))
         {
             current.view.m_SceneViewState.showFog            = current.state.showFog;
             current.view.m_SceneViewState.showFlares         = current.state.showFlares;
             current.view.m_SceneViewState.showMaterialUpdate = current.state.showMaterialUpdate;
             current.view.m_SceneViewState.showSkybox         = current.state.showSkybox;
         }
     }
     this.m_EditMode = AvatarEditor.EditMode.Stopping;
     this.DestroyEditor();
     this.ChangeInspectorLock(this.m_InspectorLocked);
     if (!EditorApplication.isUpdating && !Unsupported.IsDestroyScriptableObject(this))
     {
         string currentScene = EditorApplication.currentScene;
         if (currentScene.Length <= 0)
         {
             if (this.m_UserFileName.Length > 0)
             {
                 EditorApplication.OpenScene(this.m_UserFileName);
             }
             else
             {
                 EditorApplication.NewScene();
             }
         }
     }
     else
     {
         if (Unsupported.IsDestroyScriptableObject(this))
         {
             EditorApplication.CallbackFunction CleanUpSceneOnDestroy = null;
             string userFileName = this.m_UserFileName;
             CleanUpSceneOnDestroy = delegate
             {
                 string currentScene2 = EditorApplication.currentScene;
                 if (currentScene2.Length <= 0)
                 {
                     if (userFileName.Length > 0)
                     {
                         EditorApplication.OpenScene(userFileName);
                     }
                     else
                     {
                         EditorApplication.NewScene();
                     }
                 }
                 EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Remove(EditorApplication.update, CleanUpSceneOnDestroy);
             };
             EditorApplication.update = (EditorApplication.CallbackFunction)Delegate.Combine(EditorApplication.update, CleanUpSceneOnDestroy);
         }
     }
     this.m_GameObject = null;
     this.m_ModelBones = null;
     this.SelectAsset();
     if (!this.m_CameFromImportSettings)
     {
         this.m_EditMode = AvatarEditor.EditMode.NotEditing;
     }
 }
Esempio n. 20
0
        void ShowRealtimeLMGUI(Renderer renderer)
        {
            Hash128 inputSystemHash;

            if (renderer == null || !Lightmapping.GetInputSystemHash(renderer.GetInstanceID(), out inputSystemHash) || inputSystemHash == new Hash128())
            {
                return; // early return since we don't have any lightmaps for it
            }
            if (!UpdateRealtimeTexture(inputSystemHash, renderer.GetInstanceID()))
            {
                return;
            }

            m_ShowRealtimeLM.value = EditorGUILayout.Foldout(m_ShowRealtimeLM.value, Styles.realtimeLM, true);

            if (!m_ShowRealtimeLM.value)
            {
                return;
            }

            EditorGUI.indentLevel += 1;

            GUILayout.BeginHorizontal();

            DrawLightmapPreview(m_CachedRealtimeTexture.texture, true, renderer.GetInstanceID());

            GUILayout.BeginVertical();

            int instWidth, instHeight;

            if (Lightmapping.GetInstanceResolution(renderer, out instWidth, out instHeight))
            {
                GUILayout.Label(Styles.realtimeLMInstanceResolution.text + ": " + instWidth + "x" + instHeight);
            }

            int width, height;

            if (Lightmapping.GetSystemResolution(renderer, out width, out height))
            {
                GUILayout.Label(Styles.realtimeLMResolution.text + ": " + width + "x" + height);
            }

            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            if (Unsupported.IsDeveloperMode())
            {
                Hash128 instanceHash;
                if (Lightmapping.GetInstanceHash(renderer, out instanceHash))
                {
                    EditorGUILayout.LabelField(Styles.realtimeLMInstanceHash, GUIContent.Temp(instanceHash.ToString()));
                }

                Hash128 geometryHash;
                if (Lightmapping.GetGeometryHash(renderer, out geometryHash))
                {
                    EditorGUILayout.LabelField(Styles.realtimeLMGeometryHash, GUIContent.Temp(geometryHash.ToString()));
                }

                EditorGUILayout.LabelField(Styles.realtimeLMInputSystemHash, GUIContent.Temp(inputSystemHash.ToString()));
            }

            EditorGUI.indentLevel -= 1;

            GUILayout.Space(5);
        }
            /// <summary>
            /// Default implementation of the build player method.
            /// </summary>
            /// <param name="options"></param>
            public static void BuildPlayer(BuildPlayerOptions options)
            {
                if (!UnityConnect.instance.canBuildWithUPID)
                {
                    if (!EditorUtility.DisplayDialog("Missing Project ID", "Because you are not a member of this project this build will not access Unity services.\nDo you want to continue?", "Yes", "No"))
                    {
                        throw new BuildMethodException();
                    }
                }

                if (!BuildPipeline.IsBuildTargetSupported(options.targetGroup, options.target))
                {
                    throw new BuildMethodException("Build target is not supported.");
                }

                string module = ModuleManager.GetTargetStringFrom(EditorUserBuildSettings.selectedBuildTargetGroup, options.target);
                IBuildWindowExtension buildWindowExtension = ModuleManager.GetBuildWindowExtension(module);

                if (buildWindowExtension != null && (options.options & BuildOptions.AutoRunPlayer) != 0 && !buildWindowExtension.EnabledBuildAndRunButton())
                {
                    throw new BuildMethodException();
                }

                if (Unsupported.IsBleedingEdgeBuild())
                {
                    var sb = new System.Text.StringBuilder();
                    sb.AppendLine("This version of Unity is a BleedingEdge build that has not seen any manual testing.");
                    sb.AppendLine("You should consider this build unstable.");
                    sb.AppendLine("We strongly recommend that you use a normal version of Unity instead.");

                    if (EditorUtility.DisplayDialog("BleedingEdge Build", sb.ToString(), "Cancel", "OK"))
                    {
                        throw new BuildMethodException();
                    }
                }

                // See if we need to switch platforms and delay the build.  We do this whenever
                // we're trying to build for a target different from the active one so as to ensure
                // that the compiled script code we have loaded is built for the same platform we
                // are building for.  As we can't reload while our editor stuff is still executing,
                // we need to defer to after the next script reload then.
                bool delayToAfterScriptReload = false;

                if (EditorUserBuildSettings.activeBuildTarget != options.target ||
                    EditorUserBuildSettings.activeBuildTargetGroup != options.targetGroup)
                {
                    if (!EditorUserBuildSettings.SwitchActiveBuildTargetAsync(options.targetGroup, options.target))
                    {
                        // Switching the build target failed.  No point in trying to continue
                        // with a build.
                        var errStr = string.Format("Could not switch to build target '{0}', '{1}'.",
                                                   BuildPipeline.GetBuildTargetGroupDisplayName(options.targetGroup),
                                                   BuildPlatforms.instance.GetBuildTargetDisplayName(options.targetGroup, options.target));
                        throw new BuildMethodException(errStr);
                    }

                    if (EditorApplication.isCompiling)
                    {
                        delayToAfterScriptReload = true;
                    }
                }

                // Trigger build.
                // Note: report will be null, if delayToAfterScriptReload = true
                var report = BuildPipeline.BuildPlayerInternalNoCheck(options.scenes, options.locationPathName, null, options.targetGroup, options.target, options.options, delayToAfterScriptReload);


                if (report != null)
                {
                    var resultStr = String.Format("Build completed with a result of '{0}'", report.summary.result.ToString("g"));

                    switch (report.summary.result)
                    {
                    case Build.Reporting.BuildResult.Unknown:
                        Debug.LogWarning(resultStr);
                        break;

                    case Build.Reporting.BuildResult.Failed:
                        DeleteBuildFolderIfEmpty(report.summary.outputPath);
                        Debug.LogError(resultStr);
                        throw new BuildMethodException(report.SummarizeErrors());

                    default:
                        Debug.Log(resultStr);
                        break;
                    }

                    buildCompletionHandler?.Invoke(report);
                }
            }
Esempio n. 22
0
 public static bool IsDeveloperBuild()
 {
     return(Unsupported.IsDeveloperBuildInternal() && !Unsupported.s_FakeNonDeveloperBuild);
 }
Esempio n. 23
0
			public static void Create(Mesh src, out Unsupported.ProgressiveMesh pm)
			{
				pm.opaquePtr = Unsupported.ProgressiveMesh.CreateImpl(src);
			}
Esempio n. 24
0
			public static void Destroy(ref Unsupported.ProgressiveMesh pm)
			{
				Unsupported.ProgressiveMesh.DestroyImpl(pm.opaquePtr);
				pm.opaquePtr = IntPtr.Zero;
			}
Esempio n. 25
0
			public static void CreateInitialGeometry(Unsupported.ProgressiveMesh pm, Mesh mesh)
			{
				Unsupported.ProgressiveMesh.CreateInitialGeometryImpl(pm.opaquePtr, mesh);
			}
Esempio n. 26
0
        void Summary()
        {
            GUILayout.BeginVertical(EditorStyles.helpBox);

            long totalMemorySize            = 0;
            int  lightmapCount              = 0;
            Dictionary <Vector2, int> sizes = new Dictionary <Vector2, int>();
            bool directionalLightmapsMode   = false;
            bool shadowmaskMode             = false;

            foreach (LightmapData ld in LightmapSettings.lightmaps)
            {
                if (ld.lightmapColor == null)
                {
                    continue;
                }
                lightmapCount++;

                Vector2 texSize = new Vector2(ld.lightmapColor.width, ld.lightmapColor.height);
                if (sizes.ContainsKey(texSize))
                {
                    sizes[texSize]++;
                }
                else
                {
                    sizes.Add(texSize, 1);
                }

                totalMemorySize += TextureUtil.GetStorageMemorySizeLong(ld.lightmapColor);
                if (ld.lightmapDir)
                {
                    totalMemorySize         += TextureUtil.GetStorageMemorySizeLong(ld.lightmapDir);
                    directionalLightmapsMode = true;
                }
                if (ld.shadowMask)
                {
                    totalMemorySize += TextureUtil.GetStorageMemorySizeLong(ld.shadowMask);
                    shadowmaskMode   = true;
                }
            }
            StringBuilder sizesString = new StringBuilder();

            sizesString.Append(lightmapCount);
            sizesString.Append((directionalLightmapsMode ? " Directional" : " Non-Directional"));
            sizesString.Append(" Lightmap");
            if (lightmapCount != 1)
            {
                sizesString.Append("s");
            }
            if (shadowmaskMode)
            {
                sizesString.Append(" with Shadowmask");
                if (lightmapCount != 1)
                {
                    sizesString.Append("s");
                }
            }

            bool first = true;

            foreach (var s in sizes)
            {
                sizesString.Append(first ? ": " : ", ");
                first = false;
                if (s.Value > 1)
                {
                    sizesString.Append(s.Value);
                    sizesString.Append("x");
                }
                sizesString.Append(s.Key.x.ToString(CultureInfo.InvariantCulture.NumberFormat));
                sizesString.Append("x");
                sizesString.Append(s.Key.y.ToString(CultureInfo.InvariantCulture.NumberFormat));
                sizesString.Append("px");
            }
            sizesString.Append(" ");

            GUILayout.BeginHorizontal();

            GUILayout.BeginVertical();
            GUILayout.Label(sizesString.ToString(), Styles.LabelStyle);
            GUILayout.EndVertical();

            GUILayout.BeginVertical();
            GUILayout.Label(EditorUtility.FormatBytes(totalMemorySize), Styles.LabelStyle);
            GUILayout.Label((lightmapCount == 0 ? "No Lightmaps" : ""), Styles.LabelStyle);
            GUILayout.EndVertical();

            GUILayout.EndHorizontal();

            if (LightmapEditorSettings.lightmapper != LightmapEditorSettings.Lightmapper.Enlighten)
            {
                GUILayout.BeginVertical();
                GUILayout.Label("Occupied Texels: " + InternalEditorUtility.CountToString(Lightmapping.occupiedTexelCount), Styles.LabelStyle);
                if (Lightmapping.isRunning)
                {
                    int numLightmapsInView             = 0;
                    int numConvergedLightmapsInView    = 0;
                    int numNotConvergedLightmapsInView = 0;

                    int numLightmapsNotInView             = 0;
                    int numConvergedLightmapsNotInView    = 0;
                    int numNotConvergedLightmapsNotInView = 0;

                    int numLightmaps = LightmapSettings.lightmaps.Length;
                    for (int i = 0; i < numLightmaps; ++i)
                    {
                        LightmapConvergence lc = Lightmapping.GetLightmapConvergence(i);
                        if (!lc.IsValid())
                        {
                            continue;
                        }

                        if (Lightmapping.GetVisibleTexelCount(i) > 0)
                        {
                            numLightmapsInView++;
                            if (lc.IsConverged())
                            {
                                numConvergedLightmapsInView++;
                            }
                            else
                            {
                                numNotConvergedLightmapsInView++;
                            }
                        }
                        else
                        {
                            numLightmapsNotInView++;
                            if (lc.IsConverged())
                            {
                                numConvergedLightmapsNotInView++;
                            }
                            else
                            {
                                numNotConvergedLightmapsNotInView++;
                            }
                        }
                    }
                    if (Lightmapping.atlasCount > 0)
                    {
                        int convergedMaps = numConvergedLightmapsInView + numConvergedLightmapsNotInView;
                        GUILayout.Label("Lightmap convergence: (" + convergedMaps + "/" + Lightmapping.atlasCount + ")", Styles.LabelStyle);
                    }
                    EditorGUILayout.LabelField("Lightmaps in view: " + numLightmapsInView, Styles.LabelStyle);
                    EditorGUI.indentLevel += 1;
                    EditorGUILayout.LabelField("Converged: " + numConvergedLightmapsInView, Styles.LabelStyle);
                    EditorGUILayout.LabelField("Not Converged: " + numNotConvergedLightmapsInView, Styles.LabelStyle);
                    EditorGUI.indentLevel -= 1;
                    EditorGUILayout.LabelField("Lightmaps not in view: " + numLightmapsNotInView, Styles.LabelStyle);
                    EditorGUI.indentLevel += 1;
                    EditorGUILayout.LabelField("Converged: " + numConvergedLightmapsNotInView, Styles.LabelStyle);
                    EditorGUILayout.LabelField("Not Converged: " + numNotConvergedLightmapsNotInView, Styles.LabelStyle);
                    EditorGUI.indentLevel -= 1;

                    LightProbesConvergence lpc = Lightmapping.GetLightProbesConvergence();
                    if (lpc.IsValid() && lpc.probeSetCount > 0)
                    {
                        GUILayout.Label("Light Probes convergence: (" + lpc.convergedProbeSetCount + "/" + lpc.probeSetCount + ")", Styles.LabelStyle);
                    }
                }
                float bakeTime    = Lightmapping.GetLightmapBakeTimeTotal();
                float mraysPerSec = Lightmapping.GetLightmapBakePerformanceTotal();
                if (mraysPerSec >= 0.0)
                {
                    GUILayout.Label("Bake Performance: " + mraysPerSec.ToString("0.00", CultureInfo.InvariantCulture.NumberFormat) + " mrays/sec", Styles.LabelStyle);
                }
                if (!Lightmapping.isRunning)
                {
                    float bakeTimeRaw = Lightmapping.GetLightmapBakeTimeRaw();
                    if (bakeTime >= 0.0)
                    {
                        int time  = (int)bakeTime;
                        int timeH = time / 3600;
                        time -= 3600 * timeH;
                        int timeM = time / 60;
                        time -= 60 * timeM;
                        int timeS = time;

                        int timeRaw  = (int)bakeTimeRaw;
                        int timeRawH = timeRaw / 3600;
                        timeRaw -= 3600 * timeRawH;
                        int timeRawM = timeRaw / 60;
                        timeRaw -= 60 * timeRawM;
                        int timeRawS = timeRaw;

                        int oHeadTime  = Math.Max(0, (int)(bakeTime - bakeTimeRaw));
                        int oHeadTimeH = oHeadTime / 3600;
                        oHeadTime -= 3600 * oHeadTimeH;
                        int oHeadTimeM = oHeadTime / 60;
                        oHeadTime -= 60 * oHeadTimeM;
                        int oHeadTimeS = oHeadTime;


                        GUILayout.Label("Total Bake Time: " + timeH.ToString("0") + ":" + timeM.ToString("00") + ":" + timeS.ToString("00"), Styles.LabelStyle);
                        if (Unsupported.IsDeveloperBuild())
                        {
                            GUILayout.Label("(Raw Bake Time: " + timeRawH.ToString("0") + ":" + timeRawM.ToString("00") + ":" + timeRawS.ToString("00") + ", Overhead: " + oHeadTimeH.ToString("0") + ":" + oHeadTimeM.ToString("00") + ":" + oHeadTimeS.ToString("00") + ")", Styles.LabelStyle);
                        }
                    }
                }
                string deviceName = Lightmapping.GetLightmapBakeGPUDeviceName();
                if (deviceName.Length > 0)
                {
                    GUILayout.Label("Baking device: " + deviceName, Styles.LabelStyle);
                }
                GUILayout.EndVertical();
            }

            GUILayout.EndVertical();
        }
Esempio n. 27
0
        public void InvokeOnGUI(Rect onGUIPosition, Rect viewRect)
        {
            // Handle window reloading.
            if (Unsupported.IsDeveloperMode() &&
                actualView != null &&
                Event.current.type == EventType.KeyUp && Event.current.keyCode == KeyCode.F5)
            {
                if (Event.current.control)
                {
                    DebugWindow(actualView);
                }
                else
                {
                    Reload(actualView);
                }
                return;
            }

            DoWindowDecorationStart();

            BeginOffsetArea(viewRect, GUIContent.none, "TabWindowBackground");

            EditorGUIUtility.ResetGUIState();

            bool isExitGUIException = false;

            try
            {
                using (new PerformanceTracker(actualView.GetType().Name + ".OnGUI." + Event.current.type))
                {
                    Invoke("OnGUI");
                }
            }
            catch (TargetInvocationException e)
            {
                if (e.InnerException is ExitGUIException)
                {
                    isExitGUIException = true;
                }
                throw;
            }
            finally
            {
                // We can't reset gui state after ExitGUI we just want to bail completely
                if (!isExitGUIException)
                {
                    CheckNotificationStatus();

                    EndOffsetArea();

                    EditorGUIUtility.ResetGUIState();

                    DoWindowDecorationEnd();

                    if (Event.current != null && Event.current.type == EventType.Repaint)
                    {
                        HostViewStyles.overlay.Draw(onGUIPosition, GUIContent.none, 0);
                    }
                }
            }
        }
        private void CreateComponentTree()
        {
            string[]      submenus                  = Unsupported.GetSubmenus("Component");
            string[]      submenusCommands          = Unsupported.GetSubmenusCommands("Component");
            List <string> list                      = new List <string>();
            List <AddComponentWindow.Element> list2 = new List <AddComponentWindow.Element>();

            for (int i = 0; i < submenus.Length; i++)
            {
                if (!(submenusCommands[i] == "ADD"))
                {
                    string   text  = submenus[i];
                    string[] array = text.Split(new char[]
                    {
                        '/'
                    });
                    while (array.Length - 1 < list.Count)
                    {
                        list.RemoveAt(list.Count - 1);
                    }
                    while (list.Count > 0 && array[list.Count - 1] != list[list.Count - 1])
                    {
                        list.RemoveAt(list.Count - 1);
                    }
                    while (array.Length - 1 > list.Count)
                    {
                        list2.Add(new AddComponentWindow.GroupElement(list.Count, LocalizationDatabase.GetLocalizedString(array[list.Count])));
                        list.Add(array[list.Count]);
                    }
                    list2.Add(new AddComponentWindow.ComponentElement(list.Count, LocalizationDatabase.GetLocalizedString(array[array.Length - 1]), text, submenusCommands[i]));
                }
            }
            list2.Add(new AddComponentWindow.NewScriptElement());
            this.m_Tree = list2.ToArray();
            if (this.m_Stack.Count == 0)
            {
                this.m_Stack.Add(this.m_Tree[0] as AddComponentWindow.GroupElement);
            }
            else
            {
                AddComponentWindow.GroupElement groupElement = this.m_Tree[0] as AddComponentWindow.GroupElement;
                int level = 0;
                while (true)
                {
                    AddComponentWindow.GroupElement groupElement2 = this.m_Stack[level];
                    this.m_Stack[level] = groupElement;
                    this.m_Stack[level].selectedIndex = groupElement2.selectedIndex;
                    this.m_Stack[level].scroll        = groupElement2.scroll;
                    level++;
                    if (level == this.m_Stack.Count)
                    {
                        break;
                    }
                    List <AddComponentWindow.Element> children = this.GetChildren(this.activeTree, groupElement);
                    AddComponentWindow.Element        element  = children.FirstOrDefault((AddComponentWindow.Element c) => c.name == this.m_Stack[level].name);
                    if (element != null && element is AddComponentWindow.GroupElement)
                    {
                        groupElement = (element as AddComponentWindow.GroupElement);
                    }
                    else
                    {
                        while (this.m_Stack.Count > level)
                        {
                            this.m_Stack.RemoveAt(level);
                        }
                    }
                }
            }
            AddComponentWindow.s_DirtyList = false;
            this.RebuildSearch();
        }
Esempio n. 29
0
        private static void LoadMenu(IList menus, string prefix = "", int priority = 100)
        {
            const string k_MenuKeyName              = "name";
            const string k_MenuKeyItemId            = "menu_item_id";
            const string k_MenuKeyCommandId         = "command_id";
            const string k_MenuKeyValidateCommandId = "validate_command_id";
            const string k_MenuKeyChildren          = "children";
            const string k_MenuKeyPriority          = "priority";
            const string k_MenuKeyInternal          = "internal";
            const string k_MenuKeyShortcut          = "shortcut";
            const string k_MenuKeyChecked           = "checked";
            const string k_MenuKeyPlatform          = "platform";
            const string k_MenuKeyRename            = "rename";

            if (menus == null)
            {
                return;
            }

            foreach (var menuData in menus)
            {
                if (menuData != null)
                {
                    var menu = menuData as JSONObject;
                    if (menu == null)
                    {
                        continue;
                    }
                    var isInternal = JsonUtils.JsonReadBoolean(menu, k_MenuKeyInternal);
                    if (isInternal && !Unsupported.IsDeveloperMode())
                    {
                        continue;
                    }
                    var menuName            = JsonUtils.JsonReadString(menu, k_MenuKeyName);
                    var fullMenuName        = prefix + menuName;
                    var platform            = JsonUtils.JsonReadString(menu, k_MenuKeyPlatform);
                    var hasExplicitPriority = menu.Contains(k_MenuKeyPriority);
                    priority = JsonUtils.JsonReadInt(menu, k_MenuKeyPriority, priority + 1);

                    // Check the menu item platform
                    if (!String.IsNullOrEmpty(platform) && !Application.platform.ToString().ToLowerInvariant().StartsWith(platform.ToLowerInvariant()))
                    {
                        continue;
                    }

                    // Check if we are a submenu
                    if (menu.Contains(k_MenuKeyChildren))
                    {
                        if (menu[k_MenuKeyChildren] is IList)
                        {
                            LoadMenu(menu[k_MenuKeyChildren] as IList, fullMenuName + "/", priority);
                        }
                        else if (menu[k_MenuKeyChildren] is string && (string)menu[k_MenuKeyChildren] == "*")
                        {
                            var whitelistedItems = Menu.ExtractSubmenus(fullMenuName);
                            var renamedTo        = prefix + JsonUtils.JsonReadString(menu, k_MenuKeyRename, menuName);
                            foreach (var wi in whitelistedItems)
                            {
                                Menu.AddExistingMenuItem(wi.Replace(fullMenuName, renamedTo), wi, hasExplicitPriority ? priority : -1);
                            }
                        }
                    }
                    else
                    {
                        var commandId = JsonUtils.JsonReadString(menu, k_MenuKeyCommandId);
                        if (String.IsNullOrEmpty(commandId))
                        {
                            // We are re-using a default menu item
                            var menuItemId = JsonUtils.JsonReadString(menu, k_MenuKeyItemId, fullMenuName);
                            if (fullMenuName.Contains('/'))
                            {
                                Menu.AddExistingMenuItem(fullMenuName, menuItemId, priority);
                            }
                        }
                        else if (CommandService.Exists(commandId))
                        {
                            // Create a new menu item pointing to a command handler
                            var shortcut = JsonUtils.JsonReadString(menu, k_MenuKeyShortcut);
                            var @checked = JsonUtils.JsonReadBoolean(menu, k_MenuKeyChecked);

                            Func <bool> validateHandler   = null;
                            var         validateCommandId = JsonUtils.JsonReadString(menu, k_MenuKeyValidateCommandId);
                            if (!String.IsNullOrEmpty(validateCommandId))
                            {
                                validateHandler = () => (bool)CommandService.Execute(validateCommandId, CommandHint.Menu | CommandHint.Validate);
                            }

                            Menu.AddMenuItem(fullMenuName, shortcut, @checked, priority, () => CommandService.Execute(commandId, CommandHint.Menu), validateHandler);
                        }
                    }
                }
                else
                {
                    priority += 100;
                }
            }
        }
Esempio n. 30
0
        private void OnGUI()
        {
            ConsoleWindow.LoadIcons();
            if (background == null)
            {
                background = "AppToolbar";
            }
            if (EditorApplication.isPlayingOrWillChangePlaymode)
            {
                GUI.color = (Color)HostView.kPlayModeDarken;
            }
            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(new Rect(0f, 0f, base.position.width, base.position.height), false, false, false, false);
            }
            bool isCompiling = EditorApplication.isCompiling;

            GUILayout.Space(2f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(2f);
            string statusText = LogEntries.GetStatusText();

            if (statusText != null)
            {
                int      statusMask = LogEntries.GetStatusMask();
                GUIStyle statusStyleForErrorMode = ConsoleWindow.GetStatusStyleForErrorMode(statusMask);
                GUILayout.Label(ConsoleWindow.GetIconForErrorMode(statusMask, false), statusStyleForErrorMode, new GUILayoutOption[0]);
                GUILayout.Space(2f);
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                GUILayout.Space(2f);
                if (isCompiling)
                {
                    GUILayoutOption[] options = new GUILayoutOption[] { GUILayout.MaxWidth(GUIView.current.position.width - 52f) };
                    GUILayout.Label(statusText, statusStyleForErrorMode, options);
                }
                else
                {
                    GUILayout.Label(statusText, statusStyleForErrorMode, new GUILayoutOption[0]);
                }
                GUILayout.FlexibleSpace();
                GUILayout.EndVertical();
                if (Event.current.type == EventType.MouseDown)
                {
                    Event.current.Use();
                    LogEntries.ClickStatusBar(Event.current.clickCount);
                    GUIUtility.ExitGUI();
                }
            }
            GUILayout.EndHorizontal();
            if (Event.current.type == EventType.Repaint)
            {
                float x = base.position.width - 24f;
                if (AsyncProgressBar.isShowing)
                {
                    x -= 188f;
                    EditorGUI.ProgressBar(new Rect(x, 0f, 185f, 19f), AsyncProgressBar.progress, AsyncProgressBar.progressInfo);
                }
                if (isCompiling)
                {
                    int index = (int)Mathf.Repeat(Time.realtimeSinceStartup * 10f, 11.99f);
                    GUI.Label(new Rect(base.position.width - 24f, 0f, (float)s_StatusWheel[index].image.width, (float)s_StatusWheel[index].image.height), s_StatusWheel[index], GUIStyle.none);
                }
                if (Unsupported.IsBleedingEdgeBuild())
                {
                    Color color = GUI.color;
                    GUI.color = Color.yellow;
                    GUI.Label(new Rect(x - 310f, 0f, 310f, 19f), "THIS IS AN UNTESTED BLEEDINGEDGE UNITY BUILD");
                    GUI.color = color;
                }
                else if (Unsupported.IsDeveloperBuild())
                {
                    GUI.Label(new Rect(x - 200f, 0f, 200f, 19f), this.m_LastMiniMemoryOverview, EditorStyles.progressBarText);
                    EditorGUIUtility.CleanCache(this.m_LastMiniMemoryOverview);
                }
            }
            base.DoWindowDecorationEnd();
            EditorGUI.ShowRepaints();
        }
Esempio n. 31
0
        void ShowAtlasGUI(int instanceID, bool isMeshRenderer)
        {
            if (m_LightmapIndex == null)
            {
                return;
            }

            Hash128 contentHash = LightmapVisualizationUtility.GetBakedGITextureHash(m_LightmapIndex.intValue, 0, GITextureType.Baked);

            // if we need to fetch a new texture
            if (m_CachedBakedTexture.texture == null || m_CachedBakedTexture.contentHash != contentHash)
            {
                m_CachedBakedTexture = LightmapVisualizationUtility.GetBakedGITexture(m_LightmapIndex.intValue, 0, GITextureType.Baked);
            }

            if (m_CachedBakedTexture.texture == null)
            {
                return;
            }

            m_ShowBakedLM.value = EditorGUILayout.Foldout(m_ShowBakedLM.value, Styles.atlas, true);

            if (!m_ShowBakedLM.value)
            {
                return;
            }

            EditorGUI.indentLevel += 1;

            GUILayout.BeginHorizontal();

            DrawLightmapPreview(m_CachedBakedTexture.texture, false, instanceID);

            GUILayout.BeginVertical();

            GUILayout.Label(Styles.atlasIndex.text + ": " + m_LightmapIndex.intValue);
            GUILayout.Label(Styles.atlasTilingX.text + ": " + m_LightmapTilingOffsetX.floatValue.ToString(CultureInfo.InvariantCulture.NumberFormat));
            GUILayout.Label(Styles.atlasTilingY.text + ": " + m_LightmapTilingOffsetY.floatValue.ToString(CultureInfo.InvariantCulture.NumberFormat));
            GUILayout.Label(Styles.atlasOffsetX.text + ": " + m_LightmapTilingOffsetZ.floatValue.ToString(CultureInfo.InvariantCulture.NumberFormat));
            GUILayout.Label(Styles.atlasOffsetY.text + ": " + m_LightmapTilingOffsetW.floatValue.ToString(CultureInfo.InvariantCulture.NumberFormat));

            var settings = Lightmapping.GetLightingSettingsOrDefaultsFallback();

            float lightmapResolution = settings.lightmapResolution * CalcLODScale(isMeshRenderer) * m_LightmapScale.floatValue;

            if (isMeshRenderer && (m_Renderers != null) && (m_Renderers.Length > 0))
            {
                Transform transform           = m_Renderers[0].GetComponent <Transform>();
                float     lightmapObjectScale = System.Math.Min(System.Math.Min(transform.localScale.x, transform.localScale.y), transform.localScale.z);
                GUILayout.Label(Styles.lightmapResolution.text + ": " + lightmapResolution.ToString(CultureInfo.InvariantCulture.NumberFormat));
                GUILayout.Label(Styles.lightmapObjectScale.text + ": " + lightmapObjectScale.ToString(CultureInfo.InvariantCulture.NumberFormat));
            }

            GUILayout.EndVertical();
            GUILayout.FlexibleSpace();
            GUILayout.EndHorizontal();

            bool showProgressiveInfo = isPrefabAsset || (settings.bakedGI && settings.lightmapper != LightingSettings.Lightmapper.Enlighten);

            if (showProgressiveInfo && Unsupported.IsDeveloperMode())
            {
                Hash128 instanceHash;
                Lightmapping.GetPVRInstanceHash(instanceID, out instanceHash);
                EditorGUILayout.LabelField(Styles.pvrInstanceHash, GUIContent.Temp(instanceHash.ToString()));

                Hash128 atlasHash;
                Lightmapping.GetPVRAtlasHash(instanceID, out atlasHash);
                EditorGUILayout.LabelField(Styles.pvrAtlasHash, GUIContent.Temp(atlasHash.ToString()));

                int atlasInstanceOffset;
                Lightmapping.GetPVRAtlasInstanceOffset(instanceID, out atlasInstanceOffset);
                EditorGUILayout.LabelField(Styles.pvrAtlasInstanceOffset, GUIContent.Temp(atlasInstanceOffset.ToString()));
            }
            EditorGUI.indentLevel -= 1;

            GUILayout.Space(5);
        }
Esempio n. 32
0
 public virtual void AddItemsToMenu(GenericMenu menu)
 {
     menu.AddItem(new GUIContent("Sort groups alphabetically"), this.m_SortGroupsAlphabetically, delegate
     {
         this.m_SortGroupsAlphabetically = !this.m_SortGroupsAlphabetically;
     });
     menu.AddItem(new GUIContent("Show referenced groups"), this.m_ShowReferencedBuses, delegate
     {
         this.m_ShowReferencedBuses = !this.m_ShowReferencedBuses;
     });
     menu.AddItem(new GUIContent("Show group connections"), this.m_ShowBusConnections, delegate
     {
         this.m_ShowBusConnections = !this.m_ShowBusConnections;
     });
     if (this.m_ShowBusConnections)
     {
         menu.AddItem(new GUIContent("Only highlight selected group connections"), this.m_ShowBusConnectionsOfSelection, delegate
         {
             this.m_ShowBusConnectionsOfSelection = !this.m_ShowBusConnectionsOfSelection;
         });
     }
     menu.AddSeparator("");
     menu.AddItem(new GUIContent("Vertical layout"), this.layoutMode == AudioMixerWindow.LayoutMode.Vertical, delegate
     {
         this.layoutMode = AudioMixerWindow.LayoutMode.Vertical;
     });
     menu.AddItem(new GUIContent("Horizontal layout"), this.layoutMode == AudioMixerWindow.LayoutMode.Horizontal, delegate
     {
         this.layoutMode = AudioMixerWindow.LayoutMode.Horizontal;
     });
     menu.AddSeparator("");
     menu.AddItem(new GUIContent("Use RMS metering for display"), EditorPrefs.GetBool(AudioMixerWindow.kAudioMixerUseRMSMetering, true), delegate
     {
         EditorPrefs.SetBool(AudioMixerWindow.kAudioMixerUseRMSMetering, true);
     });
     menu.AddItem(new GUIContent("Use peak metering for display"), !EditorPrefs.GetBool(AudioMixerWindow.kAudioMixerUseRMSMetering, true), delegate
     {
         EditorPrefs.SetBool(AudioMixerWindow.kAudioMixerUseRMSMetering, false);
     });
     if (Unsupported.IsDeveloperBuild())
     {
         menu.AddSeparator("");
         menu.AddItem(new GUIContent("DEVELOPER/Groups Rendered Above"), this.m_GroupsRenderedAboveSections, delegate
         {
             this.m_GroupsRenderedAboveSections = !this.m_GroupsRenderedAboveSections;
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build 10 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(0, 7, 10);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build 20 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(0, 7, 20);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build 40 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(0, 7, 40);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build 80 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(0, 7, 80);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build 160 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(0, 7, 160);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build chain of 10 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(1, 1, 10);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build chain of 20 groups "), false, delegate
         {
             this.m_Controller.BuildTestSetup(1, 1, 20);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build chain of 40 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(1, 1, 40);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build chain of 80 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(1, 1, 80);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Show overlays"), this.m_ShowDeveloperOverlays, delegate
         {
             this.m_ShowDeveloperOverlays = !this.m_ShowDeveloperOverlays;
         });
     }
 }
        private void DragTitleBar(Rect titleBarRect)
        {
            int   id  = GUIUtility.GetControlID(FocusType.Passive);
            Event evt = Event.current;

            switch (evt.GetTypeForControl(id))
            {
            case EventType.Repaint:
                if (m_DraggingNativeTitleBarCaption)
                {
                    m_DraggingNativeTitleBarCaption = false;
                }
                EditorGUIUtility.AddCursorRect(titleBarRect, MouseCursor.Arrow);
                break;

            case EventType.MouseDown:
                // If the mouse is inside the title bar rect, we say that we're the hot control
                if (titleBarRect.Contains(evt.mousePosition) && GUIUtility.hotControl == 0 && evt.button == 0)
                {
                    if (Application.platform != RuntimePlatform.LinuxEditor)
                    {
                        Event.current.Use();
                        m_DraggingNativeTitleBarCaption = true;
                        SendCaptionEvent(m_DraggingNativeTitleBarCaption);
                    }
                    else
                    {
                        GUIUtility.hotControl = id;
                        Event.current.Use();
                        s_LastDragMousePos = evt.mousePosition;
                        startDragDpi       = GUIUtility.pixelsPerPoint;
                        Unsupported.SetAllowCursorLock(false, Unsupported.DisallowCursorLockReasons.SizeMove);
                    }
                }
                break;

            case EventType.MouseUp:
                if (m_DraggingNativeTitleBarCaption)
                {
                    break;
                }

                if (GUIUtility.hotControl == id)
                {
                    GUIUtility.hotControl = 0;
                    Event.current.Use();
                    Unsupported.SetAllowCursorLock(true, Unsupported.DisallowCursorLockReasons.SizeMove);
                }
                break;

            case EventType.MouseDrag:
                if (m_DraggingNativeTitleBarCaption)
                {
                    break;
                }

                if (GUIUtility.hotControl == id)
                {
                    Vector2 mousePos = evt.mousePosition;
                    if (startDragDpi != GUIUtility.pixelsPerPoint)
                    {
                        // We ignore this mouse event when changing screens in multi monitor setups with
                        // different dpi scalings as funky things might/will happen
                        startDragDpi       = GUIUtility.pixelsPerPoint;
                        s_LastDragMousePos = mousePos;
                    }
                    else
                    {
                        Vector2 movement = mousePos - s_LastDragMousePos;

                        float minimumDelta = 1.0f / GUIUtility.pixelsPerPoint;

                        if (Mathf.Abs(movement.x) >= minimumDelta || Mathf.Abs(movement.y) >= minimumDelta)
                        {
                            Rect dragPosition = position;
                            dragPosition.x += movement.x;
                            dragPosition.y += movement.y;
                            position        = dragPosition;

                            GUI.changed = true;
                        }
                    }
                }
                break;
            }
        }
Esempio n. 34
0
			public static void UpdateMesh(Unsupported.ProgressiveMesh pm, int targetTriCount, Mesh mesh)
			{
				Unsupported.ProgressiveMesh.UpdateMeshImpl(pm.opaquePtr, targetTriCount, mesh);
			}