Beispiel #1
0
 private static void LoadDefaultLayout()
 {
     InternalEditorUtility.LoadDefaultLayout();
 }
    private void DrawFiltersGUI()
    {
        EditorGUILayout.LabelField("Filters", EditorStyles.boldLabel);
        EditorGUILayout.BeginVertical(EditorStyles.helpBox);

        DrawProperty(nameof(showColliders));
        DrawProperty(nameof(showTriggers));

        // Collider type filter foldout
        colliderTypeFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(colliderTypeFoldout, "Collider Types");

        if (colliderTypeFoldout)
        {
            DrawProperty(nameof(showBoxColliders), new GUIContent("Box"));
            DrawProperty(nameof(showSphereColliders), new GUIContent("Sphere"));
            DrawProperty(nameof(showCapsuleColliders), new GUIContent("Capsule"));
            DrawProperty(nameof(showMeshColliders), new GUIContent("Mesh"));
            DrawProperty(nameof(showConvexMeshColliders), new GUIContent("Convex Mesh*", "The non convex mesh will be rendered"));
        }

        EditorGUILayout.EndFoldoutHeaderGroup();

        // Layer filter foldout
        layerFilterFoldout = EditorGUILayout.BeginFoldoutHeaderGroup(layerFilterFoldout, "Layers");

        if (layerFilterFoldout)
        {
            SerializedProperty layersFilterProperty = serializedObject.FindProperty(nameof(layerFilter));

            // Quick select buttons
            EditorGUILayout.BeginHorizontal();
            if (GUILayout.Button("All"))
            {
                layersFilterProperty.intValue = -1;
            }
            if (GUILayout.Button("None"))
            {
                layersFilterProperty.intValue = 0;
            }
            EditorGUILayout.EndHorizontal();

            // Layer mask checkboxes
            EditorGUI.BeginChangeCheck();
            int      concatenatedLayersMask = InternalEditorUtility.LayerMaskToConcatenatedLayersMask(layerFilter);
            string[] layers = InternalEditorUtility.layers;

            for (int i = 0; i < layers.Length; i++)
            {
                if (EditorGUILayout.Toggle(layers[i], (concatenatedLayersMask & (1 << i)) != 0))
                {
                    concatenatedLayersMask |= 1 << i;
                }
                else
                {
                    concatenatedLayersMask &= ~(1 << i);
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                layersFilterProperty.intValue =
                    InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(concatenatedLayersMask);
            }
        }

        EditorGUILayout.EndFoldoutHeaderGroup();

        // Tag filter
        DrawProperty(nameof(tags));

        EditorGUILayout.EndVertical();
    }
 private void OnDestroy()
 {
     InternalEditorUtility.BumpMapSettingsFixingWindowReportResult(0);
 }
Beispiel #4
0
        public void Inspector()
        {
            Index = GetIndex();

            Utility.SetGUIColor(UltiDraw.DarkGrey);
            using (new EditorGUILayout.VerticalScope("Box")) {
                Utility.ResetGUIColor();

                Utility.SetGUIColor(UltiDraw.LightGrey);
                using (new EditorGUILayout.VerticalScope("Box")) {
                    Utility.ResetGUIColor();

                    EditorGUILayout.BeginHorizontal();
                    Target.Folder = EditorGUILayout.TextField("Folder", "Assets/" + Target.Folder.Substring(Mathf.Min(7, Target.Folder.Length)));
                    if (Utility.GUIButton("Import", UltiDraw.DarkGrey, UltiDraw.White))
                    {
                        Import();
                    }
                    EditorGUILayout.EndHorizontal();


                    Utility.SetGUIColor(Target.GetActor() == null ? UltiDraw.DarkRed : UltiDraw.White);
                    Target.Actor = (Actor)EditorGUILayout.ObjectField("Actor", Target.GetActor(), typeof(Actor), true);
                    Utility.ResetGUIColor();

                    EditorGUILayout.ObjectField("Environment", Target.GetEnvironment(), typeof(Transform), true);

                    SetNameFilter(EditorGUILayout.TextField("Name Filter", NameFilter));
                    SetExportFilter(EditorGUILayout.Toggle("Export Filter", ExportFilter));
                    SetExcludeFilter(EditorGUILayout.Toggle("Exclude Filter", ExcludeFilter));

                    if (Instances.Length == 0)
                    {
                        LoadFile(-1);
                        EditorGUILayout.LabelField("No data available.");
                    }
                    else
                    {
                        LoadFile(EditorGUILayout.Popup("Data " + "(" + Instances.Length + ")", Index, Names));
                        EditorGUILayout.BeginHorizontal();
                        LoadFile(EditorGUILayout.IntSlider(Index + 1, 1, Instances.Length) - 1);
                        if (Utility.GUIButton("<", UltiDraw.DarkGrey, UltiDraw.White))
                        {
                            LoadFile(Mathf.Max(Index - 1, 0));
                        }
                        if (Utility.GUIButton(">", UltiDraw.DarkGrey, UltiDraw.White))
                        {
                            LoadFile(Mathf.Min(Index + 1, Instances.Length - 1));
                        }
                        EditorGUILayout.EndHorizontal();
                    }
                }

                if (Target.GetCurrentFile() != null)
                {
                    Target.GetCurrentFile().Data.Repair(Target);
                    Utility.SetGUIColor(UltiDraw.Grey);
                    using (new EditorGUILayout.VerticalScope("Box")) {
                        Utility.ResetGUIColor();
                        Frame frame = Target.GetCurrentFrame();

                        Utility.SetGUIColor(UltiDraw.Mustard);
                        using (new EditorGUILayout.VerticalScope("Box")) {
                            Utility.ResetGUIColor();
                            EditorGUILayout.BeginHorizontal();
                            GUILayout.FlexibleSpace();
                            EditorGUILayout.LabelField(Target.GetCurrentFile().Data.name, GUILayout.Width(100f));
                            EditorGUILayout.LabelField("Frames: " + Target.GetCurrentFile().Data.GetTotalFrames(), GUILayout.Width(100f));
                            EditorGUILayout.LabelField("Time: " + Target.GetCurrentFile().Data.GetTotalTime().ToString("F3") + "s", GUILayout.Width(100f));
                            EditorGUILayout.LabelField("Framerate: " + Target.GetCurrentFile().Data.Framerate.ToString("F1") + "Hz", GUILayout.Width(130f));
                            EditorGUILayout.LabelField("Timescale:", GUILayout.Width(65f), GUILayout.Height(20f));
                            Target.Timescale = EditorGUILayout.FloatField(Target.Timescale, GUILayout.Width(30f), GUILayout.Height(20f));
                            if (Utility.GUIButton("Mirror", Target.Mirror ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                            {
                                Target.SetMirror(!Target.Mirror);
                            }
                            GUILayout.FlexibleSpace();
                            EditorGUILayout.EndHorizontal();
                        }

                        Utility.SetGUIColor(UltiDraw.DarkGrey);
                        using (new EditorGUILayout.VerticalScope("Box")) {
                            Utility.ResetGUIColor();
                            EditorGUILayout.BeginHorizontal();
                            GUILayout.FlexibleSpace();
                            if (Target.Playing)
                            {
                                if (Utility.GUIButton("||", Color.red, Color.black, 20f, 20f))
                                {
                                    Target.StopAnimation();
                                }
                            }
                            else
                            {
                                if (Utility.GUIButton("|>", Color.green, Color.black, 20f, 20f))
                                {
                                    Target.PlayAnimation();
                                }
                            }
                            if (Utility.GUIButton("<<", UltiDraw.Grey, UltiDraw.White, 30f, 20f))
                            {
                                Target.LoadFrame(Mathf.Max(Target.GetCurrentFrame().Index - Mathf.RoundToInt(Target.GetCurrentFile().Data.Framerate), 1));
                            }
                            if (Utility.GUIButton("<", UltiDraw.Grey, UltiDraw.White, 20f, 20f))
                            {
                                Target.LoadPreviousFrame();
                            }
                            if (Utility.GUIButton(">", UltiDraw.Grey, UltiDraw.White, 20f, 20f))
                            {
                                Target.LoadNextFrame();
                            }
                            if (Utility.GUIButton(">>", UltiDraw.Grey, UltiDraw.White, 30f, 20f))
                            {
                                Target.LoadFrame(Mathf.Min(Target.GetCurrentFrame().Index + Mathf.RoundToInt(Target.GetCurrentFile().Data.Framerate), Target.GetCurrentFile().Data.GetTotalFrames()));
                            }
                            int index = EditorGUILayout.IntSlider(frame.Index, 1, Target.GetCurrentFile().Data.GetTotalFrames(), GUILayout.Width(440f));
                            if (index != frame.Index)
                            {
                                Target.LoadFrame(index);
                            }
                            EditorGUILayout.LabelField(frame.Timestamp.ToString("F3") + "s", Utility.GetFontColor(Color.white), GUILayout.Width(50f));
                            GUILayout.FlexibleSpace();
                            EditorGUILayout.EndHorizontal();
                            EditorGUILayout.BeginHorizontal();
                            GUILayout.FlexibleSpace();
                            Target.Window = EditorGUILayout.Slider(Target.Window, 0f, 1f);
                            GUILayout.FlexibleSpace();
                            EditorGUILayout.EndHorizontal();
                        }
                    }
                    for (int i = 0; i < Target.GetCurrentFile().Data.Modules.Length; i++)
                    {
                        Target.GetCurrentFile().Data.Modules[i].Inspector(Target);
                    }
                    string[] modules = new string[(int)Module.TYPE.Length + 1];
                    modules[0] = "Add Module...";
                    for (int i = 1; i < modules.Length; i++)
                    {
                        modules[i] = ((Module.TYPE)(i - 1)).ToString();
                    }
                    int module = EditorGUILayout.Popup(0, modules);
                    if (module > 0)
                    {
                        Target.GetCurrentFile().Data.AddModule((Module.TYPE)(module - 1));
                    }
                    if (Utility.GUIButton("Settings", Target.InspectSettings ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                    {
                        Target.InspectSettings = !Target.InspectSettings;
                    }
                    if (Target.InspectSettings)
                    {
                        StyleModule styleModule = (StyleModule)Target.GetCurrentFile().Data.GetModule(Module.TYPE.Style);

                        Utility.SetGUIColor(UltiDraw.LightGrey);
                        using (new EditorGUILayout.VerticalScope("Box")) {
                            Utility.ResetGUIColor();
                            Target.GetCurrentFile().Data.Export = EditorGUILayout.Toggle("Export", Target.GetCurrentFile().Data.Export);
                            Target.SetScaling(EditorGUILayout.FloatField("Scaling", Target.GetCurrentFile().Data.Scaling));
                            Target.GetCurrentFile().Data.RootSmoothing = EditorGUILayout.IntField("Root Smoothing", Target.GetCurrentFile().Data.RootSmoothing);
                            Target.GetCurrentFile().Data.Ground = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUILayout.MaskField("Ground Mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Target.GetCurrentFile().Data.Ground), InternalEditorUtility.layers));
                            Target.GetCurrentFile().Data.ForwardAxis = (MotionData.AXIS)EditorGUILayout.EnumPopup("Forward Axis", Target.GetCurrentFile().Data.ForwardAxis);

                            Target.GetCurrentFile().Data.MirrorAxis = (MotionData.AXIS)EditorGUILayout.EnumPopup("Mirror Axis", Target.GetCurrentFile().Data.MirrorAxis);
                            string[] names = new string[Target.GetCurrentFile().Data.Source.Bones.Length];
                            for (int i = 0; i < Target.GetCurrentFile().Data.Source.Bones.Length; i++)
                            {
                                names[i] = Target.GetCurrentFile().Data.Source.Bones[i].Name;
                            }
                            for (int i = 0; i < Target.GetCurrentFile().Data.Source.Bones.Length; i++)
                            {
                                EditorGUILayout.BeginHorizontal();
                                Target.GetCurrentFile().Data.Source.Bones[i].Active = EditorGUILayout.Toggle(Target.GetCurrentFile().Data.Source.Bones[i].Active);
                                EditorGUI.BeginDisabledGroup(true);
                                EditorGUILayout.TextField(names[i]);
                                EditorGUI.EndDisabledGroup();
                                Target.GetCurrentFile().Data.SetSymmetry(i, EditorGUILayout.Popup(Target.GetCurrentFile().Data.Symmetry[i], names));

                                if (names[i] == "Head")
                                {
                                    float x = 90f;
                                    if (Target.Mirror)
                                    {
                                        x = -90f;
                                    }
                                    Target.GetCurrentFile().Data.Source.Bones[i].Alignment = EditorGUILayout.Vector3Field("", new Vector3(x, 0f, 0f));
                                }
                                else
                                {
                                    Target.GetCurrentFile().Data.Source.Bones[i].Alignment = EditorGUILayout.Vector3Field("", Target.GetCurrentFile().Data.Source.Bones[i].Alignment);
                                }
                                EditorGUILayout.EndHorizontal();
                            }

                            Utility.SetGUIColor(UltiDraw.Grey);
                            using (new EditorGUILayout.VerticalScope("Box")) {
                                Utility.ResetGUIColor();

                                Utility.SetGUIColor(UltiDraw.Cyan);
                                using (new EditorGUILayout.VerticalScope("Box")) {
                                    Utility.ResetGUIColor();
                                    EditorGUILayout.LabelField("Camera");
                                }

                                if (Utility.GUIButton("Auto Focus", Target.AutoFocus ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                                {
                                    Target.SetAutoFocus(!Target.AutoFocus);
                                }
                                Target.FocusHeight    = EditorGUILayout.FloatField("Focus Height", Target.FocusHeight);
                                Target.FocusOffset    = EditorGUILayout.FloatField("Focus Offset", Target.FocusOffset);
                                Target.FocusDistance  = EditorGUILayout.FloatField("Focus Distance", Target.FocusDistance);
                                Target.FocusAngle     = EditorGUILayout.Slider("Focus Angle", Target.FocusAngle, 0f, 360f);
                                Target.FocusSmoothing = EditorGUILayout.Slider("Focus Smoothing", Target.FocusSmoothing, 0f, 1f);
                            }

                            if (Utility.GUIButton("Copy Hierarchy", UltiDraw.DarkGrey, UltiDraw.White))
                            {
                                Target.CopyHierarchy();
                            }
                            if (Utility.GUIButton("Detect Symmetry", UltiDraw.DarkGrey, UltiDraw.White))
                            {
                                Target.GetCurrentFile().Data.DetectSymmetry();
                            }
                            if (Utility.GUIButton("Create Skeleton", UltiDraw.DarkGrey, UltiDraw.White))
                            {
                                Target.CreateSkeleton();
                            }

                            EditorGUILayout.BeginHorizontal();
                            if (Utility.GUIButton("Add Export Sequence", UltiDraw.DarkGrey, UltiDraw.White))
                            {
                                Target.GetCurrentFile().Data.AddSequence(1, Target.GetCurrentFile().Data.GetTotalFrames());
                            }
                            if (Utility.GUIButton("Remove Export Sequence", UltiDraw.DarkGrey, UltiDraw.White))
                            {
                                Target.GetCurrentFile().Data.RemoveSequence();
                            }
                            EditorGUILayout.EndHorizontal();
                            for (int i = 0; i < Target.GetCurrentFile().Data.Sequences.Length; i++)
                            {
                                Utility.SetGUIColor(UltiDraw.Grey);
                                using (new EditorGUILayout.VerticalScope("Box")) {
                                    Utility.ResetGUIColor();

                                    EditorGUILayout.BeginHorizontal();
                                    GUILayout.FlexibleSpace();
                                    if (Utility.GUIButton("X", Color.cyan, Color.black, 15f, 15f))
                                    {
                                        Target.GetCurrentFile().Data.Sequences[i].SetStart(Target.GetCurrentFrame().Index);
                                    }
                                    EditorGUILayout.LabelField("Start", GUILayout.Width(50f));
                                    Target.GetCurrentFile().Data.Sequences[i].SetStart(EditorGUILayout.IntField(Target.GetCurrentFile().Data.Sequences[i].Start, GUILayout.Width(100f)));
                                    EditorGUILayout.LabelField("End", GUILayout.Width(50f));
                                    Target.GetCurrentFile().Data.Sequences[i].SetEnd(EditorGUILayout.IntField(Target.GetCurrentFile().Data.Sequences[i].End, GUILayout.Width(100f)));
                                    if (Utility.GUIButton("X", Color.cyan, Color.black, 15f, 15f))
                                    {
                                        Target.GetCurrentFile().Data.Sequences[i].SetEnd(Target.GetCurrentFrame().Index);
                                    }
                                    GUILayout.FlexibleSpace();
                                    EditorGUILayout.EndHorizontal();
                                }
                            }
                        }
                    }
                }
            }
        }
    public override void OnInspectorGUI()
    {
        FadeObstructionsManager fade = target as FadeObstructionsManager;

        fade.Camera = (Camera)EditorGUILayout.ObjectField(new GUIContent("Camera", "Fading is camera dependant, we fade the objects between something and the camera"), fade.Camera, typeof(Camera), true);

        fade.FinalAlpha = EditorGUILayout.Slider(new GUIContent("Final Alpha", "The final alpha of the objects that get faded. If you would like to override this on a specific object you can place a FadeObjectOptions script on that object."), fade.FinalAlpha, 0.0f, 1.0f);
        if (fade.FinalAlpha < 0)
        {
            fade.FinalAlpha = 0;
        }
        if (fade.FinalAlpha > 1)
        {
            fade.FinalAlpha = 1;
        }

        fade.FadeOutSeconds = EditorGUILayout.FloatField(new GUIContent("Fade Out Seconds", "Specify the number of seconds it takes for objects to fade out. If you would like to override this on a specific object you can place a FadeObjectOptions script on that object."), fade.FadeOutSeconds);
        if (fade.FadeOutSeconds < 0)
        {
            fade.FadeOutSeconds = 0;
        }

        fade.FadeInSeconds = EditorGUILayout.FloatField(new GUIContent("Fade In Seconds", "Specify the number of seconds it takes for objects to fade back in. If you would like to override this on a specific object you can place a FadeObjectOptions script on that object."), fade.FadeInSeconds);
        if (fade.FadeInSeconds < 0)
        {
            fade.FadeInSeconds = 0;
        }


        fade.RayRadius = EditorGUILayout.FloatField(new GUIContent("Radius", "A ray is cast from the camera to your objects that should always be visible, this specifies the ray radius"), fade.RayRadius);
        if (fade.RayRadius < 0)
        {
            fade.RayRadius = 0;
        }

        fade.LayerMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUILayout.MaskField("Layer Mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(fade.LayerMask), InternalEditorUtility.layers));
    }
Beispiel #6
0
    static BuildReport BuildGame(string[] scenes, string buildPath, string exeName, BuildTarget target,
                                 BuildOptions opts, string buildId, ScriptingImplementation scriptingImplementation, bool includeEditorMetadata = false)
    {
        var    exePathName   = buildPath + "/" + exeName;
        string fullBuildPath = Directory.GetCurrentDirectory() + "/" + buildPath;
        // var levels = new List<string>
        // {
        //     "Assets/Scenes/bootstrapper.unity",
        //     "Assets/Scenes/empty.unity"
        // };

        var levels = scenes.ToList();

        // Add scenes referenced from levelinfo's
        // foreach (var li in LoadLevelInfos())
        //     levels.Add(AssetDatabase.GetAssetPath(li.main_scene));

        Debug.Log("Levels in build:");
        foreach (var l in levels)
        {
            Debug.Log(string.Format(" - {0}", l));
        }

        Debug.Log("Building: " + exePathName);
        Directory.CreateDirectory(buildPath);

        if (scriptingImplementation == ScriptingImplementation.WinRTDotNET)
        {
            throw new Exception(string.Format("Unsupported scriptingImplementation {0}", scriptingImplementation));
        }

        //MakeBuildFilesWritable(fullBuildPath);
        //using (new MakeInstallationFilesWritableScope())
        {
            var il2cpp = scriptingImplementation == ScriptingImplementation.IL2CPP;

            var monoDirs   = Directory.GetDirectories(fullBuildPath).Where(s => s.Contains("MonoBleedingEdge"));
            var il2cppDirs = Directory.GetDirectories(fullBuildPath)
                             .Where(s => s.Contains("BackUpThisFolder_ButDontShipItWithYourGame"));
            var clearFolder = (il2cpp && monoDirs.Count() > 0) || (!il2cpp && il2cppDirs.Count() > 0);
            if (clearFolder)
            {
                Debug.Log(" deleting old folders ..");
                foreach (var file in Directory.GetFiles(fullBuildPath))
                {
                    File.Delete(file);
                }
                foreach (var dir in monoDirs)
                {
                    Directory.Delete(dir, true);
                }
                foreach (var dir in il2cppDirs)
                {
                    Directory.Delete(dir, true);
                }
                foreach (var dir in Directory.GetDirectories(fullBuildPath).Where(s => s.EndsWith("_Data")))
                {
                    Directory.Delete(dir, true);
                }
            }

            PlayerSettings.SetScriptingBackend(BuildTargetGroup.Standalone, scriptingImplementation);

            if (il2cpp)
            {
                PlayerSettings.SetIl2CppCompilerConfiguration(BuildTargetGroup.Standalone,
                                                              Il2CppCompilerConfiguration.Release);
            }

            if (includeEditorMetadata)
            {
                //PerformanceTest.SaveEditorInfo(opts, target);
            }

            Environment.SetEnvironmentVariable("BUILD_ID", buildId, EnvironmentVariableTarget.Process);
            Environment.SetEnvironmentVariable("BUILD_UNITY_VERSION", InternalEditorUtility.GetFullUnityVersion(),
                                               EnvironmentVariableTarget.Process);

            var time = DateTime.Now;
            Debug.Log("BuildPipeline.BuildPlayer started");
            var result = BuildPipeline.BuildPlayer(levels.ToArray(), exePathName, target, opts);
            Debug.Log("BuildPipeline.BuildPlayer ended. Duration:" + (DateTime.Now - time).TotalSeconds + "s");

            Environment.SetEnvironmentVariable("BUILD_ID", "", EnvironmentVariableTarget.Process);
            Environment.SetEnvironmentVariable("BUILD_UNITY_VERSION", "", EnvironmentVariableTarget.Process);

            Debug.Log(" ==== Build Done =====");

            var stepCount = result.steps.Count();
            Debug.Log(" Steps:" + stepCount);
            for (var i = 0; i < stepCount; i++)
            {
                var step = result.steps[i];
                Debug.Log("-- " + (i + 1) + "/" + stepCount + " " + step.name + " " + step.duration.Seconds + "s --");
                foreach (var msg in step.messages)
                {
                    Debug.Log(msg.content);
                }
            }

            return(result);
        }
    }
 public static void ToggleFakeNonDeveloperBuild()
 {
     Unsupported.fakeNonDeveloperBuild = !Unsupported.fakeNonDeveloperBuild;
     InternalEditorUtility.RequestScriptReload();
     InternalEditorUtility.RepaintAllViews();
 }
Beispiel #8
0
        public void ApplySettings()
        {
            // TODO: Fix this method for Unity 3/4, reflection props will be null
#if (UNITY_5 || UNITY_5_3_OR_NEWER)
            var sceneRenderSettings = new SerializedObject(GetRenderSettings.Invoke(null, null) as UnityObject);
#endif
#if !(UNITY_3_4 || UNITY_3_3 || UNITY_3_2 || UNITY_3_1 || UNITY_3_0_0 || UNITY_3_0)
            var sceneNavMeshBuildSettings = new SerializedObject(NavMeshBuilder.navMeshSettingsObject);
#if !UNITY_3_5
            var sceneLightmapEditorSettings = new SerializedObject(GetLightmapEditorSettings.Invoke(null, null) as UnityObject);
#endif
#endif

            var lightmaps     = UnityEngine.LightmapSettings.lightmaps;
            var lightmapCount = lightmaps.Length;
            lightmapSettings.lightmaps = new LightmapData[lightmapCount];

            var serializedObject = new SerializedObject(this);
            var iterator         = serializedObject.GetIterator();
            var hasNext          = true;
            // ReSharper disable once AssignmentInConditionalExpression
            while (hasNext && (hasNext = iterator.NextVisible(true)))
            {
                var propertyPath = iterator.propertyPath;
                if (propertyPath.Contains("occlusionCullingSettings"))
                {
                    ApplySettingFromProperty(OcclusionCullingProperties, iterator);
                }

#if UNITY_5 || UNITY_5_3_OR_NEWER
                if (propertyPath.Contains("renderSettings"))
                {
                    ApplySettingFromPropertyToObject(sceneRenderSettings, iterator);
                }
#else
                if (propertyPath.Contains("renderSettings"))
                {
                    CaptureSettingToProperty(RenderSettingsProperties, iterator);
                }
#endif

                if (propertyPath.Contains("lightmapSettings"))
                {
                    CaptureSettingToProperty(LightmapSettingsProperties, iterator);
                }

#if !(UNITY_3_4 || UNITY_3_3 || UNITY_3_2 || UNITY_3_1 || UNITY_3_0_0 || UNITY_3_0)
                if (propertyPath.Contains("navMeshBuildSettings"))
                {
                    ApplySettingFromPropertyToObject(sceneNavMeshBuildSettings, iterator, "m_BuildSettings.");
                }

                if (propertyPath == "lightmapSettings.lightmaps")
                {
                    if (iterator.arraySize == 0)
                    {
                        continue;
                    }

                    iterator.NextVisible(true);                     // Move past ArraySize
                    iterator.NextVisible(true);                     // Move past first element
                    var depth = iterator.depth;
                    for (var i = 0; i < lightmapCount; i++)
                    {
                        var lightmapData = lightmaps[i];
                        // ReSharper disable once AssignmentInConditionalExpression
                        while (hasNext = iterator.NextVisible(true))
                        {
                            if (iterator.depth <= depth)
                            {
                                break;
                            }
                            // Unused variable will allow for other array types in the future (like NavMeshBuildSettings)
                            propertyPath = iterator.propertyPath;
                            ApplySettingFromProperty(LightmapDataProperties, iterator, lightmapData);
                        }
                    }
                }
#if !UNITY_3_5
                if (propertyPath.Contains("lightmapEditorSettings"))
                {
                    ApplySettingFromPropertyToObject(sceneLightmapEditorSettings, iterator, "m_LightmapEditorSettings.");
                }

                if (propertyPath.Contains("giSettings"))
                {
                    ApplySettingFromPropertyToObject(sceneLightmapEditorSettings, iterator, "m_GISettings.");
                }
#endif
#endif

                if (!hasNext)
                {
                    break;
                }
            }

#if UNITY_4 || UNITY_5 || UNITY5_3_OR_NEWER
            sceneRenderSettings.ApplyModifiedProperties();
            sceneLightmapEditorSettings.ApplyModifiedProperties();
#endif

#if !(UNITY_3_4 || UNITY_3_3 || UNITY_3_2 || UNITY_3_1 || UNITY_3_0_0 || UNITY_3_0)
            sceneNavMeshBuildSettings.ApplyModifiedProperties();

            InternalEditorUtility.RepaintAllViews();
#endif
        }
        public void DoDeletedItemsGUI(ASHistoryWindow parentWin, Rect theRect, GUIStyle s, float offset, float endOffset, bool focused)
        {
            Event     current = Event.current;
            Texture2D image   = EditorGUIUtility.FindTexture(EditorResourcesUtility.folderIconName);

            offset += 3f;
            Rect position = new Rect(this.m_Indent, offset, theRect.width - this.m_Indent, ASHistoryFileView.m_RowHeight);

            if (current.type == EventType.MouseDown && position.Contains(current.mousePosition))
            {
                GUIUtility.keyboardControl = this.m_FileViewControlID;
                this.SelType = ASHistoryFileView.SelectionType.DeletedItemsRoot;
                this.ScrollToDeletedItem(-1);
                parentWin.DoLocalSelectionChange();
            }
            position.width -= position.x;
            position.x      = 0f;
            GUIContent gUIContent = new GUIContent("Deleted Assets");

            gUIContent.image = image;
            int left = (int)this.m_BaseIndent;

            s.padding.left = left;
            if (current.type == EventType.Repaint)
            {
                s.Draw(position, gUIContent, false, false, this.SelType == ASHistoryFileView.SelectionType.DeletedItemsRoot, focused);
            }
            Rect position2 = new Rect(this.m_BaseIndent - this.m_FoldoutSize, offset, this.m_FoldoutSize, ASHistoryFileView.m_RowHeight);

            if (!this.m_DeletedItemsInitialized || this.m_DelPVstate.lv.totalRows != 0)
            {
                this.DeletedItemsToggle = GUI.Toggle(position2, this.DeletedItemsToggle, GUIContent.none, ASHistoryFileView.ms_Styles.foldout);
            }
            offset += ASHistoryFileView.m_RowHeight;
            if (!this.DeletedItemsToggle)
            {
                return;
            }
            int row  = this.m_DelPVstate.lv.row;
            int num  = 0;
            int num2 = -1;
            int num3 = -1;
            int num4 = 0;

            while (offset <= endOffset && num4 < this.m_DelPVstate.lv.totalRows)
            {
                if (offset + ASHistoryFileView.m_RowHeight >= 0f)
                {
                    if (num2 == -1)
                    {
                        this.m_DelPVstate.IndexToFolderAndFile(num4, ref num2, ref num3);
                    }
                    position = new Rect(0f, offset, (float)Screen.width, ASHistoryFileView.m_RowHeight);
                    ParentViewFolder parentViewFolder = this.m_DelPVstate.folders[num2];
                    if (current.type == EventType.MouseDown && position.Contains(current.mousePosition))
                    {
                        if (current.button != 1 || this.SelType != ASHistoryFileView.SelectionType.DeletedItems || !this.m_DelPVstate.selectedItems[num])
                        {
                            GUIUtility.keyboardControl = this.m_FileViewControlID;
                            this.SelType             = ASHistoryFileView.SelectionType.DeletedItems;
                            this.m_DelPVstate.lv.row = num;
                            ListViewShared.MultiSelection(null, row, this.m_DelPVstate.lv.row, ref this.m_DelPVstate.initialSelectedItem, ref this.m_DelPVstate.selectedItems);
                            this.ScrollToDeletedItem(num);
                            parentWin.DoLocalSelectionChange();
                        }
                        if (current.button == 1 && this.SelType == ASHistoryFileView.SelectionType.DeletedItems)
                        {
                            GUIUtility.hotControl = 0;
                            Rect position3 = new Rect(current.mousePosition.x, current.mousePosition.y, 1f, 1f);
                            EditorUtility.DisplayCustomMenu(position3, this.dropDownMenuItems, -1, new EditorUtility.SelectMenuItemFunction(this.ContextMenuClick), null);
                        }
                        Event.current.Use();
                    }
                    if (num3 != -1)
                    {
                        gUIContent.text  = parentViewFolder.files[num3].name;
                        gUIContent.image = InternalEditorUtility.GetIconForFile(parentViewFolder.files[num3].name);
                        left             = (int)(this.m_BaseIndent + this.m_Indent * 2f);
                    }
                    else
                    {
                        gUIContent.text  = parentViewFolder.name;
                        gUIContent.image = image;
                        left             = (int)(this.m_BaseIndent + this.m_Indent);
                    }
                    s.padding.left = left;
                    if (Event.current.type == EventType.Repaint)
                    {
                        s.Draw(position, gUIContent, false, false, this.m_DelPVstate.selectedItems[num], focused);
                    }
                    this.m_DelPVstate.NextFileFolder(ref num2, ref num3);
                    num++;
                }
                num4++;
                offset += ASHistoryFileView.m_RowHeight;
            }
        }
Beispiel #10
0
 void NewElement(Rect buttonRect, ReorderableList list)
 {
     buttonRect.x -= 400;
     buttonRect.y -= 13;
     PopupWindow.Show(buttonRect, new EnterNamePopup(m_Tags, s => { InternalEditorUtility.AddTag(s); }));
 }
Beispiel #11
0
 public void ReorderSortLayerList(ReorderableList list)
 {
     InternalEditorUtility.UpdateSortingLayersOrder();
 }
Beispiel #12
0
        public void Inspector()
        {
            Utility.SetGUIColor(UltiDraw.Grey);
            using (new EditorGUILayout.VerticalScope("Box")) {
                Utility.ResetGUIColor();

                Utility.SetGUIColor(UltiDraw.DarkGrey);
                using (new EditorGUILayout.VerticalScope("Box")) {
                    Utility.ResetGUIColor();

                    Utility.SetGUIColor(UltiDraw.Cyan);
                    using (new EditorGUILayout.VerticalScope("Box")) {
                        Utility.ResetGUIColor();

                        EditorGUILayout.BeginHorizontal();
                        Target.Folder = EditorGUILayout.TextField("Folder", "Assets/" + Target.Folder.Substring(Mathf.Min(7, Target.Folder.Length)));
                        if (Utility.GUIButton("Load", UltiDraw.DarkGrey, UltiDraw.White))
                        {
                            Target.Load();
                            GenerateNames();
                        }
                        EditorGUILayout.EndHorizontal();

                        Utility.SetGUIColor(Target.GetActor() == null ? UltiDraw.DarkRed : UltiDraw.White);
                        Target.Actor = (Actor)EditorGUILayout.ObjectField("Actor", Target.GetActor(), typeof(Actor), true);
                        Utility.ResetGUIColor();

                        EditorGUILayout.ObjectField("Environment", Target.GetEnvironment(), typeof(Transform), true);

                        EditorGUILayout.BeginHorizontal();
                        if (Target.Files.Length == 0)
                        {
                            Target.LoadFile(-1);
                            EditorGUILayout.LabelField("No data available.");
                        }
                        else
                        {
                            Target.LoadFile(EditorGUILayout.Popup("Data " + "(" + Target.Files.Length + ")", Target.ID, Names));
                            EditorGUILayout.EndHorizontal();
                            Target.LoadFile(EditorGUILayout.IntSlider(Target.ID + 1, 1, Target.Files.Length) - 1);
                            EditorGUILayout.BeginHorizontal();
                            if (Utility.GUIButton("<", UltiDraw.Grey, UltiDraw.White))
                            {
                                Target.LoadPreviousFile();
                            }
                            if (Utility.GUIButton(">", UltiDraw.Grey, UltiDraw.White))
                            {
                                Target.LoadNextFile();
                            }
                        }
                        EditorGUILayout.EndHorizontal();

                        /*
                         * if(GUILayout.Button("Import", GUILayout.Width(50f))) {
                         *      string folder = EditorUtility.OpenFolderPanel("Motion Editor", Application.dataPath, "");
                         *      GUI.SetNextControlName("");
                         *      GUI.FocusControl("");
                         *      int pivot = folder.IndexOf("Assets");
                         *      if(pivot >= 0) {
                         *              folder = folder.Substring(pivot);
                         *              if(AssetDatabase.IsValidFolder(folder)) {
                         *                      Target.Import(folder);
                         *              }
                         *      }
                         *      GUIUtility.ExitGUI();
                         * }
                         */
                        /*
                         * if(GUILayout.Button("-", GUILayout.Width(18f))) {
                         *      Target.RemoveData();
                         * }
                         * if(GUILayout.Button("R", GUILayout.Width(18f))) {
                         *      Target.RefreshData();
                         * }
                         */
                        //EditorGUILayout.EndHorizontal();
                    }

                    Utility.SetGUIColor(UltiDraw.Grey);
                    using (new EditorGUILayout.VerticalScope("Box")) {
                        Utility.ResetGUIColor();

                        Utility.SetGUIColor(UltiDraw.Cyan);
                        using (new EditorGUILayout.VerticalScope("Box")) {
                            Utility.ResetGUIColor();
                            EditorGUILayout.LabelField("Camera");
                        }

                        if (Utility.GUIButton("Auto Focus", Target.AutoFocus ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                        {
                            Target.SetAutoFocus(!Target.AutoFocus);
                        }
                        Target.FocusHeight    = EditorGUILayout.FloatField("Focus Height", Target.FocusHeight);
                        Target.FocusOffset    = EditorGUILayout.FloatField("Focus Offset", Target.FocusOffset);
                        Target.FocusDistance  = EditorGUILayout.FloatField("Focus Distance", Target.FocusDistance);
                        Target.FocusAngle     = EditorGUILayout.Slider("Focus Angle", Target.FocusAngle, 0f, 360f);
                        Target.FocusSmoothing = EditorGUILayout.Slider("Focus Smoothing", Target.FocusSmoothing, 0f, 1f);
                    }

                    if (Target.GetData() != null)
                    {
                        MotionData.Frame frame = Target.GetData().GetFrame(Target.Timestamp);

                        Utility.SetGUIColor(UltiDraw.Mustard);
                        using (new EditorGUILayout.VerticalScope("Box")) {
                            Utility.ResetGUIColor();
                            EditorGUILayout.BeginHorizontal();
                            GUILayout.FlexibleSpace();
                            EditorGUILayout.LabelField("Frames: " + Target.GetData().GetTotalFrames(), GUILayout.Width(100f));
                            EditorGUILayout.LabelField("Time: " + Target.GetData().GetTotalTime().ToString("F3") + "s", GUILayout.Width(100f));
                            EditorGUILayout.LabelField("Framerate: " + Target.GetData().Framerate.ToString("F1") + "Hz", GUILayout.Width(130f));
                            EditorGUILayout.LabelField("Timescale:", GUILayout.Width(65f), GUILayout.Height(20f));
                            Target.Timescale = EditorGUILayout.FloatField(Target.Timescale, GUILayout.Width(30f), GUILayout.Height(20f));
                            GUILayout.FlexibleSpace();
                            EditorGUILayout.EndHorizontal();
                        }

                        EditorGUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        if (Target.Playing)
                        {
                            if (Utility.GUIButton("||", Color.red, Color.black, 20f, 20f))
                            {
                                Target.StopAnimation();
                            }
                        }
                        else
                        {
                            if (Utility.GUIButton("|>", Color.green, Color.black, 20f, 20f))
                            {
                                Target.PlayAnimation();
                            }
                        }
                        if (Utility.GUIButton("<", UltiDraw.Grey, UltiDraw.White, 20f, 20f))
                        {
                            Target.LoadPreviousFrame();
                        }
                        if (Utility.GUIButton(">", UltiDraw.Grey, UltiDraw.White, 20f, 20f))
                        {
                            Target.LoadNextFrame();
                        }
                        int index = EditorGUILayout.IntSlider(frame.Index, 1, Target.GetData().GetTotalFrames(), GUILayout.Width(440f));
                        if (index != frame.Index)
                        {
                            Target.LoadFrame(index);
                        }
                        EditorGUILayout.LabelField(frame.Timestamp.ToString("F3") + "s", Utility.GetFontColor(Color.white), GUILayout.Width(50f));
                        GUILayout.FlexibleSpace();
                        EditorGUILayout.EndHorizontal();

                        if (Utility.GUIButton("Mirror", Target.Mirror ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                        {
                            Target.SetMirror(!Target.Mirror);
                        }

                        EditorGUILayout.BeginHorizontal();
                        if (Utility.GUIButton("Motion", Target.ShowMotion ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                        {
                            Target.ShowMotion = !Target.ShowMotion;
                        }
                        if (Utility.GUIButton("Trajectory", Target.ShowTrajectory ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                        {
                            Target.ShowTrajectory = !Target.ShowTrajectory;
                        }
                        if (Utility.GUIButton("Velocities", Target.ShowVelocities ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                        {
                            Target.ShowVelocities = !Target.ShowVelocities;
                        }
                        if (Utility.GUIButton("Height Map", Target.ShowHeightMap ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                        {
                            Target.ShowHeightMap = !Target.ShowHeightMap;
                        }
                        if (Utility.GUIButton("Depth Map", Target.ShowDepthMap ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                        {
                            Target.ShowDepthMap = !Target.ShowDepthMap;
                        }
                        if (Utility.GUIButton("Depth Image", Target.ShowDepthImage ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                        {
                            Target.ShowDepthImage = !Target.ShowDepthImage;
                        }
                        EditorGUILayout.EndHorizontal();

                        Utility.SetGUIColor(UltiDraw.Grey);
                        using (new EditorGUILayout.VerticalScope("Box")) {
                            Utility.ResetGUIColor();

                            Utility.SetGUIColor(UltiDraw.Mustard);
                            using (new EditorGUILayout.VerticalScope("Box")) {
                                Utility.ResetGUIColor();
                                Target.InspectFrame = EditorGUILayout.Toggle("Style Plugin", Target.InspectFrame);
                            }

                            if (Target.InspectFrame)
                            {
                                Color[] colors = UltiDraw.GetRainbowColors(Target.GetData().Styles.Length);
                                for (int i = 0; i < Target.GetData().Styles.Length; i++)
                                {
                                    float height = 25f;
                                    EditorGUILayout.BeginHorizontal();
                                    if (Utility.GUIButton(Target.GetData().Styles[i], !frame.StyleFlags[i] ? colors[i].Transparent(0.25f) : colors[i], UltiDraw.White, 200f, height))
                                    {
                                        frame.ToggleStyle(i);
                                    }
                                    Rect c = EditorGUILayout.GetControlRect();
                                    Rect r = new Rect(c.x, c.y, frame.StyleValues[i] * c.width, height);
                                    EditorGUI.DrawRect(r, colors[i].Transparent(0.75f));
                                    EditorGUILayout.FloatField(frame.StyleValues[i], GUILayout.Width(50f));
                                    EditorGUILayout.EndHorizontal();
                                }
                                EditorGUILayout.BeginHorizontal();
                                if (Utility.GUIButton("<", UltiDraw.DarkGrey, UltiDraw.White, 25f, 50f))
                                {
                                    MotionData.Frame previous = frame.GetAnyPreviousStyleKey();
                                    Target.LoadFrame(previous == null ? 0f : previous.Timestamp);
                                }
                                EditorGUILayout.BeginVertical(GUILayout.Height(50f));
                                Rect ctrl = EditorGUILayout.GetControlRect();
                                Rect rect = new Rect(ctrl.x, ctrl.y, ctrl.width, 50f);
                                EditorGUI.DrawRect(rect, UltiDraw.Black);
                                UltiDraw.Begin();
                                //Sequences
                                for (int i = 0; i < Target.GetData().Sequences.Length; i++)
                                {
                                    float   start = rect.x + (float)(Target.GetData().Sequences[i].Start - 1) / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width;
                                    float   end   = rect.x + (float)(Target.GetData().Sequences[i].End - 1) / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width;
                                    Vector3 a     = new Vector3(start, rect.y, 0f);
                                    Vector3 b     = new Vector3(end, rect.y, 0f);
                                    Vector3 c     = new Vector3(start, rect.y + rect.height, 0f);
                                    Vector3 d     = new Vector3(end, rect.y + rect.height, 0f);
                                    UltiDraw.DrawTriangle(a, c, b, UltiDraw.Yellow.Transparent(0.25f));
                                    UltiDraw.DrawTriangle(b, c, d, UltiDraw.Yellow.Transparent(0.25f));
                                }
                                //Styles
                                for (int i = 0; i < Target.GetData().Styles.Length; i++)
                                {
                                    int x = 0;
                                    for (int j = 1; j < Target.GetData().GetTotalFrames(); j++)
                                    {
                                        float val = Target.GetData().Frames[j].StyleValues[i];
                                        if (
                                            Target.GetData().Frames[x].StyleValues[i] < 1f && val == 1f ||
                                            Target.GetData().Frames[x].StyleValues[i] > 0f && val == 0f
                                            )
                                        {
                                            float xStart = rect.x + (float)(Mathf.Max(x - 1, 0)) / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width;
                                            float xEnd   = rect.x + (float)j / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width;
                                            float yStart = rect.y + (1f - Target.GetData().Frames[Mathf.Max(x - 1, 0)].StyleValues[i]) * rect.height;
                                            float yEnd   = rect.y + (1f - Target.GetData().Frames[j].StyleValues[i]) * rect.height;
                                            UltiDraw.DrawLine(new Vector3(xStart, yStart, 0f), new Vector3(xEnd, yEnd, 0f), colors[i]);
                                            x = j;
                                        }
                                        if (
                                            Target.GetData().Frames[x].StyleValues[i] == 0f && val > 0f ||
                                            Target.GetData().Frames[x].StyleValues[i] == 1f && val < 1f
                                            )
                                        {
                                            float xStart = rect.x + (float)(x) / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width;
                                            float xEnd   = rect.x + (float)(j - 1) / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width;
                                            float yStart = rect.y + (1f - Target.GetData().Frames[x].StyleValues[i]) * rect.height;
                                            float yEnd   = rect.y + (1f - Target.GetData().Frames[j - 1].StyleValues[i]) * rect.height;
                                            UltiDraw.DrawLine(new Vector3(xStart, yStart, 0f), new Vector3(xEnd, yEnd, 0f), colors[i]);
                                            x = j;
                                        }
                                        if (j == Target.GetData().GetTotalFrames() - 1)
                                        {
                                            float xStart = rect.x + (float)x / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width;
                                            float xEnd   = rect.x + (float)(j - 1) / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width;
                                            float yStart = rect.y + (1f - Target.GetData().Frames[x].StyleValues[i]) * rect.height;
                                            float yEnd   = rect.y + (1f - Target.GetData().Frames[j - 1].StyleValues[i]) * rect.height;
                                            UltiDraw.DrawLine(new Vector3(xStart, yStart, 0f), new Vector3(xEnd, yEnd, 0f), colors[i]);
                                            x = j;
                                        }
                                    }
                                }
                                float pivot = rect.x + (float)(frame.Index - 1) / (float)(Target.GetData().GetTotalFrames() - 1) * rect.width;
                                UltiDraw.DrawLine(new Vector3(pivot, rect.y, 0f), new Vector3(pivot, rect.y + rect.height, 0f), UltiDraw.White);
                                UltiDraw.DrawWireCircle(new Vector3(pivot, rect.y, 0f), 8f, UltiDraw.Green);
                                UltiDraw.DrawWireCircle(new Vector3(pivot, rect.y + rect.height, 0f), 8f, UltiDraw.Green);
                                UltiDraw.End();
                                EditorGUILayout.EndVertical();
                                if (Utility.GUIButton(">", UltiDraw.DarkGrey, UltiDraw.White, 25f, 50f))
                                {
                                    MotionData.Frame next = frame.GetAnyNextStyleKey();
                                    Target.LoadFrame(next == null ? Target.GetData().GetTotalTime() : next.Timestamp);
                                }
                                EditorGUILayout.EndHorizontal();
                            }

                            Utility.SetGUIColor(UltiDraw.Mustard);
                            using (new EditorGUILayout.VerticalScope("Box")) {
                                Utility.ResetGUIColor();
                                Target.InspectExport = EditorGUILayout.Toggle("Export", Target.InspectExport);
                            }

                            if (Target.InspectExport)
                            {
                                Target.GetData().Export = EditorGUILayout.Toggle("Export", Target.GetData().Export);
                                for (int i = 0; i < Target.GetData().Sequences.Length; i++)
                                {
                                    Utility.SetGUIColor(UltiDraw.LightGrey);
                                    using (new EditorGUILayout.VerticalScope("Box")) {
                                        Utility.ResetGUIColor();

                                        EditorGUILayout.BeginHorizontal();
                                        GUILayout.FlexibleSpace();
                                        if (Utility.GUIButton("X", Color.cyan, Color.black, 15f, 15f))
                                        {
                                            Target.GetData().Sequences[i].SetStart(Target.GetState().Index);
                                        }
                                        EditorGUILayout.LabelField("Start", GUILayout.Width(50f));
                                        Target.GetData().Sequences[i].SetStart(EditorGUILayout.IntField(Target.GetData().Sequences[i].Start, GUILayout.Width(100f)));
                                        EditorGUILayout.LabelField("End", GUILayout.Width(50f));
                                        Target.GetData().Sequences[i].SetEnd(EditorGUILayout.IntField(Target.GetData().Sequences[i].End, GUILayout.Width(100f)));
                                        if (Utility.GUIButton("X", Color.cyan, Color.black, 15f, 15f))
                                        {
                                            Target.GetData().Sequences[i].SetEnd(Target.GetState().Index);
                                        }
                                        GUILayout.FlexibleSpace();
                                        EditorGUILayout.EndHorizontal();

                                        for (int s = 0; s < Target.GetData().Styles.Length; s++)
                                        {
                                            EditorGUILayout.BeginHorizontal();
                                            GUILayout.FlexibleSpace();
                                            EditorGUILayout.LabelField(Target.GetData().Styles[s], GUILayout.Width(50f));
                                            EditorGUILayout.LabelField("Style Copies", GUILayout.Width(100f));
                                            Target.GetData().Sequences[i].SetStyleCopies(s, EditorGUILayout.IntField(Target.GetData().Sequences[i].StyleCopies[s], GUILayout.Width(100f)));
                                            EditorGUILayout.LabelField("Transition Copies", GUILayout.Width(100f));
                                            Target.GetData().Sequences[i].SetTransitionCopies(s, EditorGUILayout.IntField(Target.GetData().Sequences[i].TransitionCopies[s], GUILayout.Width(100f)));
                                            GUILayout.FlexibleSpace();
                                            EditorGUILayout.EndHorizontal();
                                        }
                                        //for(int c=0; c<Target.GetData().Sequences[i].Copies.Length; c++) {
                                        //	EditorGUILayout.LabelField("Copy " + (c+1) + " - " + "Start: " + Target.GetData().Sequences[i].Copies[c].Start + " End: " + Target.GetData().Sequences[i].Copies[c].End);
                                        //}
                                    }
                                }
                                EditorGUILayout.BeginHorizontal();
                                if (Utility.GUIButton("Add", UltiDraw.DarkGrey, UltiDraw.White))
                                {
                                    Target.GetData().AddSequence(1, Target.GetData().GetTotalFrames());
                                }
                                if (Utility.GUIButton("Remove", UltiDraw.DarkGrey, UltiDraw.White))
                                {
                                    Target.GetData().RemoveSequence();
                                }
                                EditorGUILayout.EndHorizontal();
                            }

                            Utility.SetGUIColor(UltiDraw.Mustard);
                            using (new EditorGUILayout.VerticalScope("Box")) {
                                Utility.ResetGUIColor();
                                Target.InspectSettings = EditorGUILayout.Toggle("Settings", Target.InspectSettings);
                            }

                            if (Target.InspectSettings)
                            {
                                Utility.SetGUIColor(UltiDraw.LightGrey);
                                using (new EditorGUILayout.VerticalScope("Box")) {
                                    Utility.ResetGUIColor();
                                    if (Utility.GUIButton("Create Skeleton", UltiDraw.DarkGrey, UltiDraw.White))
                                    {
                                        Target.CreateSkeleton();
                                    }
                                }

                                Utility.SetGUIColor(UltiDraw.LightGrey);
                                using (new EditorGUILayout.VerticalScope("Box")) {
                                    Utility.ResetGUIColor();
                                    EditorGUILayout.LabelField("General");

                                    Target.GetData().Scaling       = EditorGUILayout.FloatField("Scaling", Target.GetData().Scaling);
                                    Target.GetData().RootSmoothing = EditorGUILayout.IntField("Root Smoothing", Target.GetData().RootSmoothing);

                                    Target.GetData().GroundMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUILayout.MaskField("Ground Mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Target.GetData().GroundMask), InternalEditorUtility.layers));
                                    Target.GetData().ObjectMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUILayout.MaskField("Object Mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Target.GetData().ObjectMask), InternalEditorUtility.layers));

                                    string[] names = new string[Target.GetData().Source.Bones.Length];
                                    for (int i = 0; i < Target.GetData().Source.Bones.Length; i++)
                                    {
                                        names[i] = Target.GetData().Source.Bones[i].Name;
                                    }
                                    Target.GetData().HeightMapSensor    = EditorGUILayout.Popup("Height Map Sensor", Target.GetData().HeightMapSensor, names);
                                    Target.GetData().HeightMapSize      = EditorGUILayout.Slider("Height Map Size", Target.GetData().HeightMapSize, 0f, 1f);
                                    Target.GetData().DepthMapSensor     = EditorGUILayout.Popup("Depth Map Sensor", Target.GetData().DepthMapSensor, names);
                                    Target.GetData().DepthMapAxis       = (MotionData.AXIS)EditorGUILayout.EnumPopup("Depth Map Axis", Target.GetData().DepthMapAxis);
                                    Target.GetData().DepthMapResolution = EditorGUILayout.IntField("Depth Map Resolution", Target.GetData().DepthMapResolution);
                                    Target.GetData().DepthMapSize       = EditorGUILayout.FloatField("Depth Map Size", Target.GetData().DepthMapSize);
                                    Target.GetData().DepthMapDistance   = EditorGUILayout.FloatField("Depth Map Distance", Target.GetData().DepthMapDistance);

                                    Target.GetData().SetStyleTransition(EditorGUILayout.Slider("Style Transition", Target.GetData().StyleTransition, 0.1f, 1f));
                                    for (int i = 0; i < Target.GetData().Styles.Length; i++)
                                    {
                                        EditorGUILayout.BeginHorizontal();
                                        Target.GetData().Styles[i] = EditorGUILayout.TextField("Style " + (i + 1), Target.GetData().Styles[i]);
                                        EditorGUILayout.EndHorizontal();
                                    }
                                    EditorGUILayout.BeginHorizontal();
                                    if (Utility.GUIButton("Add Style", UltiDraw.DarkGrey, UltiDraw.White))
                                    {
                                        Target.GetData().AddStyle("Style");
                                    }
                                    if (Utility.GUIButton("Remove Style", UltiDraw.DarkGrey, UltiDraw.White))
                                    {
                                        Target.GetData().RemoveStyle();
                                    }
                                    EditorGUILayout.EndHorizontal();
                                }

                                Utility.SetGUIColor(UltiDraw.LightGrey);
                                using (new EditorGUILayout.VerticalScope("Box")) {
                                    Utility.ResetGUIColor();
                                    EditorGUILayout.LabelField("Geometry");
                                    Target.GetData().MirrorAxis = (MotionData.AXIS)EditorGUILayout.EnumPopup("Mirror Axis", Target.GetData().MirrorAxis);
                                    string[] names = new string[Target.GetData().Source.Bones.Length];
                                    for (int i = 0; i < Target.GetData().Source.Bones.Length; i++)
                                    {
                                        names[i] = Target.GetData().Source.Bones[i].Name;
                                    }
                                    for (int i = 0; i < Target.GetData().Source.Bones.Length; i++)
                                    {
                                        EditorGUILayout.BeginHorizontal();
                                        EditorGUI.BeginDisabledGroup(true);
                                        EditorGUILayout.TextField(names[i]);
                                        EditorGUI.EndDisabledGroup();
                                        Target.GetData().SetSymmetry(i, EditorGUILayout.Popup(Target.GetData().Symmetry[i], names));
                                        EditorGUILayout.EndHorizontal();
                                    }
                                    if (Utility.GUIButton("Detect Symmetry", UltiDraw.DarkGrey, UltiDraw.White))
                                    {
                                        Target.GetData().DetectSymmetry();
                                    }
                                }

                                for (int i = 0; i < Target.Plugins.Length; i++)
                                {
                                    EditorGUILayout.LabelField(Target.Plugins[i].Type.ToString());
                                    if (Utility.GUIButton("Remove", UltiDraw.Red, UltiDraw.White))
                                    {
                                        Target.RemovePlugin(Target.Plugins[i].Type);
                                    }
                                }

                                string[] types = new string[3] {
                                    "Add Plugin...", "Style", "Phase"
                                };
                                switch (EditorGUILayout.Popup(0, types))
                                {
                                case 0:
                                    break;

                                case 1:
                                    Target.AddPlugin(MotionPlugin.TYPE.Style);
                                    break;

                                case 2:
                                    Target.AddPlugin(MotionPlugin.TYPE.Phase);
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
 // The authentication token
 static string GetToken()
 {
     return(InternalEditorUtility.GetAuthToken());
 }
Beispiel #14
0
 private static void RevertFactorySettings()
 {
     InternalEditorUtility.RevertFactoryLayoutSettings(true);
 }
Beispiel #15
0
    protected virtual void UiMainWizard()
    {
        GUILayout.Space(15);

        // title
        UiTitleBox(CurrentLang.PUNWizardLabel, BackgroundImage);

        // wizard info text
        GUILayout.Label(CurrentLang.WizardMainWindowInfo);
        GUILayout.Space(15);


        // pun+ info
        if (isPunPlus)
        {
            GUILayout.Label(CurrentLang.MobilePunPlusExportNoteLabel);
            GUILayout.Space(15);
        }
#if !(UNITY_5_0 || UNITY_5)
        else if (!InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.Android) || !InternalEditorUtility.HasAdvancedLicenseOnBuildTarget(BuildTarget.iOS))
        {
            GUILayout.Label(CurrentLang.MobileExportNoteLabel);
            GUILayout.Space(15);
        }
#endif

        // settings button
        GUILayout.BeginHorizontal();
        GUILayout.Label(CurrentLang.SettingsButton, EditorStyles.boldLabel, GUILayout.Width(100));
        GUILayout.BeginVertical();
        if (GUILayout.Button(new GUIContent(CurrentLang.LocateSettingsButton, CurrentLang.SettingsHighlightLabel)))
        {
            HighlightSettings();
        }
        if (GUILayout.Button(new GUIContent(CurrentLang.OpenCloudDashboardText, CurrentLang.OpenCloudDashboardTooltip)))
        {
            Application.OpenURL(UrlCloudDashboard + Uri.EscapeUriString(this.mailOrAppId));
        }
        if (GUILayout.Button(new GUIContent(CurrentLang.SetupButton, CurrentLang.SetupServerCloudLabel)))
        {
            this.photonSetupState = PhotonSetupStates.RegisterForPhotonCloud;
        }
        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
        GUILayout.Space(15);


        EditorGUILayout.Separator();


        // documentation
        GUILayout.BeginHorizontal();
        GUILayout.Label(CurrentLang.DocumentationLabel, EditorStyles.boldLabel, GUILayout.Width(100));
        GUILayout.BeginVertical();
        if (GUILayout.Button(new GUIContent(CurrentLang.OpenPDFText, CurrentLang.OpenPDFTooltip)))
        {
            EditorUtility.OpenWithDefaultApp(DocumentationLocation);
        }

        if (GUILayout.Button(new GUIContent(CurrentLang.OpenDevNetText, CurrentLang.OpenDevNetTooltip)))
        {
            Application.OpenURL(UrlDevNet);
        }

        GUI.skin.label.wordWrap = true;
        GUILayout.Label(CurrentLang.OwnHostCloudCompareLabel);
        if (GUILayout.Button(CurrentLang.ComparisonPageButton))
        {
            Application.OpenURL(UrlCompare);
        }


        if (GUILayout.Button(new GUIContent(CurrentLang.OpenForumText, CurrentLang.OpenForumTooltip)))
        {
            Application.OpenURL(UrlForum);
        }

        GUILayout.EndVertical();
        GUILayout.EndHorizontal();
    }
Beispiel #16
0
 protected override void DerivedInspector(MotionEditor editor)
 {
     Radius = EditorGUILayout.FloatField("Radius", Radius);
     Mask   = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUILayout.MaskField("Mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Mask), InternalEditorUtility.layers));
 }
        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++;
                            }
                        }
                    }
                    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();
        }
Beispiel #18
0
        internal bool DrawInspector(Rect contentRect)
        {
            if (GameObjectInspector.s_styles == null)
            {
                GameObjectInspector.s_styles = new GameObjectInspector.Styles();
            }
            base.serializedObject.Update();
            GameObject gameObject = this.target as GameObject;

            EditorGUIUtility.labelWidth = 52f;
            bool enabled = GUI.enabled;

            GUI.enabled = true;
            GUI.Label(new Rect(contentRect.x, contentRect.y, contentRect.width, contentRect.height + 3f), GUIContent.none, EditorStyles.inspectorBig);
            GUI.enabled = enabled;
            float      width      = contentRect.width;
            float      y          = contentRect.y;
            GUIContent gUIContent = null;
            PrefabType prefabType = PrefabType.None;

            if (this.m_AllOfSamePrefabType)
            {
                prefabType = PrefabUtility.GetPrefabType(gameObject);
                switch (prefabType)
                {
                case PrefabType.None:
                    gUIContent = GameObjectInspector.s_styles.goIcon;
                    break;

                case PrefabType.Prefab:
                case PrefabType.PrefabInstance:
                case PrefabType.DisconnectedPrefabInstance:
                    gUIContent = GameObjectInspector.s_styles.prefabIcon;
                    break;

                case PrefabType.ModelPrefab:
                case PrefabType.ModelPrefabInstance:
                case PrefabType.DisconnectedModelPrefabInstance:
                    gUIContent = GameObjectInspector.s_styles.modelIcon;
                    break;

                case PrefabType.MissingPrefabInstance:
                    gUIContent = GameObjectInspector.s_styles.prefabIcon;
                    break;
                }
            }
            else
            {
                gUIContent = GameObjectInspector.s_styles.typelessIcon;
            }
            EditorGUI.ObjectIconDropDown(new Rect(3f, 4f + y, 24f, 24f), base.targets, true, gUIContent.image as Texture2D, this.m_Icon);
            using (new EditorGUI.DisabledScope(prefabType == PrefabType.ModelPrefab))
            {
                EditorGUI.PropertyField(new Rect(34f, 4f + y, 14f, 14f), this.m_IsActive, GUIContent.none);
                float num    = GameObjectInspector.s_styles.staticFieldToggleWidth + 15f;
                float width2 = width - 52f - num - 5f;
                EditorGUI.DelayedTextField(new Rect(52f, 4f + y + 1f, width2, 16f), this.m_Name, GUIContent.none);
                Rect rect = new Rect(width - num, 4f + y, GameObjectInspector.s_styles.staticFieldToggleWidth, 16f);
                EditorGUI.BeginProperty(rect, GUIContent.none, this.m_StaticEditorFlags);
                EditorGUI.BeginChangeCheck();
                Rect position = rect;
                EditorGUI.showMixedValue |= GameObjectInspector.ShowMixedStaticEditorFlags((StaticEditorFlags)this.m_StaticEditorFlags.intValue);
                Event     current = Event.current;
                EventType type    = current.type;
                bool      flag    = current.type == EventType.MouseDown && current.button != 0;
                if (flag)
                {
                    current.type = EventType.Ignore;
                }
                bool flagValue = EditorGUI.ToggleLeft(position, "Static", gameObject.isStatic);
                if (flag)
                {
                    current.type = type;
                }
                EditorGUI.showMixedValue = false;
                if (EditorGUI.EndChangeCheck())
                {
                    SceneModeUtility.SetStaticFlags(base.targets, -1, flagValue);
                    base.serializedObject.SetIsDifferentCacheDirty();
                }
                EditorGUI.EndProperty();
                EditorGUI.BeginChangeCheck();
                EditorGUI.showMixedValue = this.m_StaticEditorFlags.hasMultipleDifferentValues;
                int  changedFlags;
                bool flagValue2;
                EditorGUI.EnumMaskField(new Rect(rect.x + GameObjectInspector.s_styles.staticFieldToggleWidth, rect.y, 10f, 14f), GameObjectUtility.GetStaticEditorFlags(gameObject), GameObjectInspector.s_styles.staticDropdown, out changedFlags, out flagValue2);
                EditorGUI.showMixedValue = false;
                if (EditorGUI.EndChangeCheck())
                {
                    SceneModeUtility.SetStaticFlags(base.targets, changedFlags, flagValue2);
                    base.serializedObject.SetIsDifferentCacheDirty();
                }
                float num2 = 4f;
                float num3 = 4f;
                EditorGUIUtility.fieldWidth = (width - num2 - 52f - GameObjectInspector.s_styles.layerFieldWidth - num3) / 2f;
                string tag = null;
                try
                {
                    tag = gameObject.tag;
                }
                catch (Exception)
                {
                    tag = "Undefined";
                }
                EditorGUIUtility.labelWidth = GameObjectInspector.s_styles.tagFieldWidth;
                Rect rect2 = new Rect(52f - EditorGUIUtility.labelWidth, 24f + y, EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth, 16f);
                EditorGUI.BeginProperty(rect2, GUIContent.none, this.m_Tag);
                EditorGUI.BeginChangeCheck();
                string text = EditorGUI.TagField(rect2, EditorGUIUtility.TempContent("Tag"), tag);
                if (EditorGUI.EndChangeCheck())
                {
                    this.m_Tag.stringValue = text;
                    Undo.RecordObjects(base.targets, "Change Tag of " + this.targetTitle);
                    UnityEngine.Object[] targets = base.targets;
                    for (int i = 0; i < targets.Length; i++)
                    {
                        UnityEngine.Object @object = targets[i];
                        (@object as GameObject).tag = text;
                    }
                }
                EditorGUI.EndProperty();
                EditorGUIUtility.labelWidth = GameObjectInspector.s_styles.layerFieldWidth;
                rect2 = new Rect(52f + EditorGUIUtility.fieldWidth + num2, 24f + y, EditorGUIUtility.labelWidth + EditorGUIUtility.fieldWidth, 16f);
                EditorGUI.BeginProperty(rect2, GUIContent.none, this.m_Layer);
                EditorGUI.BeginChangeCheck();
                int num4 = EditorGUI.LayerField(rect2, EditorGUIUtility.TempContent("Layer"), gameObject.layer);
                if (EditorGUI.EndChangeCheck())
                {
                    GameObjectUtility.ShouldIncludeChildren shouldIncludeChildren = GameObjectUtility.DisplayUpdateChildrenDialogIfNeeded(base.targets.OfType <GameObject>(), "Change Layer", "Do you want to set layer to " + InternalEditorUtility.GetLayerName(num4) + " for all child objects as well?");
                    if (shouldIncludeChildren != GameObjectUtility.ShouldIncludeChildren.Cancel)
                    {
                        this.m_Layer.intValue = num4;
                        this.SetLayer(num4, shouldIncludeChildren == GameObjectUtility.ShouldIncludeChildren.IncludeChildren);
                    }
                }
                EditorGUI.EndProperty();
                if (this.m_HasInstance)
                {
                    using (new EditorGUI.DisabledScope(EditorApplication.isPlayingOrWillChangePlaymode))
                    {
                        float      num5        = (width - 52f - 5f) / 3f;
                        Rect       position2   = new Rect(52f + num5 * 0f, 44f + y, num5, 15f);
                        Rect       position3   = new Rect(52f + num5 * 1f, 44f + y, num5, 15f);
                        Rect       position4   = new Rect(52f + num5 * 2f, 44f + y, num5, 15f);
                        Rect       position5   = new Rect(52f, 44f + y, num5 * 3f, 15f);
                        GUIContent gUIContent2 = (base.targets.Length <= 1) ? GameObjectInspector.s_styles.goTypeLabel[(int)prefabType] : GameObjectInspector.s_styles.goTypeLabelMultiple;
                        if (gUIContent2 != null)
                        {
                            float x = GUI.skin.label.CalcSize(gUIContent2).x;
                            if (prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.MissingPrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance)
                            {
                                GUI.contentColor = GUI.skin.GetStyle("CN StatusWarn").normal.textColor;
                                if (prefabType == PrefabType.MissingPrefabInstance)
                                {
                                    GUI.Label(new Rect(52f, 44f + y, width - 52f - 5f, 18f), gUIContent2, EditorStyles.whiteLabel);
                                }
                                else
                                {
                                    GUI.Label(new Rect(52f - x - 5f, 44f + y, width - 52f - 5f, 18f), gUIContent2, EditorStyles.whiteLabel);
                                }
                                GUI.contentColor = Color.white;
                            }
                            else
                            {
                                Rect position6 = new Rect(52f - x - 5f, 44f + y, x, 18f);
                                GUI.Label(position6, gUIContent2);
                            }
                        }
                        if (base.targets.Length > 1)
                        {
                            GUI.Label(position5, "Instance Management Disabled", GameObjectInspector.s_styles.instanceManagementInfo);
                        }
                        else
                        {
                            if (prefabType != PrefabType.MissingPrefabInstance && GUI.Button(position2, "Select", "MiniButtonLeft"))
                            {
                                Selection.activeObject = PrefabUtility.GetPrefabParent(this.target);
                                EditorGUIUtility.PingObject(Selection.activeObject);
                            }
                            if ((prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance) && GUI.Button(position3, "Revert", "MiniButtonMid"))
                            {
                                List <UnityEngine.Object> hierarchy = new List <UnityEngine.Object>();
                                this.GetObjectListFromHierarchy(hierarchy, gameObject);
                                Undo.RegisterFullObjectHierarchyUndo(gameObject, "Revert to prefab");
                                PrefabUtility.ReconnectToLastPrefab(gameObject);
                                Undo.RegisterCreatedObjectUndo(PrefabUtility.GetPrefabObject(gameObject), "Revert to prefab");
                                PrefabUtility.RevertPrefabInstance(gameObject);
                                this.CalculatePrefabStatus();
                                List <UnityEngine.Object> list = new List <UnityEngine.Object>();
                                this.GetObjectListFromHierarchy(list, gameObject);
                                this.RegisterNewComponents(list, hierarchy);
                            }
                            using (new EditorGUI.DisabledScope(AnimationMode.InAnimationMode()))
                            {
                                if ((prefabType == PrefabType.ModelPrefabInstance || prefabType == PrefabType.PrefabInstance) && GUI.Button(position3, "Revert", "MiniButtonMid"))
                                {
                                    List <UnityEngine.Object> hierarchy2 = new List <UnityEngine.Object>();
                                    this.GetObjectListFromHierarchy(hierarchy2, gameObject);
                                    Undo.RegisterFullObjectHierarchyUndo(gameObject, "Revert Prefab Instance");
                                    PrefabUtility.RevertPrefabInstance(gameObject);
                                    this.CalculatePrefabStatus();
                                    List <UnityEngine.Object> list2 = new List <UnityEngine.Object>();
                                    this.GetObjectListFromHierarchy(list2, gameObject);
                                    this.RegisterNewComponents(list2, hierarchy2);
                                }
                                if (prefabType == PrefabType.PrefabInstance || prefabType == PrefabType.DisconnectedPrefabInstance)
                                {
                                    GameObject gameObject2 = PrefabUtility.FindValidUploadPrefabInstanceRoot(gameObject);
                                    GUI.enabled = (gameObject2 != null && !AnimationMode.InAnimationMode());
                                    if (GUI.Button(position4, "Apply", "MiniButtonRight"))
                                    {
                                        UnityEngine.Object prefabParent = PrefabUtility.GetPrefabParent(gameObject2);
                                        string             assetPath    = AssetDatabase.GetAssetPath(prefabParent);
                                        bool flag2 = Provider.PromptAndCheckoutIfNeeded(new string[]
                                        {
                                            assetPath
                                        }, "The version control requires you to check out the prefab before applying changes.");
                                        if (flag2)
                                        {
                                            PrefabUtility.ReplacePrefab(gameObject2, prefabParent, ReplacePrefabOptions.ConnectToPrefab);
                                            this.CalculatePrefabStatus();
                                            EditorSceneManager.MarkSceneDirty(gameObject2.scene);
                                            GUIUtility.ExitGUI();
                                        }
                                    }
                                }
                            }
                            if ((prefabType == PrefabType.DisconnectedModelPrefabInstance || prefabType == PrefabType.ModelPrefabInstance) && GUI.Button(position4, "Open", "MiniButtonRight"))
                            {
                                AssetDatabase.OpenAsset(PrefabUtility.GetPrefabParent(this.target));
                                GUIUtility.ExitGUI();
                            }
                        }
                    }
                }
            }
            base.serializedObject.ApplyModifiedProperties();
            return(true);
        }
Beispiel #19
0
        public void OnGUI()
        {
            LoadLogos();
            GUILayout.Space(10);
            GUILayout.BeginHorizontal();
            GUILayout.Space(5);
            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();
            GUILayout.Label(s_Header, GUIStyle.none);

            ListenForSecretCodes();

            var licenseTypeString = "";

            if (InternalEditorUtility.HasFreeLicense())
            {
                licenseTypeString = " Personal";
            }
            if (InternalEditorUtility.HasEduLicense())
            {
                licenseTypeString = " Edu";
            }

            GUILayout.BeginHorizontal();
            GUILayout.Space(52f); // Ident version information

            string extensionVersion = FormatExtensionVersionString();

            m_ShowDetailedVersion |= Event.current.alt;
            if (m_ShowDetailedVersion)
            {
                int      t            = InternalEditorUtility.GetUnityVersionDate();
                DateTime dt           = new DateTime(1970, 1, 1, 0, 0, 0, 0);
                string   branch       = InternalEditorUtility.GetUnityBuildBranch();
                string   branchString = "";
                if (branch.Length > 0)
                {
                    branchString = "Branch: " + branch;
                }
                EditorGUILayout.SelectableLabel(
                    string.Format("Version {0}{1}{2}\n{3:r}\n{4}", InternalEditorUtility.GetFullUnityVersion(), licenseTypeString, extensionVersion, dt.AddSeconds(t), branchString),
                    GUILayout.Width(550), GUILayout.Height(50));

                m_TextInitialYPos = 120 - 12;
            }
            else
            {
                GUILayout.Label(string.Format("Version {0}{1}{2}", Application.unityVersion, licenseTypeString, extensionVersion));
            }

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

            GUILayout.EndHorizontal();
            GUILayout.Space(4);
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

            GUILayout.FlexibleSpace();

            float creditsWidth = position.width - 10;
            float chunkOffset  = m_TextYPos;

            Rect scrollAreaRect = GUILayoutUtility.GetRect(10, m_TextInitialYPos);

            GUI.BeginGroup(scrollAreaRect);
            foreach (string nameChunk in AboutWindowNames.Names(null, true))
            {
                chunkOffset = DoCreditsNameChunk(nameChunk, creditsWidth, chunkOffset);
            }
            chunkOffset          = DoCreditsNameChunk(kSpecialThanksNames, creditsWidth, chunkOffset);
            m_TotalCreditsHeight = chunkOffset - m_TextYPos;
            GUI.EndGroup();

            HandleScrollEvents(scrollAreaRect);

            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            GUILayout.Label(s_MonoLogo);
            GUILayout.Label("Scripting powered by The Mono Project.\n\n(c) 2011 Novell, Inc.", "MiniLabel", GUILayout.Width(200));
            GUILayout.Label(s_AgeiaLogo);
            GUILayout.Label("Physics powered by PhysX.\n\n(c) 2011 NVIDIA Corporation.", "MiniLabel", GUILayout.Width(200));
            GUILayout.EndHorizontal();
            GUILayout.FlexibleSpace();
            GUILayout.BeginHorizontal();
            GUILayout.Space(5);
            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();

            var VSTUlabel = UnityVSSupport.GetAboutWindowLabel();

            if (VSTUlabel.Length > 0)
            {
                GUILayout.Label(VSTUlabel, "MiniLabel");
            }
            GUILayout.Label(InternalEditorUtility.GetUnityCopyright(), "MiniLabel");
            GUILayout.EndVertical();
            GUILayout.Space(10);
            GUILayout.FlexibleSpace();
            GUILayout.BeginVertical();
            GUILayout.FlexibleSpace();
            GUILayout.Label(InternalEditorUtility.GetLicenseInfo(), "AboutWindowLicenseLabel");
            GUILayout.EndVertical();
            GUILayout.Space(5);
            GUILayout.EndHorizontal();

            GUILayout.Space(5);
        }
        private void LightmapDebugInfo(int index)
        {
            if (!showDebugInfo)
            {
                return;
            }

            GUILayout.Space(5);
            GUILayout.BeginVertical();

            LightmapConvergence lc = Lightmapping.GetLightmapConvergence(index);

            if (lc.IsValid())
            {
                GUILayout.Label("Occupied: " + InternalEditorUtility.CountToString((ulong)lc.occupiedTexelCount), EditorStyles.miniLabel);

                GUIContent direct = EditorGUIUtility.TrTextContent("Direct: " + lc.minDirectSamples + " / " + lc.maxDirectSamples + " / " + lc.avgDirectSamples + "", "min / max / avg samples per texel");
                GUILayout.Label(direct, EditorStyles.miniLabel);

                GUIContent gi = EditorGUIUtility.TrTextContent("GI: " + lc.minGISamples + " / " + lc.maxGISamples + " / " + lc.avgGISamples + "", "min / max / avg samples per texel");
                GUILayout.Label(gi, EditorStyles.miniLabel);

                GUIContent env = EditorGUIUtility.TrTextContent("Environment: " + lc.minEnvSamples + " / " + lc.maxEnvSamples + " / " + lc.avgEnvSamples + "", "min / max / avg samples per texel");
                GUILayout.Label(env, EditorStyles.miniLabel);
            }
            else
            {
                GUILayout.Label("Occupied: N/A", EditorStyles.miniLabel);
                GUILayout.Label("Direct: N/A", EditorStyles.miniLabel);
                GUILayout.Label("GI: N/A", EditorStyles.miniLabel);
                GUILayout.Label("Environment: N/A", EditorStyles.miniLabel);
            }
            float mraysPerSec = Lightmapping.GetLightmapBakePerformance(index);

            if (mraysPerSec >= 0.0)
            {
                GUILayout.Label(mraysPerSec.ToString("0.00", CultureInfo.InvariantCulture.NumberFormat) + " mrays/sec", EditorStyles.miniLabel);
            }
            else
            {
                GUILayout.Label("N/A mrays/sec", EditorStyles.miniLabel);
            }

            GUILayout.EndVertical();
            GUILayout.Space(5);
            GUILayout.BeginVertical();

            LightmapMemory lightmapMemory = Lightmapping.GetLightmapMemory(index);

            GUILayout.Label("Lightmap data: " + SizeString(lightmapMemory.lightmapDataSizeCPU), EditorStyles.miniLabel);

            GUIContent lightmapTexturesSizeContent = null;

            if (lightmapMemory.lightmapTexturesSize > 0.0f)
            {
                lightmapTexturesSizeContent = EditorGUIUtility.TrTextContent("Lightmap textures: " + SizeString(lightmapMemory.lightmapTexturesSize));
            }
            else
            {
                lightmapTexturesSizeContent = EditorGUIUtility.TrTextContent("Lightmap textures: N/A", "This lightmap has converged and is not owned by the Progressive Lightmapper anymore.");
            }
            GUILayout.Label(lightmapTexturesSizeContent, EditorStyles.miniLabel);

            GUIContent GPUSizeContent = null;

            if (lightmapMemory.lightmapDataSizeGPU > 0.0f)
            {
                GPUSizeContent = EditorGUIUtility.TrTextContent("GPU memory: " + SizeString(lightmapMemory.lightmapDataSizeGPU));
            }
            else
            {
                GPUSizeContent = EditorGUIUtility.TrTextContent("GPU memory: N/A");
            }
            GUILayout.Label(GPUSizeContent, EditorStyles.miniLabel);

            GUILayout.EndVertical();
        }
 public static void SaveScreenShot(Rect r, string name)
 {
     SaveScreenShot((int)r.width, (int)r.height, InternalEditorUtility.ReadScreenPixel(new Vector2(r.x, r.y), (int)r.width, (int)r.height), name);
 }
        private static void SaveAllUnsavedAssets(MenuCommand menuCommand)
        {
            var explosionObject = menuCommand.context as VoxelChunksObjectExplosion;

            if (explosionObject == null)
            {
                return;
            }

            var explosionCore = new VoxelChunksObjectExplosionCore(explosionObject);

            var folder = EditorUtility.OpenFolderPanel("Save all", explosionCore.voxelBaseCore.GetDefaultPath(), null);

            if (string.IsNullOrEmpty(folder))
            {
                return;
            }
            if (folder.IndexOf(Application.dataPath) < 0)
            {
                EditorCommon.SaveInsideAssetsFolderDisplayDialog();
                return;
            }

            Undo.RecordObject(explosionObject, "Save All Unsaved Assets");
            if (explosionObject.chunksExplosion != null)
            {
                Undo.RecordObjects(explosionObject.chunksExplosion, "Save All Unsaved Assets");
            }

            if (explosionObject.materialMode == VoxelChunksObject.MaterialMode.Combine)
            {
                if (explosionObject.chunksExplosion != null)
                {
                    for (int i = 0; i < explosionObject.chunksExplosion.Length; i++)
                    {
                        if (explosionObject.chunksExplosion[i] == null)
                        {
                            continue;
                        }
                        #region Mesh
                        for (int j = 0; j < explosionObject.chunksExplosion[i].meshes.Count; j++)
                        {
                            if (explosionObject.chunksExplosion[i].meshes[j] != null && explosionObject.chunksExplosion[i].meshes[j].mesh != null && !EditorCommon.IsMainAsset(explosionObject.chunksExplosion[i].meshes[j].mesh))
                            {
                                var chunkObject = explosionObject.chunksExplosion[i].GetComponent <VoxelChunksObjectChunk>();
                                if (chunkObject == null)
                                {
                                    continue;
                                }
                                var path = folder + "/" + string.Format("{0}_{1}_explosion_mesh{2}.asset", explosionObject.gameObject.name, chunkObject.chunkName, j);
                                path = FileUtil.GetProjectRelativePath(path);
                                AssetDatabase.CreateAsset(Mesh.Instantiate(explosionObject.chunksExplosion[i].meshes[j].mesh), path);
                                explosionObject.chunksExplosion[i].meshes[j].mesh = AssetDatabase.LoadAssetAtPath <Mesh>(path);
                            }
                        }
                        #endregion
                    }
                }

                #region Material
                if (explosionObject.materials != null)
                {
                    for (int index = 0; index < explosionObject.materials.Count; index++)
                    {
                        if (explosionObject.materials[index] == null)
                        {
                            continue;
                        }
                        if (EditorCommon.IsMainAsset(explosionObject.materials[index]))
                        {
                            continue;
                        }
                        var path = folder + "/" + string.Format("{0}_explosion_mat{1}.mat", explosionObject.gameObject.name, index);
                        path = FileUtil.GetProjectRelativePath(path);
                        AssetDatabase.CreateAsset(Material.Instantiate(explosionObject.materials[index]), path);
                        explosionObject.materials[index] = AssetDatabase.LoadAssetAtPath <Material>(path);
                    }
                }
                #endregion
            }
            else if (explosionObject.materialMode == VoxelChunksObject.MaterialMode.Individual)
            {
                if (explosionObject.chunksExplosion != null)
                {
                    for (int i = 0; i < explosionObject.chunksExplosion.Length; i++)
                    {
                        if (explosionObject.chunksExplosion[i] == null)
                        {
                            continue;
                        }
                        var chunkObject = explosionObject.chunksExplosion[i].GetComponent <VoxelChunksObjectChunk>();
                        if (chunkObject == null)
                        {
                            continue;
                        }
                        #region Mesh
                        for (int j = 0; j < explosionObject.chunksExplosion[i].meshes.Count; j++)
                        {
                            if (explosionObject.chunksExplosion[i].meshes[j] != null && explosionObject.chunksExplosion[i].meshes[j].mesh != null && !EditorCommon.IsMainAsset(explosionObject.chunksExplosion[i].meshes[j].mesh))
                            {
                                var path = folder + "/" + string.Format("{0}_{1}_explosion_mesh{2}.asset", explosionObject.gameObject.name, chunkObject.chunkName, j);
                                path = FileUtil.GetProjectRelativePath(path);
                                AssetDatabase.CreateAsset(Mesh.Instantiate(explosionObject.chunksExplosion[i].meshes[j].mesh), path);
                                explosionObject.chunksExplosion[i].meshes[j].mesh = AssetDatabase.LoadAssetAtPath <Mesh>(path);
                            }
                        }
                        #endregion

                        #region Material
                        if (explosionObject.chunksExplosion[i].materials != null)
                        {
                            for (int index = 0; index < explosionObject.chunksExplosion[i].materials.Count; index++)
                            {
                                if (explosionObject.chunksExplosion[i].materials[index] == null)
                                {
                                    continue;
                                }
                                if (EditorCommon.IsMainAsset(explosionObject.chunksExplosion[i].materials[index]))
                                {
                                    continue;
                                }
                                var path = folder + "/" + string.Format("{0}_{1}_explosion_mat{2}.mat", explosionObject.gameObject.name, chunkObject.chunkName, index);
                                path = FileUtil.GetProjectRelativePath(path);
                                AssetDatabase.CreateAsset(Material.Instantiate(explosionObject.chunksExplosion[i].materials[index]), path);
                                explosionObject.chunksExplosion[i].materials[index] = AssetDatabase.LoadAssetAtPath <Material>(path);
                            }
                        }
                        #endregion
                    }
                }
            }
            else
            {
                Assert.IsTrue(false);
            }

            explosionCore.Generate();
            InternalEditorUtility.RepaintAllViews();
        }
Beispiel #23
0
        public void Inspector(MotionEditor editor)
        {
            UltiDraw.Begin();

            UltiDraw.DrawSphere(Vector3.zero, Quaternion.identity, 1f, Color.red);

            Utility.SetGUIColor(UltiDraw.Grey);
            using (new EditorGUILayout.VerticalScope("Box")) {
                Utility.ResetGUIColor();

                Frame frame = Module.Data.GetFrame(editor.GetState().Index);

                SetSensor(EditorGUILayout.Popup("Sensor", Sensor, Module.Names));
                SetDistanceThreshold(EditorGUILayout.FloatField("Distance Threshold", DistanceThreshold));
                SetVelocityThreshold(EditorGUILayout.FloatField("Velocity Threshold", VelocityThtreshold));
                SetFilterWidth(EditorGUILayout.IntField("Filter Width", FilterWidth));
                SetOffset(EditorGUILayout.Vector3Field("Offset", Offset));
                SetNormal(EditorGUILayout.Vector3Field("Normal", Normal));
                SetMask(InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUILayout.MaskField("Mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Mask), InternalEditorUtility.layers)));

                EditorGUILayout.BeginVertical(GUILayout.Height(50f));
                Rect ctrl = EditorGUILayout.GetControlRect();
                Rect rect = new Rect(ctrl.x, ctrl.y, ctrl.width, 50f);
                EditorGUI.DrawRect(rect, UltiDraw.Black);

                float startTime = frame.Timestamp - editor.GetWindow() / 2f;
                float endTime   = frame.Timestamp + editor.GetWindow() / 2f;
                if (startTime < 0f)
                {
                    endTime  -= startTime;
                    startTime = 0f;
                }
                if (endTime > Module.Data.GetTotalTime())
                {
                    startTime -= endTime - Module.Data.GetTotalTime();
                    endTime    = Module.Data.GetTotalTime();
                }
                startTime = Mathf.Max(0f, startTime);
                endTime   = Mathf.Min(Module.Data.GetTotalTime(), endTime);
                int start    = Module.Data.GetFrame(startTime).Index;
                int end      = Module.Data.GetFrame(endTime).Index;
                int elements = end - start;

                Vector3 prevPos = Vector3.zero;
                Vector3 newPos  = Vector3.zero;
                Vector3 bottom  = new Vector3(0f, rect.yMax, 0f);
                Vector3 top     = new Vector3(0f, rect.yMax - rect.height, 0f);

                //Contacts
                for (int i = start; i <= end; i++)
                {
                    top.x    = rect.xMin + (float)(i - start) / elements * rect.width;
                    bottom.x = rect.xMin + (float)(i - start) / elements * rect.width;

                    top.y    = rect.yMax - rect.height;
                    bottom.y = rect.yMax - rect.height / 2f;
                    if (RegularContacts[i - 1])
                    {
                        UltiDraw.DrawLine(top, bottom, UltiDraw.Green);
                    }

                    top.y    = rect.yMax - rect.height / 2f;
                    bottom.y = rect.yMax;
                    if (InverseContacts[i - 1])
                    {
                        UltiDraw.DrawLine(top, bottom, UltiDraw.Green);
                    }
                }

                //Sequences
                for (int i = 0; i < Module.Data.Sequences.Length; i++)
                {
                    float   _start = (float)(Mathf.Clamp(Module.Data.Sequences[i].Start, start, end) - start) / (float)elements;
                    float   _end   = (float)(Mathf.Clamp(Module.Data.Sequences[i].End, start, end) - start) / (float)elements;
                    float   left   = rect.x + _start * rect.width;
                    float   right  = rect.x + _end * rect.width;
                    Vector3 a      = new Vector3(left, rect.y, 0f);
                    Vector3 b      = new Vector3(right, rect.y, 0f);
                    Vector3 c      = new Vector3(left, rect.y + rect.height, 0f);
                    Vector3 d      = new Vector3(right, rect.y + rect.height, 0f);
                    UltiDraw.DrawTriangle(a, c, b, UltiDraw.Yellow.Transparent(0.25f));
                    UltiDraw.DrawTriangle(b, c, d, UltiDraw.Yellow.Transparent(0.25f));
                }
                //Current Pivot
                top.x    = rect.xMin + (float)(frame.Index - start) / elements * rect.width;
                bottom.x = rect.xMin + (float)(frame.Index - start) / elements * rect.width;
                top.y    = rect.yMax - rect.height;
                bottom.y = rect.yMax;
                UltiDraw.DrawLine(top, bottom, UltiDraw.Yellow);
                UltiDraw.DrawCircle(top, 3f, UltiDraw.Green);
                UltiDraw.DrawCircle(bottom, 3f, UltiDraw.Green);

                Handles.DrawLine(Vector3.zero, Vector3.zero);                 //Somehow needed to get it working...

                EditorGUILayout.EndVertical();
            }
            UltiDraw.End();
        }
        public override void OnMonitorGUI(Rect r)
        {
            if (Event.current.type == EventType.Repaint)
            {
                // If m_MonitorAreaRect isn't set the preview was just opened so refresh the render to get the histogram data
                if (Mathf.Approximately(m_MonitorAreaRect.width, 0) && Mathf.Approximately(m_MonitorAreaRect.height, 0))
                {
                    InternalEditorUtility.RepaintAllViews();
                }

                // Sizing
                float width = m_HistogramTexture != null
                    ? Mathf.Min(m_HistogramTexture.width, r.width - 65f)
                    : r.width;

                float height = m_HistogramTexture != null
                    ? Mathf.Min(m_HistogramTexture.height, r.height - 45f)
                    : r.height;

                m_MonitorAreaRect = new Rect(
                    Mathf.Floor(r.x + r.width / 2f - width / 2f),
                    Mathf.Floor(r.y + r.height / 2f - height / 2f - 5f),
                    width, height
                    );

                if (m_HistogramTexture != null)
                {
                    Graphics.DrawTexture(m_MonitorAreaRect, m_HistogramTexture);

                    var         color     = Color.white;
                    const float kTickSize = 5f;

                    // Rect, lines & ticks points
                    if (m_MonitorSettings.histogramMode == HistogramMode.RGBSplit)
                    {
                        //  A B C D E
                        //  N       F
                        //  M       G
                        //  L K J I H

                        var A = new Vector3(m_MonitorAreaRect.x - 1f, m_MonitorAreaRect.y - 1f);
                        var E = new Vector3(A.x + m_MonitorAreaRect.width + 2f, m_MonitorAreaRect.y - 1f);
                        var H = new Vector3(E.x, E.y + m_MonitorAreaRect.height + 2f);
                        var L = new Vector3(A.x, H.y);

                        var N = new Vector3(A.x, A.y + (L.y - A.y) / 3f);
                        var M = new Vector3(A.x, A.y + (L.y - A.y) * 2f / 3f);
                        var F = new Vector3(E.x, E.y + (H.y - E.y) / 3f);
                        var G = new Vector3(E.x, E.y + (H.y - E.y) * 2f / 3f);

                        var C = new Vector3(A.x + (E.x - A.x) / 2f, A.y);
                        var J = new Vector3(L.x + (H.x - L.x) / 2f, L.y);

                        var B = new Vector3(A.x + (C.x - A.x) / 2f, A.y);
                        var D = new Vector3(C.x + (E.x - C.x) / 2f, C.y);
                        var I = new Vector3(J.x + (H.x - J.x) / 2f, J.y);
                        var K = new Vector3(L.x + (J.x - L.x) / 2f, L.y);

                        // Borders
                        Handles.color = color;
                        Handles.DrawLine(A, E);
                        Handles.DrawLine(E, H);
                        Handles.DrawLine(H, L);
                        Handles.DrawLine(L, new Vector3(A.x, A.y - 1f));

                        // Vertical ticks
                        Handles.DrawLine(A, new Vector3(A.x - kTickSize, A.y));
                        Handles.DrawLine(N, new Vector3(N.x - kTickSize, N.y));
                        Handles.DrawLine(M, new Vector3(M.x - kTickSize, M.y));
                        Handles.DrawLine(L, new Vector3(L.x - kTickSize, L.y));

                        Handles.DrawLine(E, new Vector3(E.x + kTickSize, E.y));
                        Handles.DrawLine(F, new Vector3(F.x + kTickSize, F.y));
                        Handles.DrawLine(G, new Vector3(G.x + kTickSize, G.y));
                        Handles.DrawLine(H, new Vector3(H.x + kTickSize, H.y));

                        // Horizontal ticks
                        Handles.DrawLine(A, new Vector3(A.x, A.y - kTickSize));
                        Handles.DrawLine(B, new Vector3(B.x, B.y - kTickSize));
                        Handles.DrawLine(C, new Vector3(C.x, C.y - kTickSize));
                        Handles.DrawLine(D, new Vector3(D.x, D.y - kTickSize));
                        Handles.DrawLine(E, new Vector3(E.x, E.y - kTickSize));

                        Handles.DrawLine(L, new Vector3(L.x, L.y + kTickSize));
                        Handles.DrawLine(K, new Vector3(K.x, K.y + kTickSize));
                        Handles.DrawLine(J, new Vector3(J.x, J.y + kTickSize));
                        Handles.DrawLine(I, new Vector3(I.x, I.y + kTickSize));
                        Handles.DrawLine(H, new Vector3(H.x, H.y + kTickSize));

                        // Separators
                        Handles.DrawLine(N, F);
                        Handles.DrawLine(M, G);

                        // Labels
                        GUI.color = color;
                        GUI.Label(new Rect(L.x - 15f, L.y + kTickSize - 4f, 30f, 30f), "0.0", FxStyles.tickStyleCenter);
                        GUI.Label(new Rect(J.x - 15f, J.y + kTickSize - 4f, 30f, 30f), "0.5", FxStyles.tickStyleCenter);
                        GUI.Label(new Rect(H.x - 15f, H.y + kTickSize - 4f, 30f, 30f), "1.0", FxStyles.tickStyleCenter);
                    }
                    else
                    {
                        //  A B C D E
                        //  P       F
                        //  O       G
                        //  N       H
                        //  M L K J I

                        var A = new Vector3(m_MonitorAreaRect.x, m_MonitorAreaRect.y);
                        var E = new Vector3(A.x + m_MonitorAreaRect.width + 1f, m_MonitorAreaRect.y);
                        var I = new Vector3(E.x, E.y + m_MonitorAreaRect.height + 1f);
                        var M = new Vector3(A.x, I.y);

                        var C = new Vector3(A.x + (E.x - A.x) / 2f, A.y);
                        var G = new Vector3(E.x, E.y + (I.y - E.y) / 2f);
                        var K = new Vector3(M.x + (I.x - M.x) / 2f, M.y);
                        var O = new Vector3(A.x, A.y + (M.y - A.y) / 2f);

                        var P = new Vector3(A.x, A.y + (O.y - A.y) / 2f);
                        var F = new Vector3(E.x, E.y + (G.y - E.y) / 2f);
                        var N = new Vector3(A.x, O.y + (M.y - O.y) / 2f);
                        var H = new Vector3(E.x, G.y + (I.y - G.y) / 2f);

                        var B = new Vector3(A.x + (C.x - A.x) / 2f, A.y);
                        var L = new Vector3(M.x + (K.x - M.x) / 2f, M.y);
                        var D = new Vector3(C.x + (E.x - C.x) / 2f, A.y);
                        var J = new Vector3(K.x + (I.x - K.x) / 2f, M.y);

                        // Borders
                        Handles.color = color;
                        Handles.DrawLine(A, E);
                        Handles.DrawLine(E, I);
                        Handles.DrawLine(I, M);
                        Handles.DrawLine(M, new Vector3(A.x, A.y - 1f));

                        // Vertical ticks
                        Handles.DrawLine(A, new Vector3(A.x - kTickSize, A.y));
                        Handles.DrawLine(P, new Vector3(P.x - kTickSize, P.y));
                        Handles.DrawLine(O, new Vector3(O.x - kTickSize, O.y));
                        Handles.DrawLine(N, new Vector3(N.x - kTickSize, N.y));
                        Handles.DrawLine(M, new Vector3(M.x - kTickSize, M.y));

                        Handles.DrawLine(E, new Vector3(E.x + kTickSize, E.y));
                        Handles.DrawLine(F, new Vector3(F.x + kTickSize, F.y));
                        Handles.DrawLine(G, new Vector3(G.x + kTickSize, G.y));
                        Handles.DrawLine(H, new Vector3(H.x + kTickSize, H.y));
                        Handles.DrawLine(I, new Vector3(I.x + kTickSize, I.y));

                        // Horizontal ticks
                        Handles.DrawLine(A, new Vector3(A.x, A.y - kTickSize));
                        Handles.DrawLine(B, new Vector3(B.x, B.y - kTickSize));
                        Handles.DrawLine(C, new Vector3(C.x, C.y - kTickSize));
                        Handles.DrawLine(D, new Vector3(D.x, D.y - kTickSize));
                        Handles.DrawLine(E, new Vector3(E.x, E.y - kTickSize));

                        Handles.DrawLine(M, new Vector3(M.x, M.y + kTickSize));
                        Handles.DrawLine(L, new Vector3(L.x, L.y + kTickSize));
                        Handles.DrawLine(K, new Vector3(K.x, K.y + kTickSize));
                        Handles.DrawLine(J, new Vector3(J.x, J.y + kTickSize));
                        Handles.DrawLine(I, new Vector3(I.x, I.y + kTickSize));

                        // Labels
                        GUI.color = color;
                        GUI.Label(new Rect(A.x - kTickSize - 34f, A.y - 15f, 30f, 30f), "1.0", FxStyles.tickStyleRight);
                        GUI.Label(new Rect(O.x - kTickSize - 34f, O.y - 15f, 30f, 30f), "0.5", FxStyles.tickStyleRight);
                        GUI.Label(new Rect(M.x - kTickSize - 34f, M.y - 15f, 30f, 30f), "0.0", FxStyles.tickStyleRight);

                        GUI.Label(new Rect(E.x + kTickSize + 4f, E.y - 15f, 30f, 30f), "1.0", FxStyles.tickStyleLeft);
                        GUI.Label(new Rect(G.x + kTickSize + 4f, G.y - 15f, 30f, 30f), "0.5", FxStyles.tickStyleLeft);
                        GUI.Label(new Rect(I.x + kTickSize + 4f, I.y - 15f, 30f, 30f), "0.0", FxStyles.tickStyleLeft);

                        GUI.Label(new Rect(M.x - 15f, M.y + kTickSize - 4f, 30f, 30f), "0.0", FxStyles.tickStyleCenter);
                        GUI.Label(new Rect(K.x - 15f, K.y + kTickSize - 4f, 30f, 30f), "0.5", FxStyles.tickStyleCenter);
                        GUI.Label(new Rect(I.x - 15f, I.y + kTickSize - 4f, 30f, 30f), "1.0", FxStyles.tickStyleCenter);
                    }
                }
            }
        }
Beispiel #25
0
        // Draw a list item.  A few too many magic numbers in here so will need to tidy this a bit
        void DrawItem(ListItem item, Rect area, float x, float y, bool focus, bool selected)
        {
            bool drag      = (item == dragTarget);
            bool highlight = selected;

            if (selected)
            {
                Texture2D selectTex = focus ? blueTex : greyTex;
                GUI.DrawTexture(new Rect(area.x, y, area.width, c_lineHeight), selectTex, ScaleMode.StretchToFill, false);
            }
            else if (drag)
            {
                switch (dragAdjust)
                {
                case SelectDirection.Up:
                    if (item.PrevOpenVisible != item.Parent)
                    {
                        GUI.DrawTexture(new Rect(x, y - 1, area.width, 2), yellowTex, ScaleMode.StretchToFill, false);
                    }
                    break;

                case SelectDirection.Down:
                    GUI.DrawTexture(new Rect(x, y + c_lineHeight - 1, area.width, 2), yellowTex, ScaleMode.StretchToFill, false);
                    break;

                default:
                    if (item.CanAccept)
                    {
                        GUI.DrawTexture(new Rect(area.x, y, area.width, c_lineHeight), yellowTex, ScaleMode.StretchToFill, false);
                        highlight = true;
                    }
                    break;
                }
            }
            else if (dragTarget != null && item == dragTarget.Parent && dragAdjust != SelectDirection.Current)
            {
                GUI.DrawTexture(new Rect(area.x, y, area.width, c_lineHeight), yellowTex, ScaleMode.StretchToFill, false);
                highlight = true;
            }

            if (item.HasActions)
            {
                // Draw any actions available
                for (int i = 0; i < item.Actions.Length; ++i)
                {
                    calcSizeTmpContent.text = item.Actions[i];
                    Vector2 sz = GUI.skin.button.CalcSize(calcSizeTmpContent);
                    if (GUI.Button(new Rect(x, y, sz.x, c_lineHeight), item.Actions[i]))
                    {
                        // Action performed. Callback delegate
                        actionDelegate(item, i);
                    }
                    x += sz.x + 4; // offset by 4 px
                }
            }

            if (item.CanExpand)
            {
                EditorGUI.Foldout(new Rect(x, y, 16, c_lineHeight), item.Expanded, GUIContent.none);
            }

            Texture icon            = item.Icon;
            Color   tmpColor        = GUI.color;
            Color   tmpContentColor = GUI.contentColor;

            // We grey the items when we dont know the state or its a dummy item
            if (/*item.Asset.State == Asset.States.Local ||*/ item.Dummy) //< Locals shown with icon for now
            {
                GUI.color = new Color(0.65f, 0.65f, 0.65f);
            }

            // This should not be an else statement as the previous if can set icon
            if (!item.Dummy)
            {
                // If there is no icon set then we look for cached items
                if (icon == null)
                {
                    icon = InternalEditorUtility.GetIconForFile(item.Name);
                    //                  icon = defaultIcon;
                }

                var iconRect = new Rect(x + 14, y, 16, c_lineHeight);

                if (icon != null)
                {
                    GUI.DrawTexture(iconRect, icon);
                }

                if (item.Asset != null)
                {
                    bool   drawOverlay = true;
                    string vcsType     = EditorSettings.externalVersionControl;
                    if (vcsType == ExternalVersionControl.Disabled ||
                        vcsType == ExternalVersionControl.AutoDetect ||
                        vcsType == ExternalVersionControl.Generic)
                    {
                        drawOverlay = false; // no overlays for these version control systems
                    }
                    if (drawOverlay)
                    {
                        Rect overlayRect = iconRect;
                        overlayRect.width += 12;
                        overlayRect.x     -= 6;
                        Overlay.DrawOverlay(item.Asset, overlayRect);
                    }
                }
            }

            string  displayName     = DisplayName(item);
            Vector2 displayNameSize = EditorStyles.label.CalcSize(EditorGUIUtility.TempContent(displayName));
            float   labelOffsetX    = x + 32;

            if (highlight)
            {
                GUI.contentColor = new Color(3, 3, 3);
                GUI.Label(new Rect(labelOffsetX, y, area.width - labelOffsetX, c_lineHeight + 2), displayName);
            }
            else
            {
                GUI.Label(new Rect(labelOffsetX, y, area.width - labelOffsetX, c_lineHeight + 2), displayName);
            }

            if (HasHiddenMetaFile(item))
            {
                GUI.color = new Color(0.55f, 0.55f, 0.55f);
                float spaceBefore = labelOffsetX + displayNameSize.x + 2;
                GUI.Label(new Rect(spaceBefore, y, area.width - spaceBefore, c_lineHeight + 2), "+meta");
            }
            GUI.contentColor = tmpContentColor;
            GUI.color        = tmpColor;
        }
Beispiel #26
0
 public static void PasteSettings()
 {
     PasteSettings(GetRenderSettings(), GetLightmapSettings());
     InternalEditorUtility.RepaintAllViews();
 }
Beispiel #27
0
        public OpenVRRecommendedSettings()
        {
            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Virtual Reality Supported with OpenVR",
                skipCheckFunc    = () => !VIUSettingsEditor.canSupportOpenVR,
                currentValueFunc = () => VIUSettingsEditor.supportOpenVR,
                setValueFunc     = v => VIUSettingsEditor.supportOpenVR = v,
                recommendedValue = true,
            });

            Add(new VIUVersionCheck.RecommendedSetting <BuildTarget>()
            {
                settingTitle     = "Build Target",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || VIUSettingsEditor.activeBuildTargetGroup != BuildTargetGroup.Standalone,
                currentValueFunc = () => EditorUserBuildSettings.activeBuildTarget,
                setValueFunc     = v =>
                {
#if UNITY_2017_1_OR_NEWER
                    EditorUserBuildSettings.SwitchActiveBuildTargetAsync(BuildTargetGroup.Standalone, v);
#elif UNITY_5_6_OR_NEWER
                    EditorUserBuildSettings.SwitchActiveBuildTarget(BuildTargetGroup.Standalone, v);
#else
                    EditorUserBuildSettings.SwitchActiveBuildTarget(v);
#endif
                },
                recommendedValue = BuildTarget.StandaloneWindows64,
            });

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Load Binding Config on Start",
                skipCheckFunc    = () => !VIUSettingsEditor.supportOpenVR,
                toolTip          = "You can change this option later in Edit -> Preferences... -> VIU Settings.",
                currentValueFunc = () => VIUSettings.autoLoadBindingConfigOnStart,
                setValueFunc     = v => { VIUSettings.autoLoadBindingConfigOnStart = v; },
                recommendedValue = true,
            });

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Binding Interface Switch",
                skipCheckFunc    = () => !VIUSettingsEditor.supportOpenVR,
                toolTip          = VIUSettings.BIND_UI_SWITCH_TOOLTIP + " You can change this option later in Edit -> Preferences... -> VIU Settings.",
                currentValueFunc = () => VIUSettings.enableBindingInterfaceSwitch,
                setValueFunc     = v => { VIUSettings.enableBindingInterfaceSwitch = v; },
                recommendedValue = true,
            });

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "External Camera Switch",
                skipCheckFunc    = () => !VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportOpenVR,
                toolTip          = VIUSettings.EX_CAM_UI_SWITCH_TOOLTIP + " You can change this option later in Edit -> Preferences... -> VIU Settings.",
                currentValueFunc = () => VIUSettings.enableExternalCameraSwitch,
                setValueFunc     = v => { VIUSettings.enableExternalCameraSwitch = v; },
                recommendedValue = true,
            });

#if UNITY_5_3
            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Stereoscopic Rendering",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyVR,
                currentValueFunc = () => PlayerSettings.stereoscopic3D,
                setValueFunc     = v => PlayerSettings.stereoscopic3D = v,
                recommendedValue = false,
            });
#endif

#if UNITY_5_3 || UNITY_5_4
            Add(new VIUVersionCheck.RecommendedSetting <RenderingPath>()
            {
                settingTitle        = "Rendering Path",
                skipCheckFunc       = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyVR,
                recommendBtnPostfix = "required for MSAA",
                currentValueFunc    = () => PlayerSettings.renderingPath,
                setValueFunc        = v => PlayerSettings.renderingPath = v,
                recommendedValue    = RenderingPath.Forward,
            });

            // Unity 5.3 doesn't have SplashScreen for VR
            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Show Unity Splash Screen",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !InternalEditorUtility.HasPro() || !VIUSettingsEditor.supportAnyVR,
                currentValueFunc = () => PlayerSettings.showUnitySplashScreen,
                setValueFunc     = v => PlayerSettings.showUnitySplashScreen = v,
                recommendedValue = false,
            });
#endif

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "GPU Skinning",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyVR,
                currentValueFunc = () => PlayerSettings.gpuSkinning,
                setValueFunc     = v =>
                {
                    if (VIUSettingsEditor.supportAnyAndroidVR)
                    {
                        VIUSettingsEditor.SetGraphicsAPI(BuildTarget.Android, GraphicsDeviceType.OpenGLES3);
                    }
                    PlayerSettings.gpuSkinning = v;
                },
                recommendedValueFunc = () => !VIUSettingsEditor.supportWaveVR,
            });

            Add(new VIUVersionCheck.RecommendedSetting <Vector2>()
            {
                settingTitle     = "Default Screen Size",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => new Vector2(PlayerSettings.defaultScreenWidth, PlayerSettings.defaultScreenHeight),
                setValueFunc     = v => { PlayerSettings.defaultScreenWidth = (int)v.x; PlayerSettings.defaultScreenHeight = (int)v.y; },
                recommendedValue = new Vector2(1024f, 768f),
            });

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Run In Background",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.runInBackground,
                setValueFunc     = v => PlayerSettings.runInBackground = v,
                recommendedValue = true,
            });

#if !UNITY_2019_2_OR_NEWER
            Add(new VIUVersionCheck.RecommendedSetting <ResolutionDialogSetting>()
            {
                settingTitle     = "Display Resolution Dialog",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.displayResolutionDialog,
                setValueFunc     = v => PlayerSettings.displayResolutionDialog = v,
                recommendedValue = ResolutionDialogSetting.HiddenByDefault,
            });
#endif

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Resizable Window",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.resizableWindow,
                setValueFunc     = v => PlayerSettings.resizableWindow = v,
                recommendedValue = true,
            });

#if !UNITY_2018_1_OR_NEWER
            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Default Is Fullscreen",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.defaultIsFullScreen,
                setValueFunc     = v => PlayerSettings.defaultIsFullScreen = v,
                recommendedValue = false,
            });

            Add(new VIUVersionCheck.RecommendedSetting <D3D11FullscreenMode>()
            {
                settingTitle     = "D3D11 Fullscreen Mode",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.d3d11FullscreenMode,
                setValueFunc     = v => PlayerSettings.d3d11FullscreenMode = v,
                recommendedValue = D3D11FullscreenMode.FullscreenWindow,
            });
#else
            Add(new VIUVersionCheck.RecommendedSetting <FullScreenMode>()
            {
                settingTitle     = "Fullscreen Mode",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.fullScreenMode,
                setValueFunc     = v => PlayerSettings.fullScreenMode = v,
                recommendedValue = FullScreenMode.FullScreenWindow,
            });
#endif

            Add(new VIUVersionCheck.RecommendedSetting <bool>()
            {
                settingTitle     = "Visible In Background",
                skipCheckFunc    = () => VRModule.isSteamVRPluginDetected || !VIUSettingsEditor.supportAnyStandaloneVR,
                currentValueFunc = () => PlayerSettings.visibleInBackground,
                setValueFunc     = v => PlayerSettings.visibleInBackground = v,
                recommendedValue = true,
            });

            Add(new VIUVersionCheck.RecommendedSetting <ColorSpace>()
            {
                settingTitle        = "Color Space",
                skipCheckFunc       = () => (VRModule.isSteamVRPluginDetected && VIUSettingsEditor.activeBuildTargetGroup == BuildTargetGroup.Standalone) || !VIUSettingsEditor.supportAnyVR,
                recommendBtnPostfix = "requires reloading scene",
                currentValueFunc    = () => PlayerSettings.colorSpace,
                setValueFunc        = v =>
                {
                    if (VIUSettingsEditor.supportAnyAndroidVR)
                    {
                        VIUSettingsEditor.SetGraphicsAPI(BuildTarget.Android, GraphicsDeviceType.OpenGLES3);
                    }
                    PlayerSettings.colorSpace = v;
                },
                recommendedValue = ColorSpace.Linear,
            });
#if VIU_STEAMVR_2_0_0_OR_NEWER
            Add(new RecommendedSteamVRInputFileSettings());
#endif
        }
Beispiel #28
0
 private void OnFocus()
 {
     AllowCursorLockAndHide(true);
     s_LastFocusedGameView = this;
     InternalEditorUtility.OnGameViewFocus(true);
 }
Beispiel #29
0
        public void OnGUI()
        {
            AboutWindow.LoadLogos();
            GUILayout.Space(10f);
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(5f);
            GUILayout.BeginVertical(new GUILayoutOption[0]);
            GUILayout.FlexibleSpace();
            GUILayout.Label(AboutWindow.s_Header, GUIStyle.none, new GUILayoutOption[0]);
            this.ListenForSecretCodes();
            string text = "";

            if (InternalEditorUtility.HasFreeLicense())
            {
                text = " Personal";
            }
            if (InternalEditorUtility.HasEduLicense())
            {
                text = " Edu";
            }
            GUILayout.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Space(52f);
            string text2 = this.FormatExtensionVersionString();

            this.m_ShowDetailedVersion |= Event.current.alt;
            if (this.m_ShowDetailedVersion)
            {
                int      unityVersionDate = InternalEditorUtility.GetUnityVersionDate();
                DateTime dateTime         = new DateTime(1970, 1, 1, 0, 0, 0, 0);
                string   unityBuildBranch = InternalEditorUtility.GetUnityBuildBranch();
                string   text3            = "";
                if (unityBuildBranch.Length > 0)
                {
                    text3 = "Branch: " + unityBuildBranch;
                }
                EditorGUILayout.SelectableLabel(string.Format("Version {0}{1}{2}\n{3:r}\n{4}", new object[]
                {
                    InternalEditorUtility.GetFullUnityVersion(),
                    text,
                    text2,
                    dateTime.AddSeconds((double)unityVersionDate),
                    text3
                }), new GUILayoutOption[]
                {
                    GUILayout.Width(550f),
                    GUILayout.Height(42f)
                });
                this.m_TextInitialYPos = 108f;
            }
            else
            {
                GUILayout.Label(string.Format("Version {0}{1}{2}", Application.unityVersion, text, text2), new GUILayoutOption[0]);
            }
            if (Event.current.type != EventType.ValidateCommand)
            {
                GUILayout.EndHorizontal();
                GUILayout.Space(4f);
                GUILayout.EndVertical();
                GUILayout.EndHorizontal();
                GUILayout.FlexibleSpace();
                float creditsWidth = base.position.width - 10f;
                float num          = this.m_TextYPos;
                Rect  rect         = GUILayoutUtility.GetRect(10f, this.m_TextInitialYPos);
                GUI.BeginGroup(rect);
                string[] array = AboutWindowNames.Names(null, true);
                for (int i = 0; i < array.Length; i++)
                {
                    string nameChunk = array[i];
                    num = AboutWindow.DoCreditsNameChunk(nameChunk, creditsWidth, num);
                }
                num = AboutWindow.DoCreditsNameChunk("Thanks to Forest 'Yoggy' Johnson, Graham McAllister, David Janik-Jones, Raimund Schumacher, Alan J. Dickins and Emil 'Humus' Persson", creditsWidth, num);
                this.m_TotalCreditsHeight = num - this.m_TextYPos;
                GUI.EndGroup();
                this.HandleScrollEvents(rect);
                GUILayout.FlexibleSpace();
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Label(AboutWindow.s_MonoLogo, new GUILayoutOption[0]);
                GUILayout.Label("Scripting powered by The Mono Project.\n\n(c) 2011 Novell, Inc.", "MiniLabel", new GUILayoutOption[]
                {
                    GUILayout.Width(200f)
                });
                GUILayout.Label(AboutWindow.s_AgeiaLogo, new GUILayoutOption[0]);
                GUILayout.Label("Physics powered by PhysX.\n\n(c) 2011 NVIDIA Corporation.", "MiniLabel", new GUILayoutOption[]
                {
                    GUILayout.Width(200f)
                });
                GUILayout.EndHorizontal();
                GUILayout.FlexibleSpace();
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(5f);
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                string aboutWindowLabel = UnityVSSupport.GetAboutWindowLabel();
                if (aboutWindowLabel.Length > 0)
                {
                    GUILayout.Label(aboutWindowLabel, "MiniLabel", new GUILayoutOption[0]);
                }
                GUILayout.Label(InternalEditorUtility.GetUnityCopyright(), "MiniLabel", new GUILayoutOption[0]);
                GUILayout.EndVertical();
                GUILayout.Space(10f);
                GUILayout.FlexibleSpace();
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                GUILayout.FlexibleSpace();
                GUILayout.Label(InternalEditorUtility.GetLicenseInfo(), "AboutWindowLicenseLabel", new GUILayoutOption[0]);
                GUILayout.EndVertical();
                GUILayout.Space(5f);
                GUILayout.EndHorizontal();
                GUILayout.Space(5f);
            }
        }
Beispiel #30
0
        public static bool LoadWindowLayout(string path, bool newProjectLayoutWasCreated)
        {
            Rect position = default(Rect);

            UnityEngine.Object[] array  = Resources.FindObjectsOfTypeAll(typeof(ContainerWindow));
            UnityEngine.Object[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                ContainerWindow containerWindow = (ContainerWindow)array2[i];
                if (containerWindow.showMode == ShowMode.MainWindow)
                {
                    position = containerWindow.position;
                }
            }
            bool flag = false;
            bool result;

            try
            {
                ContainerWindow.SetFreezeDisplay(true);
                WindowLayout.CloseWindows();
                UnityEngine.Object[]      array3 = InternalEditorUtility.LoadSerializedFileAndForget(path);
                List <UnityEngine.Object> list   = new List <UnityEngine.Object>();
                int j = 0;
                while (j < array3.Length)
                {
                    UnityEngine.Object @object      = array3[j];
                    EditorWindow       editorWindow = @object as EditorWindow;
                    if (editorWindow != null)
                    {
                        if (!(editorWindow.m_Parent == null))
                        {
                            goto IL_186;
                        }
                        UnityEngine.Object.DestroyImmediate(editorWindow, true);
                        Console.WriteLine(string.Concat(new object[]
                        {
                            "LoadWindowLayout: Removed unparented EditorWindow while reading window layout: window #",
                            j,
                            ", type=",
                            @object.GetType().ToString(),
                            ", instanceID=",
                            @object.GetInstanceID()
                        }));
                        flag = true;
                    }
                    else
                    {
                        DockArea dockArea = @object as DockArea;
                        if (!(dockArea != null) || dockArea.m_Panes.Count != 0)
                        {
                            goto IL_186;
                        }
                        dockArea.Close(null);
                        Console.WriteLine(string.Concat(new object[]
                        {
                            "LoadWindowLayout: Removed empty DockArea while reading window layout: window #",
                            j,
                            ", instanceID=",
                            @object.GetInstanceID()
                        }));
                        flag = true;
                    }
IL_190:
                    j++;
                    continue;
IL_186:
                    list.Add(@object);
                    goto IL_190;
                }
                ContainerWindow containerWindow2 = null;
                ContainerWindow containerWindow3 = null;
                for (int k = 0; k < list.Count; k++)
                {
                    ContainerWindow containerWindow4 = list[k] as ContainerWindow;
                    if (containerWindow4 != null && containerWindow4.showMode == ShowMode.MainWindow)
                    {
                        containerWindow3 = containerWindow4;
                        if ((double)position.width != 0.0)
                        {
                            containerWindow2          = containerWindow4;
                            containerWindow2.position = position;
                        }
                    }
                }
                for (int l = 0; l < list.Count; l++)
                {
                    UnityEngine.Object object2 = list[l];
                    if (object2 == null)
                    {
                        Console.WriteLine("LoadWindowLayout: Error while reading window layout: window #" + l + " is null");
                        flag = true;
                    }
                    else if (object2.GetType() == null)
                    {
                        Console.WriteLine(string.Concat(new object[]
                        {
                            "LoadWindowLayout: Error while reading window layout: window #",
                            l,
                            " type is null, instanceID=",
                            object2.GetInstanceID()
                        }));
                        flag = true;
                    }
                    else if (newProjectLayoutWasCreated)
                    {
                        MethodInfo method = object2.GetType().GetMethod("OnNewProjectLayoutWasCreated", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                        if (method != null)
                        {
                            method.Invoke(object2, null);
                        }
                    }
                }
                if (containerWindow2)
                {
                    containerWindow2.position = position;
                    containerWindow2.OnResize();
                }
                if (containerWindow3 == null)
                {
                    UnityEngine.Debug.LogError("Error while reading window layout: no main window found");
                    throw new Exception();
                }
                containerWindow3.Show(containerWindow3.showMode, true, true);
                for (int m = 0; m < list.Count; m++)
                {
                    EditorWindow editorWindow2 = list[m] as EditorWindow;
                    if (editorWindow2)
                    {
                        editorWindow2.minSize = editorWindow2.minSize;
                    }
                    ContainerWindow containerWindow5 = list[m] as ContainerWindow;
                    if (containerWindow5 && containerWindow5 != containerWindow3)
                    {
                        containerWindow5.Show(containerWindow5.showMode, true, true);
                    }
                }
                GameView gameView = WindowLayout.GetMaximizedWindow() as GameView;
                if (gameView != null && gameView.maximizeOnPlay)
                {
                    WindowLayout.Unmaximize(gameView);
                }
                if (newProjectLayoutWasCreated)
                {
                    if (UnityConnect.instance.online && UnityConnect.instance.loggedIn && UnityConnect.instance.shouldShowServicesWindow)
                    {
                        UnityConnectServiceCollection.instance.ShowService("Hub", true, "new_project_created");
                    }
                    else
                    {
                        UnityConnectServiceCollection.instance.CloseServices();
                    }
                }
            }
            catch (Exception arg)
            {
                UnityEngine.Debug.LogError("Failed to load window layout: " + arg);
                int num = 0;
                if (!Application.isTestRun)
                {
                    num = EditorUtility.DisplayDialogComplex("Failed to load window layout", "This can happen if layout contains custom windows and there are compile errors in the project.", "Load Default Layout", "Quit", "Revert Factory Settings");
                }
                if (num != 0)
                {
                    if (num != 1)
                    {
                        if (num == 2)
                        {
                            WindowLayout.RevertFactorySettings();
                        }
                    }
                    else
                    {
                        EditorApplication.Exit(0);
                    }
                }
                else
                {
                    WindowLayout.LoadDefaultLayout();
                }
                result = false;
                return(result);
            }
            finally
            {
                ContainerWindow.SetFreezeDisplay(false);
                if (Path.GetExtension(path) == ".wlt")
                {
                    Toolbar.lastLoadedLayoutName = Path.GetFileNameWithoutExtension(path);
                }
                else
                {
                    Toolbar.lastLoadedLayoutName = null;
                }
            }
            if (flag)
            {
                UnityEngine.Debug.Log("The editor layout could not be fully loaded, this can happen when the layout contains EditorWindows not available in this project");
            }
            result = true;
            return(result);
        }