Ejemplo n.º 1
0
        private static IEnumerator BuildHierarchicalVolumeGridRecursive(int count, int density, VolumeData data, Action <VolumeData> result, object obj)
        {
            count++;
            VolumeData[] childData = new VolumeData[8];
            for (int i = 0; i < childData.Length; i++)
            {
                Vector3 size     = new Vector3(data.bounds.size.x * 0.5f, data.bounds.size.y * 0.5f, data.bounds.size.z * 0.5f);
                float   signX    = (float)(i + 1) % 2 == 0 ? 1 : -1;
                float   signY    = i == 2 || i == 3 || i == 6 || i == 7 ? 1 : -1;            // TODO - Maths
                float   signZ    = i == 4 || i == 5 || i == 6 || i == 7 ? 1 : -1;            //(float)(i + 1) * 0.5f > 4 ? 1 : -1; // TODO - Maths
                Vector3 position = data.bounds.center + new Vector3(signX * size.x * 0.5f, signY * size.y * 0.5f, signZ * size.z * 0.5f);
                Bounds  bounds   = new Bounds(position, size);
                childData[i] = new VolumeData(bounds, null, null);

                if (count < density)
                {
                    VolumeData childResult = new VolumeData();
                    yield return(EditorCoroutines.StartCoroutine(BuildHierarchicalVolumeGridRecursive(count, density, childData[i], value => childResult = value, obj), obj));

                    childData[i] = childResult;
                }
            }
            data.children = childData;
            result(data);
        }
Ejemplo n.º 2
0
        private IEnumerator Generate()
        {
            m_StaticRenderers = Utils.GetStaticRenderers();
            yield return(EditorCoroutines.StartCoroutine(Utils.BuildOccluderProxyGeometry(transform, m_StaticRenderers, value => m_Occluders = value, this, "Occluder"), this));

            UnityEditor.SceneView.RepaintAll();
        }
Ejemplo n.º 3
0
    protected override void DerivedInspector(MotionEditor editor)
    {
        ShowVelocities = EditorGUILayout.Toggle("Show Velocities", ShowVelocities);
        ShowCycle      = EditorGUILayout.Toggle("Show Cycle", ShowCycle);
        SetMaximumVelocity(EditorGUILayout.FloatField("Maximum Velocity", MaximumVelocity));
        SetVelocityThreshold(EditorGUILayout.FloatField("Velocity Threshold", VelocityThreshold));
        string[] names = new string[1 + Data.Source.Bones.Length];
        names[0] = "Select...";
        for (int i = 0; i < names.Length - 1; i++)
        {
            names[i + 1] = Data.Source.Bones[i].Name;
        }
        int index = EditorGUILayout.Popup("Phase Detector", 0, names);

        if (index > 0)
        {
            ToggleVariable(index - 1);
        }
        for (int i = 0; i < Data.Source.Bones.Length; i++)
        {
            if (Variables[i])
            {
                using (new EditorGUILayout.VerticalScope("Box")) {
                    EditorGUILayout.BeginHorizontal();
                    EditorGUILayout.LabelField(Data.Source.Bones[i].Name);
                    EditorGUILayout.LabelField(Data.Source.Bones[Data.Symmetry[i]].Name);
                    EditorGUILayout.EndHorizontal();
                }
            }
        }
        Utility.SetGUIColor(UltiDraw.Grey);
        using (new EditorGUILayout.VerticalScope("Box")) {
            Utility.ResetGUIColor();
            if (Optimising)
            {
                if (Utility.GUIButton("Stop Optimisation", UltiDraw.LightGrey, UltiDraw.Black))
                {
                    EditorCoroutines.StopCoroutine(RegularPhaseFunction.Optimise(), this);
                    EditorCoroutines.StopCoroutine(InversePhaseFunction.Optimise(), this);
                    Optimising = false;
                }
            }
            else
            {
                if (Utility.GUIButton("Start Optimisation", UltiDraw.DarkGrey, UltiDraw.White))
                {
                    EditorCoroutines.StartCoroutine(RegularPhaseFunction.Optimise(), this);
                    EditorCoroutines.StartCoroutine(InversePhaseFunction.Optimise(), this);
                    Optimising = true;
                }
            }
            if (Utility.GUIButton("Clear", UltiDraw.DarkGrey, UltiDraw.White))
            {
                RegularPhaseFunction.Clear();
                InversePhaseFunction.Clear();
            }
        }
        RegularPhaseFunction.Inspector(editor);
        InversePhaseFunction.Inspector(editor);
    }
Ejemplo n.º 4
0
        // --------------------------------------------------
        // BAKE

#if UNITY_EDITOR
        private IEnumerator BakePortalData()
        {
            // Generate Portal data
            m_Completion    = 0.0f;
            m_BakeTime      = 0.0f;
            m_BakeStartTime = Time.realtimeSinceStartup;
            m_BakeState     = BakeState.Occluders;
            var occluders = PortalPrepareUtil.GetOccluderData();

            m_BakeState = BakeState.Volumes;
            var volumes = PortalPrepareUtil.GetVolumeData(m_VolumeMode, m_Subdivisions);

            m_BakeState = BakeState.Visibility;
            List <VisbilityData> visibilityTable = null;

            yield return(EditorCoroutines.StartCoroutine(GenerateVisibilityTable(occluders, volumes, value => visibilityTable = value), this));

            // Serialize
            m_PortalData = new SerializablePortalData()
            {
                occluders       = occluders,
                volumes         = volumes,
                visibilityTable = visibilityTable
            };

            // Finalize
            m_BakeState  = BakeState.Active;
            m_Completion = 1.0f;
            m_BakeTime   = Time.realtimeSinceStartup - m_BakeStartTime;
            UnityEditor.SceneView.RepaintAll();
            UnityEditor.SceneManagement.EditorSceneManager.MarkAllScenesDirty();
        }
Ejemplo n.º 5
0
        private IEnumerator OnIteration(int index)
        {
            RockLog.InsertLine();
            RockLog.WriteLine(this, LogTier.Info, string.Format("Starting iteration number: {0}", CurrentIteration));

            InnerScope.Reset();

            var iteratorVariable = Field <object> .Create(RepeatNumberName, index, false, true);

            // update the iterator job context
            InnerScope.ScopeContext.Add(iteratorVariable);

            // reset the inner scope and loop through the child steps
            yield return(EditorCoroutines.StartCoroutine(InnerScope.StartExecutingSteps(), this));

            if (!IsSuppressed)
            {
                switch (InnerScope.Request)
                {
                case StepRequest.ExitScope:
                case StepRequest.RootScope:
                case StepRequest.TerminateJob:

                    DoLoop = false;

                    break;
                }
            }

            CurrentIteration++;
        }
Ejemplo n.º 6
0
        /// <inheritdoc />
        protected override IEnumerator OnExecute(JobContext context)
        {
            InnerScope.ScopeContext = new JobContext(context);

            if (InnerScope.Steps.Count == 0)
            {
                IsSuccess = true;
                yield break;
            }

            var startCount = StartAtZero ? 0 : 1;
            var endCount   = StartAtZero
                ? RepeatCount - 1
                : RepeatCount;

            if (!Reverse)
            {
                for (var i = startCount; i <= endCount && DoLoop; i++)
                {
                    yield return(EditorCoroutines.StartCoroutine(OnIteration(i), this));
                }
            }
            else
            {
                for (var i = endCount; i >= startCount && DoLoop; i--)
                {
                    yield return(EditorCoroutines.StartCoroutine(OnIteration(i), this));
                }
            }

            IsSuccess = true;
            yield return(null);
        }
Ejemplo n.º 7
0
        /// <inheritdoc />
        protected override IEnumerator OnExecute(JobContext context)
        {
            InnerScope.ScopeContext = context;
            yield return(EditorCoroutines.StartCoroutine(InnerScope.StartExecutingSteps(), this));

            IsSuccess = true;
            yield return(null);
        }
Ejemplo n.º 8
0
        public void OnClickGenerate()
        {
            m_VolumeData = null;
            MeshRenderer[] staticRenderers = Utils.GetStaticRenderers();
            Bounds         bounds          = Utils.GetSceneBounds(staticRenderers);

            EditorCoroutines.StartCoroutine(Utils.BuildHierarchicalVolumeGrid(bounds, m_VolumeDensity, value => m_VolumeData = value, this), this);
            UnityEditor.SceneView.RepaintAll();
        }
Ejemplo n.º 9
0
 public void PlayAnimation()
 {
     if (Playing)
     {
         return;
     }
     Playing = true;
     EditorCoroutines.StartCoroutine(Play(), this);
 }
Ejemplo n.º 10
0
        // --------------------------------------------------
        // Hirarchical Volume Grid

        public static IEnumerator BuildHierarchicalVolumeGrid(Bounds bounds, int density, Action <VolumeData> result, object obj)
        {
            VolumeData data  = new VolumeData(bounds, null, null);
            int        count = 0;

            if (count < density)
            {
                yield return(EditorCoroutines.StartCoroutine(BuildHierarchicalVolumeGridRecursive(count, density, data, value => data = value, obj), obj));
            }
            result(data);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Start the bake process. Editor only.
        /// </summary>
        public void OnClickBake()
        {
            // Abort if in play mode as save actions arent valid
            if (Application.isPlaying)
            {
                Debug.LogWarning("Cannot modifiy Portal data while in Play mode. Aborting.");
                return;
            }

            // Start bake
            EditorCoroutines.StartCoroutine(BakePortalData(), this);
        }
Ejemplo n.º 12
0
        /// <inheritdoc />
        /// <summary>
        /// Called when this Step gets executed.
        /// </summary>
        /// <param name="context">Current job context.</param>
        /// <returns></returns>
        protected override IEnumerator OnExecute(JobContext context)
        {
            InnerScope.ScopeContext = new JobContext(context);

            if (InnerScope.Steps.Count == 0)
            {
                IsSuccess = true;
                yield break;
            }

            foreach (var item in ItemList)
            {
                if (!DoLoop)
                {
                    break;
                }

                OnIterationStart(CurrentIteration);
                InnerScope.Reset();

                var iteratorVariable = Field <object> .Create(IteratorName.Trim('%'), item, false, true);

                var indexCountVariable = Field <object> .Create(IndexCountName.Trim('%'), CurrentIteration, false, true);

                // update the iterator job context
                InnerScope.ScopeContext.Add(iteratorVariable);
                InnerScope.ScopeContext.Add(indexCountVariable);

                // reset the inner scope and loop through the child steps
                yield return(EditorCoroutines.StartCoroutine(InnerScope.StartExecutingSteps(), this));

                OnIterationEnd(CurrentIteration);

                if (!IsSuppressed)
                {
                    switch (InnerScope.Request)
                    {
                    case StepRequest.ExitScope:
                    case StepRequest.RootScope:
                    case StepRequest.TerminateJob:

                        DoLoop = false;

                        break;
                    }
                }

                CurrentIteration++;
            }

            IsSuccess = true;
            yield return(null);
        }
Ejemplo n.º 13
0
    public void UnloadData()
    {
        if (Data == null)
        {
            return;
        }

        //Saving
        if (Data.IsDirty())
        {
            if (Application.isPlaying)
            {
                Debug.Log("Can not save asset " + name + " in play mode.");
            }
            else
            {
                //Debug.Log("Saving asset " + Data.GetName() + ".");
                AssetDatabase.SaveAssets();
                EditorSceneManager.SaveScene(Data.GetScene());
            }
        }

        //Unloading Scene
        Scene scene = EditorSceneManager.GetSceneByName(Data.name);

        if (Application.isPlaying)
        {
            SceneManager.UnloadSceneAsync(scene);
        }
        else
        {
            EditorCoroutines.StartCoroutine(RemoveScene(0.25f), this);
        }
        IEnumerator RemoveScene(float delay)
        {
            EditorSceneManager.CloseScene(scene, false);
            yield return(new WaitForSeconds(delay));

            if (!scene.isLoaded)
            {
                EditorSceneManager.CloseScene(scene, true);
                EditorApplication.RepaintHierarchyWindow();
            }
        }

        //Unloading Asset
        Resources.UnloadUnusedAssets();

        //Reset Temporary
        TimeSeries  = null;
        BoneMapping = null;
    }
Ejemplo n.º 14
0
        protected void Init(IExampleContext context, MapIngredientConfig mapIngredientConfig, WorldGeneratorConfig worldGeneratorConfig)
        {
            GameContext = context;
            Config      = mapIngredientConfig;

            Config.OnUpdate += () =>
            {
#if UNITY_EDITOR
                EditorCoroutines.StartCoroutine(CleanUpAndStartRecalculating(), this);
#endif
                RefreshVisualisation();
            };
        }
Ejemplo n.º 15
0
        private IEnumerator GenerateOcclusion()
        {
            m_StaticRenderers = Utils.GetStaticRenderers();

            // Generate Occluder Data
            m_BakeState = BakeState.Occluders;
            ClearOccluderData();
            yield return(EditorCoroutines.StartCoroutine(Utils.BuildOccluderProxyGeometry(transform, m_StaticRenderers, value => m_Occluders = value, this, m_OccluderTag), this));

            // Generate Volume Data
            m_BakeState = BakeState.Volumes;
            ClearVolumeData();
            switch (m_VolumeMode)
            {
            case VolumeMode.Automatic:
                // Generate Hierarchical Volume Grid
                Bounds bounds = Utils.GetSceneBounds(m_StaticRenderers);
                yield return(EditorCoroutines.StartCoroutine(Utils.BuildHierarchicalVolumeGrid(bounds, m_VolumeDensity, value => m_VolumeData = value, this), this));

                break;

            case VolumeMode.Manual:
                // Generate Manual Volumes
                yield return(EditorCoroutines.StartCoroutine(Utils.BuildManualVolumeGrid(m_ManualVolumes, value => m_VolumeData = value), this));

                break;
            }

            if (m_VolumeData != null)
            {
                // Generate Occlusion Data
                m_BakeState = BakeState.Occlusion;
                int          volumeDensity   = m_VolumeMode == VolumeMode.Automatic ? m_VolumeDensity : 1;
                VolumeData[] smallestVolumes = Utils.GetLowestSubdivisionVolumes(m_VolumeData, volumeDensity);
                for (int i = 0; i < smallestVolumes.Length; i++)
                {
                    m_Completion   = (float)(i + 1) / (float)smallestVolumes.Length;
                    m_ActiveVolume = smallestVolumes[i];
                    yield return(EditorCoroutines.StartCoroutine(Utils.BuildOcclusionForVolume(smallestVolumes[i].bounds, m_RayDensity, m_StaticRenderers, m_Occluders, value => smallestVolumes[i].renderers = value, this, m_FilterAngle), this));
                }
                m_BakeState = BakeState.Active;
            }
            else
            {
                Debug.LogError("Occlusion Bake Failed. Check Settings.");
                m_BakeState  = BakeState.Empty;
                m_Completion = 0;
            }
            m_ActiveVolume = null;
            yield return(null);
        }
Ejemplo n.º 16
0
    public void Unload()
    {
        Scene scene = EditorSceneManager.GetSceneByName(name);

        if (Application.isPlaying)
        {
            SceneManager.UnloadSceneAsync(scene);
        }
        else
        {
            EditorSceneManager.CloseScene(scene, false);
            EditorCoroutines.StartCoroutine(RemoveScene(scene), this);
        }
    }
Ejemplo n.º 17
0
 protected override void DerivedInspector(MotionEditor editor)
 {
     if (Utility.GUIButton("Capture Contacts", UltiDraw.DarkGrey, UltiDraw.White))
     {
         EditorCoroutines.StartCoroutine(CaptureContacts(editor), this);
     }
     EditorGUILayout.BeginHorizontal();
     BakedContacts = (BakedContacts)EditorGUILayout.ObjectField(BakedContacts, typeof(BakedContacts), true);
     EditorGUI.BeginDisabledGroup(BakedContacts == null || editor.Mirror);
     if (Utility.GUIButton("Bake", UltiDraw.DarkGrey, UltiDraw.White))
     {
         BakeContacts(editor);
     }
     EditorGUI.EndDisabledGroup();
     EditorGUILayout.EndHorizontal();
     DrawScale                 = EditorGUILayout.FloatField("Draw Scale", DrawScale);
     EditMotion                = EditorGUILayout.Toggle("Edit Motion", EditMotion);
     ShowDebug                 = EditorGUILayout.Toggle("Show Debug", ShowDebug);
     ShowSensors               = EditorGUILayout.Toggle("Show Sensors", ShowSensors);
     ShowTolerances            = EditorGUILayout.Toggle("Show Tolerances", ShowTolerances);
     ShowDistances             = EditorGUILayout.Toggle("Show Distances", ShowDistances);
     TrueMotionTrajectory      = EditorGUILayout.Toggle("True Motion Trajectory", TrueMotionTrajectory);
     CorrectedMotionTrajectory = EditorGUILayout.Toggle("Corrected Motion Trajectory", CorrectedMotionTrajectory);
     PastTrajectoryWindow      = EditorGUILayout.FloatField("Past Trajectory Window", PastTrajectoryWindow);
     FutureTrajectoryWindow    = EditorGUILayout.FloatField("Future Trajectory Window", FutureTrajectoryWindow);
     //ShowSkeletons = EditorGUILayout.Toggle("Show Skeletons", ShowSkeletons);
     //SkeletonStep = EditorGUILayout.IntField("Skeleton Step", SkeletonStep);
     ShowContacts        = EditorGUILayout.Toggle("Show Contacts", ShowContacts);
     ContactTrajectories = EditorGUILayout.Toggle("Contact Trajectories", ContactTrajectories);
     Step          = EditorGUILayout.IntField("Step", Step);
     CaptureFilter = EditorGUILayout.Slider("Capture Filter", CaptureFilter, 0f, 1f);
     EditFilter    = EditorGUILayout.Slider("Edit Filter", EditFilter, 0f, 1f);
     for (int i = 0; i < Sensors.Length; i++)
     {
         EditorGUILayout.BeginHorizontal();
         Sensors[i].Inspector(editor);
         EditorGUILayout.BeginVertical();
         if (Utility.GUIButton("-", UltiDraw.DarkRed, UltiDraw.White, 28f, 18f))
         {
             RemoveSensor(Sensors[i]);
         }
         EditorGUILayout.EndVertical();
         EditorGUILayout.EndHorizontal();
     }
     if (Utility.GUIButton("+", UltiDraw.DarkGrey, UltiDraw.White))
     {
         AddSensor();
     }
 }
Ejemplo n.º 18
0
        private IEnumerator Generate()
        {
            m_StaticRenderers = Utils.GetStaticRenderers();
            Bounds bounds = Utils.GetSceneBounds(m_StaticRenderers);

            yield return(EditorCoroutines.StartCoroutine(Utils.BuildHierarchicalVolumeGrid(bounds, 0, value => m_VolumeData = value, this), this));

            yield return(EditorCoroutines.StartCoroutine(Utils.BuildVisibilityForVolume(bounds, m_RayDensity, m_StaticRenderers, value => m_PassedRenderers = value, value => m_DebugData = value, this, m_FilterAngle), this));

            totalBounds         = bounds.size;
            totalRays           = m_DebugData.rays.Length;
            successfulRays      = m_DebugData.rays.Where(s => s.pass).ToList().Count;
            totalRenderers      = m_StaticRenderers.Length;
            successfulRenderers = m_PassedRenderers.Length;
            displayDebug        = true;
            UnityEditor.SceneView.RepaintAll();
        }
Ejemplo n.º 19
0
        // --------------------------------------------------
        // Test Execution

        private void Update()
        {
            m_StaticRenderers = Utils.GetStaticRenderers();
            List <MeshRenderer> renderers = new List <MeshRenderer>();

            if (m_Occluders == null)
            {
                EditorCoroutines.StartCoroutine(Utils.BuildOccluderProxyGeometry(transform, m_StaticRenderers, value => m_Occluders = value, this), this);
            }

            for (int i = 0; i < m_StaticRenderers.Length; i++)
            {
                if (Utils.CheckAABBIntersection(raySource.position, raySource.forward, m_StaticRenderers[i].bounds))
                {
                    if (Utils.CheckOcclusion(m_Occluders, m_StaticRenderers[i], raySource.position, raySource.forward))
                    {
                        renderers.Add(m_StaticRenderers[i]);
                    }
                }
            }
            m_PassedRenderers = renderers.ToArray();
        }
Ejemplo n.º 20
0
        /// <inheritdoc />
        /// <summary>
        /// Executes this step.
        /// </summary>
        /// <param name="context">Current job context.</param>
        /// <returns>Returns true if execution was successful.</returns>
        protected override IEnumerator OnExecute(JobContext context)
        {
            var isConditionTrue = ConditionCollection.EvaluateAll(context);

            if (isConditionTrue)
            {
                InnerScope.ScopeContext = context;
                yield return(EditorCoroutines.StartCoroutine(InnerScope.StartExecutingSteps(), this));

                PostExecutionRequest = StepRequest.SkipNext;
            }
            else
            {
                foreach (var child in Children)
                {
                    child.Status = StepStatus.Skipped;
                    yield return(null);
                }
            }

            IsSuccess = true;
            yield return(null);
        }
Ejemplo n.º 21
0
 public static EditorCoroutines.EditorCoroutine StartCoroutine(this EditorWindow thisRef, string methodName, object value)
 {
     return(EditorCoroutines.StartCoroutine(methodName, value, thisRef));
 }
Ejemplo n.º 22
0
 public static EditorCoroutines.EditorCoroutine StartCoroutine(this EditorWindow thisRef, IEnumerator coroutine)
 {
     return(EditorCoroutines.StartCoroutine(coroutine, thisRef));
 }
Ejemplo n.º 23
0
        // --------------------------------------------------
        // Visibility

        public static IEnumerator BuildOcclusionForVolume(Bounds bounds, int rayDensity, MeshRenderer[] staticRenderers, OccluderData[] occluders, Action <MeshRenderer[]> result, object obj, int coneAngle = 45)
        {
            VolumeDebugData debugData = new VolumeDebugData();

            yield return(EditorCoroutines.StartCoroutine(BuildVisibilityAndOcclusionForVolume(bounds, rayDensity, staticRenderers, result, value => debugData = value, coneAngle, occluders), obj));
        }
Ejemplo n.º 24
0
        public void Inspector()
        {
            Target.Refresh();

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

                Utility.SetGUIColor(UltiDraw.Yellow);
                using (new EditorGUILayout.VerticalScope("Box")) {
                    Utility.ResetGUIColor();
                    EditorGUILayout.LabelField("Import Settings");
                }

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

                    EditorGUILayout.BeginHorizontal();
                    GUILayout.FlexibleSpace();
                    if (Utility.GUIButton("Add Folder", UltiDraw.DarkGrey, UltiDraw.White, 100f, 18f))
                    {
                        ArrayExtensions.Append(ref Target.Folders, string.Empty);
                        ArrayExtensions.Append(ref Target.Imports, true);
                    }
                    if (Utility.GUIButton("Remove Folder", UltiDraw.DarkGrey, UltiDraw.White, 100f, 18f))
                    {
                        ArrayExtensions.Shrink(ref Target.Folders);
                        ArrayExtensions.Shrink(ref Target.Imports);
                    }
                    if (Utility.GUIButton(Target.GetLoadStrategy(), UltiDraw.LightGrey, UltiDraw.Black, 100f, 18f))
                    {
                        Target.ToggleLoadStrategy();
                    }
                    if (Utility.GUIButton(Target.LoadTagged ? "Tagged" : "Any", UltiDraw.LightGrey, UltiDraw.Black, 100f, 18f))
                    {
                        Target.LoadTagged = !Target.LoadTagged;
                    }
                    GUILayout.FlexibleSpace();
                    EditorGUILayout.EndHorizontal();

                    Utility.SetGUIColor(UltiDraw.DarkGrey);
                    using (new EditorGUILayout.VerticalScope("Box")) {
                        Utility.ResetGUIColor();
                        for (int i = 0; i < Target.Folders.Length; i++)
                        {
                            EditorGUILayout.BeginHorizontal();
                            Utility.SetGUIColor(Target.IsFolderValid(i) ? (Target.Imports[i] ? UltiDraw.DarkGreen : UltiDraw.Gold) : UltiDraw.DarkRed);
                            Target.Folders[i] = EditorGUILayout.TextField(Target.Folders[i]);
                            Target.Imports[i] = EditorGUILayout.Toggle(Target.Imports[i], GUILayout.Width(20f));
                            Utility.ResetGUIColor();
                            EditorGUILayout.EndHorizontal();
                        }
                    }

                    if (!Target.Importing)
                    {
                        if (Utility.GUIButton("Import", UltiDraw.DarkGrey, UltiDraw.White))
                        {
                            EditorCoroutines.StartCoroutine(Target.Import(() => ApplyFilter()), this);
                        }
                    }
                    else
                    {
                        EditorGUI.DrawRect(new Rect(EditorGUILayout.GetControlRect().x, EditorGUILayout.GetControlRect().y, Target.Progress * EditorGUILayout.GetControlRect().width, 25f), UltiDraw.Green.Opacity(0.75f));
                        EditorGUI.LabelField(new Rect(EditorGUILayout.GetControlRect()), Target.CurrentFile + " / " + Target.TotalFiles);
                        EditorGUI.BeginDisabledGroup(!Target.Importing);
                        if (Utility.GUIButton(!Target.Importing ? "Aborting" : "Stop", !Target.Importing ? UltiDraw.Gold : UltiDraw.DarkRed, UltiDraw.White))
                        {
                            Target.Importing = false;
                        }
                        EditorGUI.EndDisabledGroup();
                    }
                }
            }

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

                Utility.SetGUIColor(UltiDraw.Yellow);
                using (new EditorGUILayout.VerticalScope("Box")) {
                    Utility.ResetGUIColor();
                    EditorGUILayout.LabelField("Data Inspector");
                }

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

                    //Selection Browser
                    int pivot = MotionEditor.FindIndex(Assets, Utility.GetAssetGUID(Target.Data));
                    EditorGUILayout.BeginHorizontal();
                    EditorGUI.BeginChangeCheck();
                    int selectIndex = EditorGUILayout.Popup(pivot, Enums);
                    if (EditorGUI.EndChangeCheck())
                    {
                        if (selectIndex != -1)
                        {
                            Target.LoadData(Assets[selectIndex]);
                        }
                    }

                    EditorGUI.BeginChangeCheck();
                    Filter = EditorGUILayout.TextField(Filter, GUILayout.Width(200f));
                    if (EditorGUI.EndChangeCheck())
                    {
                        ApplyFilter();
                    }

                    if (Utility.GUIButton("<", UltiDraw.DarkGrey, UltiDraw.White, 55f))
                    {
                        LoadPreviousAsset();
                    }
                    if (Utility.GUIButton(">", UltiDraw.DarkGrey, UltiDraw.White, 55f))
                    {
                        LoadNextAsset();
                    }

                    EditorGUILayout.EndHorizontal();

                    //Slider Browser
                    EditorGUILayout.BeginHorizontal();
                    if (Assets.Length == 0)
                    {
                        EditorGUILayout.IntSlider(0, 0, 0);
                    }
                    else
                    {
                        EditorGUI.BeginChangeCheck();
                        int sliderIndex = EditorGUILayout.IntSlider(pivot + 1, 1, Assets.Length);
                        if (EditorGUI.EndChangeCheck())
                        {
                            Target.LoadData(Assets[sliderIndex - 1]);
                        }
                    }
                    EditorGUILayout.LabelField("/ " + Assets.Length, GUILayout.Width(60f));
                    EditorGUILayout.EndHorizontal();

                    if (Target.Data != null)
                    {
                        Frame frame = Target.GetCurrentFrame();

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

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

                                Utility.SetGUIColor(UltiDraw.LightGrey);
                                EditorGUILayout.ObjectField(Target.Data, typeof(MotionData), true);
                                Utility.ResetGUIColor();
                                EditorGUILayout.HelpBox(Target.Data.GetParentDirectoryPath(), MessageType.None);
                            }

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

                            //Sequences
                            for (int i = 0; i < Target.Data.Sequences.Length; i++)
                            {
                                Target.DrawRect(Target.Data.GetFrame(Target.Data.Sequences[i].Start), Target.Data.GetFrame(Target.Data.Sequences[i].End), 1f, !Target.Data.Export ? UltiDraw.White.Opacity(.25f) : UltiDraw.Green.Opacity(0.25f), rect);
                            }

                            //Valid Window
                            Target.DrawRect(Target.Data.Frames.First(), Target.Data.GetFirstValidFrame(), 1f, UltiDraw.DarkRed.Opacity(0.5f), rect);
                            Target.DrawRect(Target.Data.GetLastValidFrame(), Target.Data.Frames.Last(), 1f, UltiDraw.DarkRed.Opacity(0.5f), rect);

                            //Current Pivot
                            Target.DrawPivot(rect);

                            EditorGUILayout.EndVertical();

                            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, 50f, 40f))
                                    {
                                        Target.StopAnimation();
                                    }
                                }
                                else
                                {
                                    if (Utility.GUIButton("|>", Color.green, Color.black, 50f, 40f))
                                    {
                                        Target.PlayAnimation();
                                    }
                                }
                                if (Utility.GUIButton("<", UltiDraw.Grey, UltiDraw.White, 20f, 40f))
                                {
                                    Target.LoadFrame(Mathf.Max(frame.Timestamp - Target.Data.GetDeltaTime(), 0f));
                                }
                                if (Utility.GUIButton(">", UltiDraw.Grey, UltiDraw.White, 20f, 40f))
                                {
                                    Target.LoadFrame(Mathf.Min(frame.Timestamp + Target.Data.GetDeltaTime(), Target.Data.GetTotalTime()));
                                }

                                int index = EditorGUILayout.IntSlider(frame.Index, 1, Target.Data.GetTotalFrames(), GUILayout.Height(40f));
                                if (index != frame.Index)
                                {
                                    Target.LoadFrame(index);
                                }
                                EditorGUILayout.BeginVertical();
                                EditorGUILayout.LabelField("/ " + Target.Data.GetTotalFrames() + " @ " + Mathf.RoundToInt(Target.Data.Framerate) + "Hz", Utility.GetFontColor(Color.white), GUILayout.Width(80f));
                                EditorGUILayout.LabelField("[" + frame.Timestamp.ToString("F2") + "s / " + Target.Data.GetTotalTime().ToString("F2") + "s]", Utility.GetFontColor(Color.white), GUILayout.Width(80f));
                                EditorGUILayout.EndVertical();
                                GUILayout.FlexibleSpace();
                                EditorGUILayout.EndHorizontal();
                            }
                        }

                        Target.Data.Inspector(Target);
                    }
                }
            }

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

                Utility.SetGUIColor(UltiDraw.Yellow);
                using (new EditorGUILayout.VerticalScope("Box")) {
                    Utility.ResetGUIColor();
                    EditorGUILayout.LabelField("Editor Settings");
                }

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

                    Target.SetModel((Actor)EditorGUILayout.ObjectField("Character", Target.Model, typeof(Actor), true));

                    Target.SetTargetFramerate(EditorGUILayout.FloatField("Target Framerate", Target.TargetFramerate));

                    Target.Timescale = EditorGUILayout.FloatField("Timescale", Target.Timescale);

                    Target.SetRandomSeed(EditorGUILayout.IntField("Random Seed", Target.RandomSeed));

                    Target.Zoom = EditorGUILayout.Slider("Zoom", Target.Zoom, 0f, 1f);

                    Utility.SetGUIColor(UltiDraw.DarkGrey);
                    using (new EditorGUILayout.VerticalScope("Box")) {
                        Utility.ResetGUIColor();
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        EditorGUILayout.LabelField("Past Keys", Utility.GetFontColor(Color.white), GUILayout.Width(90f));
                        Target.SetPastKeys(EditorGUILayout.IntField(Target.PastKeys, GUILayout.Width(50f)));
                        EditorGUILayout.LabelField("Future Keys", Utility.GetFontColor(Color.white), GUILayout.Width(90f));
                        Target.SetFutureKeys(EditorGUILayout.IntField(Target.FutureKeys, GUILayout.Width(50f)));
                        EditorGUILayout.LabelField("Past Window", Utility.GetFontColor(Color.white), GUILayout.Width(90f));
                        Target.SetPastWindow(EditorGUILayout.FloatField(Target.PastWindow, GUILayout.Width(50f)));
                        EditorGUILayout.LabelField("Future Window", Utility.GetFontColor(Color.white), GUILayout.Width(90f));
                        Target.SetFutureWindow(EditorGUILayout.FloatField(Target.FutureWindow, GUILayout.Width(50f)));
                        GUILayout.FlexibleSpace();
                        EditorGUILayout.EndHorizontal();
                    }

                    EditorGUILayout.BeginHorizontal();
                    if (Utility.GUIButton("Mark As First Valid Frame", UltiDraw.DarkGrey, UltiDraw.White))
                    {
                        Target.Data.SetFirstValidFrame(Target.GetCurrentFrame());
                    }
                    if (Utility.GUIButton("Mark As Last Valid Frame", UltiDraw.DarkGrey, UltiDraw.White))
                    {
                        Target.Data.SetLastValidFrame(Target.GetCurrentFrame());
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    if (Utility.GUIButton("Visualize First Frame", Target.VisualizeFirstFrame ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                    {
                        Target.VisualizeFirstFrame = !Target.VisualizeFirstFrame;
                    }
                    if (Utility.GUIButton("Visualize Last Frame", Target.VisualizeLastFrame ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                    {
                        Target.VisualizeLastFrame = !Target.VisualizeLastFrame;
                    }
                    EditorGUILayout.EndHorizontal();

                    EditorGUILayout.BeginHorizontal();
                    if (Utility.GUIButton("Visualize", Target.Visualize ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                    {
                        Target.SetVisualize(!Target.Visualize);
                    }
                    if (Utility.GUIButton("Mirror", Target.Mirror ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                    {
                        Target.SetMirror(!Target.Mirror);
                    }
                    if (Utility.GUIButton("Precomputable", Target.Precomputable ? UltiDraw.Cyan : UltiDraw.LightGrey, UltiDraw.Black))
                    {
                        Target.SetPrecomputable(!Target.Precomputable);
                    }
                    EditorGUILayout.EndHorizontal();

                    Utility.SetGUIColor(UltiDraw.DarkGrey);
                    using (new EditorGUILayout.VerticalScope("Box")) {
                        Utility.ResetGUIColor();
                        if (Utility.GUIButton("Camera Focus", Target.CameraFocus ? UltiDraw.Cyan : UltiDraw.DarkGrey, Target.CameraFocus ? UltiDraw.Black : UltiDraw.White))
                        {
                            Target.SetCameraFocus(!Target.CameraFocus);
                        }
                        if (Target.CameraFocus)
                        {
                            Utility.SetGUIColor(UltiDraw.LightGrey);
                            using (new EditorGUILayout.VerticalScope("Box")) {
                                Utility.ResetGUIColor();
                                Target.FocusHeight    = EditorGUILayout.FloatField("Focus Height", Target.FocusHeight);
                                Target.FocusDistance  = EditorGUILayout.FloatField("Focus Distance", Target.FocusDistance);
                                Target.FocusAngle.y   = EditorGUILayout.Slider("Focus Angle Horizontal", Target.FocusAngle.y, -180f, 180f);
                                Target.FocusAngle.x   = EditorGUILayout.Slider("Focus Angle Vertical", Target.FocusAngle.x, -180f, 180f);
                                Target.FocusSmoothing = EditorGUILayout.Slider("Focus Smoothing", Target.FocusSmoothing, 0f, 1f);
                            }
                        }
                    }

                    Utility.SetGUIColor(UltiDraw.DarkGrey);
                    using (new EditorGUILayout.VerticalScope("Box")) {
                        Utility.ResetGUIColor();
                        if (Utility.GUIButton("Motion Trail", Target.MotionTrail ? UltiDraw.Cyan : UltiDraw.DarkGrey, Target.MotionTrail ? UltiDraw.Black : UltiDraw.White))
                        {
                            Target.SetMotionTrail(!Target.MotionTrail);
                        }
                        if (Target.MotionTrail)
                        {
                            Utility.SetGUIColor(UltiDraw.LightGrey);
                            using (new EditorGUILayout.VerticalScope("Box")) {
                                Utility.ResetGUIColor();
                                Target.CharacterMeshTrail  = EditorGUILayout.Toggle("Character Mesh", Target.CharacterMeshTrail);
                                Target.SkeletonSketchTrail = EditorGUILayout.Toggle("Skeleton Sketch", Target.SkeletonSketchTrail);
                                Target.ApplyMotionTrail();
                            }
                        }
                    }
                }
            }
            //END
        }
Ejemplo n.º 25
0
 public static IEnumerator BuildVisibilityForVolume(Bounds bounds, int rayDensity, MeshRenderer[] staticRenderers, Action <MeshRenderer[]> result, Action <VolumeDebugData> debugData, object obj, int coneAngle = 45)
 {
     yield return(EditorCoroutines.StartCoroutine(BuildVisibilityAndOcclusionForVolume(bounds, rayDensity, staticRenderers, result, debugData, coneAngle), obj));
 }
Ejemplo n.º 26
0
 public void OnClickGenerate()
 {
     EditorCoroutines.StartCoroutine(Generate(), this);
 }
 void UpdateProtos()
 {
     EditorCoroutines.StartCoroutine(UpdateProtosCoroutine(), this);
 }
Ejemplo n.º 28
0
 public void OnClickGenerate()
 {
     EditorCoroutines.StopAllCoroutines(this);
     EditorCoroutines.StartCoroutine(GenerateOcclusion(), this);
 }