private bool CastRay(Vector2 loc, out RaycastHit hit)
        {
            switch (ModeData.Mode)
            {
            case DistributionMode.Surface:
                foreach (Collider col in _surfaceColliders)
                {
                    if (col.Raycast(new Ray(new Vector3(loc.x, _surfaceBounds.max.y + 1, loc.y), Vector3.down), out hit, _surfaceBounds.size.y + 2))
                    {
                        return(true);
                    }
                }
                hit = new RaycastHit();
                return(false);

            case DistributionMode.ProjectionPlane:
            case DistributionMode.ProjectionEllipse:
            {
                float xPos = Remap(loc.x, _surfaceBounds.min.x, _surfaceBounds.max.x, -0.5f, 0.5f);
                float zPos = Remap(loc.y, _surfaceBounds.min.z, _surfaceBounds.max.z, -0.5f, 0.5f);

                Transform transform = EditorData.HelperVisual.transform;
                Matrix4x4 mat       = transform.localToWorldMatrix;
                Vector3   startPos  = mat.MultiplyPoint(new Vector3(xPos, 0.0f, zPos));

                LayerMask correctedMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(_activeData.ProjectionLayerMask);
                Vector3   direction     = mat.MultiplyPoint(new Vector3(xPos, -1.0f, zPos)) - startPos;
                return(Physics.Raycast(startPos, direction, out hit, direction.magnitude, correctedMask, _activeData.ProjectionRaycastTriggerInteraction));
            }

            case DistributionMode.Plane:
            case DistributionMode.Ellipse:
            {
                hit = new RaycastHit();

                float xPos = Remap(loc.x, _surfaceBounds.min.x, _surfaceBounds.max.x, -0.5f, 0.5f);
                float zPos = Remap(loc.y, _surfaceBounds.min.z, _surfaceBounds.max.z, -0.5f, 0.5f);

                Transform transform = EditorData.HelperVisual.transform;
                Matrix4x4 mat       = transform.localToWorldMatrix;

                hit.normal = mat.MultiplyVector(Vector3.up).normalized;
                hit.point  = mat.MultiplyPoint(new Vector3(xPos, 0.0f, zPos));

                return(true);
            }

            default:
                hit = new RaycastHit();
                return(true);
            }
        }
Beispiel #2
0
 protected override void DerivedInspector(MotionEditor editor)
 {
     Root          = EditorGUILayout.Popup("Root", Root, Data.Source.GetBoneNames());
     Topology      = (TOPOLOGY)EditorGUILayout.EnumPopup("Topology", Topology);
     RightShoulder = EditorGUILayout.Popup("Right Shoulder", RightShoulder, Data.Source.GetBoneNames());
     LeftShoulder  = EditorGUILayout.Popup("Left Shoulder", LeftShoulder, Data.Source.GetBoneNames());
     RightHip      = EditorGUILayout.Popup("Right Hip", RightHip, Data.Source.GetBoneNames());
     LeftHip       = EditorGUILayout.Popup("Left Hip", LeftHip, Data.Source.GetBoneNames());
     Neck          = EditorGUILayout.Popup("Neck", Neck, Data.Source.GetBoneNames());
     Hips          = EditorGUILayout.Popup("Hips", Hips, Data.Source.GetBoneNames());
     ForwardAxis   = (Axis)EditorGUILayout.EnumPopup("Forward Axis", ForwardAxis);
     Ground        = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUILayout.MaskField("Ground Mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Ground), InternalEditorUtility.layers));
     Smooth        = EditorGUILayout.Toggle("Smooth", Smooth);
 }
Beispiel #3
0
    public override bool DrawInspectorGUI()
    {
        bool      change   = false;
        LayerMask old      = mask;
        LayerMask tempMask = EditorGUILayout.MaskField("Mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(mask), InternalEditorUtility.layers);

        mask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask);

        if (mask != old)
        {
            change = true;
        }

        return(change | base.DrawInspectorGUI());
    }
        protected override void OnControlGUI(Rect position)
        {
            EditorGUI.BeginChangeCheck();

            var newValue = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUI.MaskField
                                                                                   (
                                                                                       position,
                                                                                       InternalEditorUtility.LayerMaskToConcatenatedLayersMask((LayerMask)accessor.value),
                                                                                       InternalEditorUtility.layers
                                                                                   ));

            if (EditorGUI.EndChangeCheck())
            {
                accessor.RecordUndo();
                accessor.value = newValue;
            }
        }
        protected override void OnGUI(Rect position, GUIContent label)
        {
            position = BeginBlock(metadata, position, label);

            var newValue = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUI.MaskField
                                                                                   (
                                                                                       position,
                                                                                       InternalEditorUtility.LayerMaskToConcatenatedLayersMask((LayerMask)metadata.value),
                                                                                       InternalEditorUtility.layers
                                                                                   ));

            if (EndBlock(metadata))
            {
                metadata.RecordUndo();
                metadata.value = newValue;
            }
        }
    public override void OnInspectorGUI()
    {
        EditorGUILayout.LabelField("Grass Limit", EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal();
        EditorGUILayout.LabelField(grassPainter.i.ToString() + "/", EditorStyles.label);
        grassPainter.grassLimit = EditorGUILayout.IntField(grassPainter.grassLimit);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Paint Status (Right-Mouse Button to paint)", EditorStyles.boldLabel);
        grassPainter.toolbarInt = GUILayout.Toolbar(grassPainter.toolbarInt, toolbarStrings);
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Brush Settings", EditorStyles.boldLabel);
        LayerMask tempMask = EditorGUILayout.MaskField("Hit Mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(grassPainter.hitMask), InternalEditorUtility.layers);

        grassPainter.hitMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask);
        LayerMask tempMask2 = EditorGUILayout.MaskField("Painting Mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(grassPainter.paintMask), InternalEditorUtility.layers);

        grassPainter.paintMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask2);

        grassPainter.brushSize   = EditorGUILayout.Slider("Brush Size", grassPainter.brushSize, 0.1f, 10f);
        grassPainter.density     = EditorGUILayout.Slider("Density", grassPainter.density, 0.1f, 10f);
        grassPainter.normalLimit = EditorGUILayout.Slider("Normal Limit", grassPainter.normalLimit, 0f, 1f);


        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Width and Length ", EditorStyles.boldLabel);
        grassPainter.sizeWidth  = EditorGUILayout.Slider("Grass Width", grassPainter.sizeWidth, 0f, 2f);
        grassPainter.sizeLength = EditorGUILayout.Slider("Grass Length", grassPainter.sizeLength, 0f, 2f);
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Color", EditorStyles.boldLabel);
        grassPainter.AdjustedColor = EditorGUILayout.ColorField("Brush Color", grassPainter.AdjustedColor);
        EditorGUILayout.LabelField("Random Color Variation", EditorStyles.boldLabel);
        grassPainter.rangeR = EditorGUILayout.Slider("Red", grassPainter.rangeR, 0f, 1f);
        grassPainter.rangeG = EditorGUILayout.Slider("Green", grassPainter.rangeG, 0f, 1f);
        grassPainter.rangeB = EditorGUILayout.Slider("Blue", grassPainter.rangeB, 0f, 1f);

        if (GUILayout.Button("Clear Mesh"))
        {
            if (EditorUtility.DisplayDialog("Clear Painted Mesh?",
                                            "Are you sure you want to clear the mesh?", "Clear", "Don't Clear"))
            {
                grassPainter.ClearMesh();
            }
        }
    }
Beispiel #7
0
        public override void BaseGUI()
        {
            BeginBox();
            GUILayout.Label(ContentProperties.ViewProperties, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(7);
            instance.SetViewRadius(EditorGUILayout.FloatField(ContentProperties.ViewRadius, instance.GetViewRadius()));
            instance.SetViewAngle(EditorGUILayout.Slider(ContentProperties.ViewAngle, instance.GetViewAngle(), 0, 360));

            GUILayout.Space(10);
            GUILayout.Label(ContentProperties.MasksProperties, UEditorStyles.SectionHeaderLabel);
            GUILayout.Space(7);
            LayerMask targetMask = EditorGUILayout.MaskField(ContentProperties.TargetMask, InternalEditorUtility.LayerMaskToConcatenatedLayersMask(instance.GetTargetMask()), InternalEditorUtility.layers);

            instance.SetTargetMask(InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(targetMask));
            LayerMask obstacleMask = EditorGUILayout.MaskField(ContentProperties.ObstacleMask, InternalEditorUtility.LayerMaskToConcatenatedLayersMask(instance.GetObstacleMask()), InternalEditorUtility.layers);

            instance.SetObstacleMask(InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(obstacleMask));
            EndBox();
        }
Beispiel #8
0
 /// <summary>
 /// Draws field based on current setting to check for
 /// </summary>
 public void DrawSettings()
 {
     if (script.checksFor == OnTrigger_Base.Check.Layer)
     {
         Undo.RecordObject(script, "Changed Layer");
         script.layers = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUILayout.MaskField("Layers:",
                                                                                                           InternalEditorUtility.LayerMaskToConcatenatedLayersMask(script.layers), InternalEditorUtility.layers));
     }
     else if (script.checksFor == OnTrigger_Base.Check.Tag)
     {
         Undo.RecordObject(script, "Changed Tag");
         script.tagName = EditorGUILayout.TagField("Tag:", script.tagName);
     }
     else if (script.checksFor == OnTrigger_Base.Check.Name)
     {
         Undo.RecordObject(script, "Changed Name");
         script.nameContains = EditorGUILayout.TextField("Name Contains:", script.nameContains).Trim();
     }
 }
Beispiel #9
0
    private void LayoutWaypointsSettings()
    {
        EditorGUILayout.LabelField("Pathfinding Area", _headerStyle);

        EditorGUI.BeginChangeCheck();

        //Si hago un cambio en el area o los waypoints, recalculo las posiciones
        GUILayout.BeginHorizontal();
        _pathfindingAreaWidth  = EditorGUILayout.FloatField("Width", _pathfindingAreaWidth);
        _pathfindingAreaLength = EditorGUILayout.FloatField("Length", _pathfindingAreaLength);
        GUILayout.EndHorizontal();
        EditorGUILayout.LabelField("Waypoints amount", _headerStyle);
        GUILayout.BeginHorizontal();
        _waypointRows    = EditorGUILayout.IntField("Rows", _waypointRows);
        _waypointColumns = EditorGUILayout.IntField("Columns", _waypointColumns);
        GUILayout.EndHorizontal();
        _originPoint = EditorGUILayout.Vector3Field("Origin Point", _originPoint);

        var rect = EditorGUILayout.GetControlRect(false, 1);

        EditorGUI.DrawRect(rect, Color.gray);

        EditorGUILayout.LabelField("Obstacles", _headerStyle);
        _detectObstacles         = EditorGUILayout.Toggle("Don't instantiate near obstacles", _detectObstacles);
        _radiusObstacleDetection = EditorGUILayout.FloatField("Radius Detection", _radiusObstacleDetection);

        LayerMask tempMask = EditorGUILayout.MaskField("Obstacles mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(_obstaclesMask), InternalEditorUtility.layers);

        _obstaclesMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask);

        if (EditorGUI.EndChangeCheck())
        {
            _pathfindingAreaWidth    = _pathfindingAreaWidth < 0 ? 0 : _pathfindingAreaWidth;
            _pathfindingAreaLength   = _pathfindingAreaLength < 0 ? 0 : _pathfindingAreaLength;
            _waypointRows            = _waypointRows < 1 ? 1 : _waypointRows;
            _waypointColumns         = _waypointColumns < 1 ? 1 : _waypointColumns;
            _radiusObstacleDetection = _radiusObstacleDetection < 0 ? 0 : _radiusObstacleDetection;

            CalculatePositions();
        }
    }
Beispiel #10
0
        void OnGUI()
        {
            EditorGUILayout.BeginVertical("box");

            affectRotation = EditorGUILayout.Toggle("Affect rotation", affectRotation);

            EditorGUILayout.LabelField("LayerMask");
            LayerMask tempMask = EditorGUILayout.MaskField(InternalEditorUtility.LayerMaskToConcatenatedLayersMask(mask), InternalEditorUtility.layers);

            mask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask);

            EditorGUILayout.LabelField("Buried level");
            offset = EditorGUILayout.FloatField(offset);

            EditorGUILayout.EndVertical();

            if (GUILayout.Button("Set"))
            {
                SetPositions(Selection.gameObjects);
            }
        }
        private void LayerMasking(Rect Area, DynamicDecalSettings Settings)
        {
            if (Settings.UseMaskLayers)
            {
                //Begin Layout area
                GUILayout.BeginArea(Area);

                //Header
                if (Settings.maskMethod == DecalMaskMethod.Both)
                {
                    EditorGUILayout.LabelField(layers, EditorStyles.boldLabel);
                }

                //Generate layer options
                for (int i = 0; i < Settings.Layers.Length; i++)
                {
                    EditorGUI.BeginChangeCheck();

                    EditorGUILayout.BeginHorizontal();
                    string layerName = EditorGUILayout.TextField(new GUIContent(""), Settings.Layers[i].name, GUILayout.Width(Area.width - 180));
                    GUILayout.FlexibleSpace();
                    LayerMask layerMask = EditorGUILayout.MaskField(new GUIContent(""), InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Settings.Layers[i].layers), InternalEditorUtility.layers, GUILayout.Width(160));
                    EditorGUILayout.EndHorizontal();

                    if (EditorGUI.EndChangeCheck())
                    {
                        //Record state for undo
                        Undo.RecordObject(Settings, "Layer name");

                        //Change layer name
                        Settings.Layers[i].name   = layerName;
                        Settings.Layers[i].layers = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(layerMask);

                        //Recalculate passes
                        Settings.CalculatePasses();
                    }
                }
                GUILayout.EndArea();
            }
        }
Beispiel #12
0
        private void DrawWindow()
        {
            EditorGUILayout.BeginVertical("box");
            {
                //GameObject Array
                {
                    ScriptableObject   scriptableObj = this;
                    SerializedObject   serialObj     = new SerializedObject(scriptableObj);
                    SerializedProperty serialProp    = serialObj.FindProperty("objectsToInstance");

                    EditorGUILayout.PropertyField(serialProp, true);
                    serialObj.ApplyModifiedProperties();
                }

                //Parent
                {
                    _parent = (Transform)EditorGUILayout.ObjectField("Parent ", _parent, typeof(Transform), true);
                }

                //Offset
                {
                    _offset = EditorGUILayout.Vector3Field("Offset", _offset);
                }

                //Rotacion
                {
                    _useRandomRotation = EditorGUILayout.Toggle("Random Rotacion", _useRandomRotation);
                    _useGroundRotation = EditorGUILayout.Toggle("Use ground rotation", _useGroundRotation);
                }

                //Layer Mask popup
                {
                    EditorGUILayout.LabelField("LayerMask");
                    LayerMask tempMask = EditorGUILayout.MaskField(InternalEditorUtility.LayerMaskToConcatenatedLayersMask(_mask), InternalEditorUtility.layers);
                    _mask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask);
                }
            }
            EditorGUILayout.EndVertical();
        }
Beispiel #13
0
        /// <summary>
        /// Display the Controllers Pointer Parameters
        /// </summary>
        private void ShowPointerParameters(EHand hand)
        {
            Undo.RecordObject(_controllersParameters, "Modifiying pointer");

            switch (hand)
            {
            case (EHand.RIGHT):
                _controllersParameters.RightPointerState = (EPointerState)EditorGUILayout.EnumPopup("Right Pointer State", _controllersParameters.RightPointerState);

                LayerMask rightTempMask = EditorGUILayout.MaskField("Excluded layer Right", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(_controllersParameters.RightExclusionLayer), InternalEditorUtility.layers);
                _controllersParameters.RightExclusionLayer = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(rightTempMask);

                _controllersParameters.ColorMatOnRight         = EditorGUILayout.ColorField("Color On Right", _controllersParameters.ColorMatOnRight);
                _controllersParameters.ColorMatOffRight        = EditorGUILayout.ColorField("Color Off Right", _controllersParameters.ColorMatOffRight);
                _controllersParameters.ColorMatSelectableRight = EditorGUILayout.ColorField("Color Selectable Right", _controllersParameters.ColorMatSelectableRight);

                _controllersParameters.MaxDistancePointerRight = EditorGUILayout.FloatField("Max Distance Right Pointer", _controllersParameters.MaxDistancePointerRight);
                break;

            case (EHand.LEFT):
                _controllersParameters.LeftPointerState = (EPointerState)EditorGUILayout.EnumPopup("Left Pointer State", _controllersParameters.LeftPointerState);

                LayerMask leftTempMask = EditorGUILayout.MaskField("Excluded layer Left", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(_controllersParameters.LeftExclusionLayer), InternalEditorUtility.layers);
                _controllersParameters.LeftExclusionLayer = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(leftTempMask);

                _controllersParameters.ColorMatOnLeft         = EditorGUILayout.ColorField("Color On Left", _controllersParameters.ColorMatOnLeft);
                _controllersParameters.ColorMatOffLeft        = EditorGUILayout.ColorField("Color Off Left", _controllersParameters.ColorMatOffLeft);
                _controllersParameters.ColorMatSelectableLeft = EditorGUILayout.ColorField("Color Selectable Left", _controllersParameters.ColorMatSelectableLeft);

                _controllersParameters.MaxDistancePointerLeft = EditorGUILayout.FloatField("Max Distance Left Pointer", _controllersParameters.MaxDistancePointerLeft);
                break;

            default:
                Debug.LogError("Error in ShowPointerParameters, the hand wasn't recognized.");
                break;
            }

            Undo.FlushUndoRecordObjects();
        }
Beispiel #14
0
    //all elements in the window, the elemets apply to variables that can be set or read from other code
    void OnGUI()
    {
        GUILayout.Label("base settings", EditorStyles.boldLabel);
        stign = EditorGUILayout.TextField("text fild", stign);

        testbounds = EditorGUILayout.BoundsField("bounds box", testbounds);

        GUILayout.Label("if true it will stop next to the destination if false it will get as close as possible", EditorStyles.helpBox);
        stopnextto = EditorGUILayout.Toggle("stop next to", stopnextto);

        GUILayout.Label("recalculates each step, my be coputationaly intensive", EditorStyles.helpBox);
        recalc = EditorGUILayout.Toggle("recalc", recalc);

        movespeed = EditorGUILayout.FloatField("movespeed", movespeed);

        GUILayout.Label("how long between recalculates when source has already reached destination (set to 0 to disable)", EditorStyles.helpBox);
        recalcwhenidle = EditorGUILayout.FloatField("recalc timer", recalcwhenidle);

        GUILayout.Label("how large the nodes are so bigger is less detailed, massive computational effect", EditorStyles.helpBox);
        deets = EditorGUILayout.FloatField("deets", deets);


        groupEnabled = EditorGUILayout.BeginToggleGroup("smooth movment", groupEnabled);
        GUILayout.Label("if too small it may get stuck as it cant turn sharp enough to reach the next node", EditorStyles.helpBox);
        rateofAnglechange = EditorGUILayout.FloatField("rateofAnglechange", rateofAnglechange);
        EditorGUILayout.EndToggleGroup();

        GUILayout.Label("enabling this group will ignor the box bounds", EditorStyles.helpBox);
        groupEnabled2   = EditorGUILayout.BeginToggleGroup("dynamic bounds box", groupEnabled2);
        dynamicedgesize = EditorGUILayout.FloatField("edge buffer", dynamicedgesize);
        EditorGUILayout.EndToggleGroup();

        GUILayout.Label("set this layermask to somthing if you want it to be ignored when finding a path if it have a collider on it. some examples could be if the source had a collider or a wall that it can walk through, they layermask will need to be but on thoes gameobjects", EditorStyles.helpBox);
        //theMask = EditorGUILayout.LayerField("the mask", theMask);

        LayerMask tempMask = EditorGUILayout.MaskField(InternalEditorUtility.LayerMaskToConcatenatedLayersMask(theMask), InternalEditorUtility.layers);

        theMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask);
    }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();
            enableDesigner.boolValue = EditorGUILayout.Toggle("Enable Editor", enableDesigner.boolValue);
            CheckMeshRendererEnabled();
            EditorGUILayout.PropertyField(storage, new GUIContent("Tiles"));

            EditorGUILayout.Separator();
            brushIndex.intValue = EditorGUILayout.Popup("Brush Size", brushIndex.intValue, brushTiles);

            EditorGUILayout.Separator();
            EditorGUILayout.PropertyField(tileScale, new GUIContent("Tile Scale"));
            EditorGUILayout.PropertyField(yOffset, new GUIContent("Y offset"));
            if (GUILayout.Button("Apply to all"))
            {
                ReplaceTiles();
            }
            EditorGUILayout.Separator();

            EditorGUILayout.PropertyField(alignY, new GUIContent("Align Vertically"));
            EditorGUILayout.PropertyField(tagsToIgnore, new GUIContent("Tags to ignore"), true);
            LayerMask tempMask = EditorGUILayout.MaskField("Layers to ignore", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(layersToIgnore.intValue), InternalEditorUtility.layers);

            layersToIgnore.intValue = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask);
            EditorGUILayout.Space();
            EditorGUILayout.LabelField("Click to place tiles, \nCtrl & Click to delete tiles", EditorStyles.helpBox);
            EditorGUILayout.Space();

            EditorGUILayout.Separator();
            EditorGUILayout.LabelField("At Runtime", EditorStyles.boldLabel);
            EditorGUILayout.PropertyField(disableMeshRenderersAtStart, new GUIContent("Disable Mesh Renderers at Runtime"));

            if (GUILayout.Button("Clear Grid"))
            {
                ClearGrid();
            }
            serializedObject.ApplyModifiedProperties();
        }
Beispiel #16
0
        void DrawProjectionOptions()
        {
            // Depth
            EditorGUILayout.PropertyField(m_DepthProp, Styles.Depth);
            EditorGUILayout.Slider(m_DepthFalloffProp, 0.0f, 1.0f, Styles.DepthFalloff);

            // Angle
            EditorGUILayout.Slider(m_AngleProp, 0.0f, 180.0f, Styles.Angle);
            EditorGUILayout.Slider(m_AngleFalloffProp, 0.0f, 1.0f, Styles.AngleFalloff);

            // Layer Mask
            EditorGUI.BeginChangeCheck();
            LayerMask tempMask = EditorGUILayout.MaskField(Styles.LayerMask, InternalEditorUtility.LayerMaskToConcatenatedLayersMask((LayerMask)m_LayerMaskProp.intValue), InternalEditorUtility.layers);

            tempMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask);
            if (EditorGUI.EndChangeCheck())
            {
                m_LayerMaskProp.intValue = (int)tempMask;
            }

            // Sorting Order
            EditorGUILayout.PropertyField(m_SortingOrderProp, Styles.SortingOrder);
        }
Beispiel #17
0
    private void DoCollisionAvoidance(CameraParams t)
    {
        if (showCollisionAvoidanceParams)
        {
            EditorGUI.indentLevel++;

            t.avoidCollisionWithGeometry = Toggle("Avoid collisions", t.avoidCollisionWithGeometry);
            if (t.avoidCollisionWithGeometry)
            {
                EditorGUI.indentLevel++;

                //https://answers.unity.com/questions/42996/how-to-create-layermask-field-in-a-custom-editorwi.html
                //just doing t.whateverMask = MaskField("..", t.colliderLayerMask, InternalEditorUtility.layers) makes the actual mask value one up from whatever the inspector shows, for some reason
                LayerMask colliderLayers = MaskField("Colliders layer mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(t.colliderLayerMask), InternalEditorUtility.layers);
                t.colliderLayerMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(colliderLayers);
                t.collisionMaxDistClampRelaxTime = FloatField("Distance clamp relaxation time", t.collisionMaxDistClampRelaxTime);

                EditorGUI.indentLevel--;
            }

            EditorGUI.indentLevel--;
        }
    }
    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 #19
0
    private void OnGUI()
    {
        numberOfObjects = EditorGUILayout.IntField("Number of objects", numberOfObjects);
        scaleRange      = EditorGUILayout.Vector2Field("Scale range", scaleRange);

        //https://answers.unity.com/questions/859554/editorwindow-display-array-dropdown.html
        SerializedObject   so = new SerializedObject(this);
        SerializedProperty stringsProperty = so.FindProperty("objectsToPlace");

        EditorGUILayout.PropertyField(stringsProperty, true); // True means show children
        so.ApplyModifiedProperties();                         // Remember to apply modified properties

        //Do some weird shit with the layer mask
        //https://answers.unity.com/questions/42996/how-to-create-layermask-field-in-a-custom-editorwi.html
        var tempMask = EditorGUILayout.MaskField(InternalEditorUtility.LayerMaskToConcatenatedLayersMask(mask), InternalEditorUtility.layers);

        mask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask);


        if (GUILayout.Button("Place!"))
        {
            Place();
        }
    }
Beispiel #20
0
    private void DoOcclusionAvoidance(CameraParams t)
    {
        if (showOcclusionAvoidanceParams)
        {
            EditorGUI.indentLevel++;

            t.avoidFollowTargetOcclusion = Toggle("Avoid occlusion", t.avoidFollowTargetOcclusion);
            if (t.avoidFollowTargetOcclusion)
            {
                EditorGUI.indentLevel++;

                LayerMask occluderLayers = MaskField("Occluders layer mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(t.occluderLayerMask), InternalEditorUtility.layers);
                t.occluderLayerMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(occluderLayers);

                t.occlusionPullInSpeedHorizontal = FloatField("Pull-in speed horizontal", t.occlusionPullInSpeedHorizontal);
                t.occlusionPullInSpeedVertical   = FloatField("Pull-in speed vertical", t.occlusionPullInSpeedVertical);
                t.occlusionFollowSpeedIncrease   = FloatField("Increase follow speed", t.occlusionFollowSpeedIncrease);
                t.occlusionClipPanePadding       = FloatField("Near clip pane padding", t.occlusionClipPanePadding);
                t.useTimeInOcclusionMultiplier   = Toggle("Ease in/out multiplier", t.useTimeInOcclusionMultiplier);
                if (t.useTimeInOcclusionMultiplier)
                {
                    EditorGUI.indentLevel++;

                    t.maxTimeInOcclusionMultiplier = FloatField("Max", t.maxTimeInOcclusionMultiplier);
                    t.timeInOcclusionRampUpSpeed   = FloatField("Ease in speed", t.timeInOcclusionRampUpSpeed);
                    t.timeInOcclusionRampDownSpeed = FloatField("Ease out speed", t.timeInOcclusionRampDownSpeed);

                    EditorGUI.indentLevel--;
                }

                EditorGUI.indentLevel--;
            }

            EditorGUI.indentLevel--;
        }
    }
Beispiel #21
0
        private void Inspector()
        {
            Utility.SetGUIColor(UltiDraw.Grey);
            using (new EditorGUILayout.VerticalScope("Box"))
            {
                Utility.ResetGUIColor();
                if (Utility.GUIButton("Create ControlPoint", UltiDraw.DarkGreen, UltiDraw.White))
                {
                    Target.CreateCP = !Target.CreateCP;
                }

                Target.CreateCP    = EditorGUILayout.Toggle("Create Controlpoint", Target.CreateCP);
                Target.CreateCPKey = (KeyCode)EditorGUILayout.EnumPopup("Key to create Controlpoint", Target.CreateCPKey);

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

                        string[] styles = System.Enum.GetNames(typeof(StyleNames));
                        for (int i = 0; i < styles.Length; i++)
                        {
                            StyleValues[i] = EditorGUILayout.Slider(styles[i], StyleValues[i], 0f, 1f);
                        }
                    }
                }

                if (Utility.GUIButton("ControlPoints", UltiDraw.Yellow, UltiDraw.Black))
                {
                    Target.Inspect = !Target.Inspect;
                }

                if (Target.Inspect)
                {
                    using (new EditorGUILayout.VerticalScope("Box"))
                    {
                        EditorGUI.BeginChangeCheck();
                        //LayerMask tempMask = EditorGUILayout.MaskField("Ground",InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Target.Ground), InternalEditorUtility.layers);
                        //Target.Ground = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask);
                        Target.isLooping    = EditorGUILayout.Toggle("Looping", Target.isLooping);
                        Target.TimeDelta    = EditorGUILayout.FloatField("TimeDelta", Target.TimeDelta);
                        Target.TimeInterval = EditorGUILayout.FloatField("Time between Points", Target.TimeInterval);
                        using (new EditorGUILayout.VerticalScope("Box"))
                        {
                            Target.Idle    = (Color)EditorGUILayout.ColorField("Idle", Target.Idle);
                            Target.Move    = (Color)EditorGUILayout.ColorField("Move", Target.Move);
                            Target.Jump    = (Color)EditorGUILayout.ColorField("Jump", Target.Jump);
                            Target.Sit     = (Color)EditorGUILayout.ColorField("Sit", Target.Sit);
                            Target.Stand   = (Color)EditorGUILayout.ColorField("Stand", Target.Stand);
                            Target.Lie     = (Color)EditorGUILayout.ColorField("Lie", Target.Lie);
                            Target.Sneak   = (Color)EditorGUILayout.ColorField("Sneak", Target.Sneak);
                            Target.Eat     = (Color)EditorGUILayout.ColorField("Eat", Target.Eat);
                            Target.Hydrate = (Color)EditorGUILayout.ColorField("Hydrate", Target.Hydrate);
                        }

                        if (EditorGUI.EndChangeCheck())
                        {
                            if (Application.isPlaying)
                            {
                                Target.UpdateLookUpPoints(Target.TimeDelta);
                            }
                        }
                        int countCpInspector = 0;
                        for (int i = 0; i < Target.ControlPoints.Count; i++)
                        {
                            if (!Target.ControlPoints[i].Inspector)
                            {
                                continue;
                            }
                            if (Target.ControlPoints[i].Inspector)
                            {
                                countCpInspector++;
                            }


                            int m = Target.ControlPoints[i].MotionTime;

                            EditorGUILayout.BeginHorizontal();
                            if (Utility.GUIButton("ControlPoint " + (countCpInspector - 1), UltiDraw.DarkGrey, UltiDraw.White))
                            {
                                Target.ControlPoints[i].Inspect = !Target.ControlPoints[i].Inspect;
                            }

                            EditorGUI.BeginChangeCheck();
                            if (Utility.GUIButton("X", UltiDraw.DarkRed, UltiDraw.White, 20f, 20f))
                            {
                                for (int j = 0; j < m; j++)
                                {
                                    Utility.Destroy(Target.ControlPoints[i + 1].GameObject);
                                    Target.RemoveControlPoint(Target.ControlPoints[i + 1]);
                                }

                                Utility.Destroy(Target.ControlPoints[i].GameObject);
                                Target.ControlPoints.RemoveAt(i);
                                i--;
                            }
                            if (EditorGUI.EndChangeCheck())
                            {
                                if (Application.isPlaying)
                                {
                                    Target.UpdateLookUpPoints(Target.TimeDelta);
                                }
                            }

                            EditorGUILayout.EndHorizontal();

                            if (Target.ControlPoints[i].Inspect)
                            {
                                Utility.SetGUIColor(UltiDraw.Grey);
                                using (new EditorGUILayout.VerticalScope("Box"))
                                {
                                    EditorGUI.BeginChangeCheck();
                                    Utility.ResetGUIColor();
                                    Target.ControlPoints[i].GameObject = (GameObject)EditorGUILayout.ObjectField("Controlpoint " + (countCpInspector - 1), Target.ControlPoints[i].GameObject, typeof(GameObject), true);
                                    Target.ControlPoints[i].Transform  = EditorGUILayout.ObjectField("Transform", Target.ControlPoints[i].Transform, typeof(Transform), true) as Transform;
                                    LayerMask tempMask = EditorGUILayout.MaskField("Ground", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Target.ControlPoints[i].Ground), InternalEditorUtility.layers);
                                    Target.ControlPoints[i].Ground = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask);

                                    for (int j = 0; j < Target.ControlPoints[i].GetStyles().Length; j++)
                                    {
                                        var style = Target.ControlPoints[i].GetStyles()[j];
                                        style.Value = EditorGUILayout.Slider(style.Name, style.Value, 0f, 1f);
                                    }
                                    if (EditorGUI.EndChangeCheck())
                                    {
                                        //update paused CP (motiontime)
                                        for (int j = 0; j < m; j++)
                                        {
                                            Utility.Destroy(Target.ControlPoints[i + 1].GameObject);
                                            Target.RemoveControlPoint(Target.ControlPoints[i + 1]);
                                        }

                                        for (int j = 0; j < Target.ControlPoints[i].MotionTime; j++)
                                        {
                                            Target.InsertControlPoint(Target.ControlPoints[i]);
                                        }

                                        if (Application.isPlaying)
                                        {
                                            Target.UpdateLookUpPoint(i * Target.TimeInterval);
                                        }
                                    }

                                    EditorGUI.BeginChangeCheck();
                                    Target.ControlPoints[i].MotionTime = EditorGUILayout.IntField("MotionTime", Target.ControlPoints[i].MotionTime);
                                    if (EditorGUI.EndChangeCheck())
                                    {
                                        //update paused CP (motiontime)
                                        for (int j = 0; j < m; j++)
                                        {
                                            Utility.Destroy(Target.ControlPoints[i + 1].GameObject);
                                            Target.RemoveControlPoint(Target.ControlPoints[i + 1]);
                                        }

                                        for (int j = 0; j < Target.ControlPoints[i].MotionTime; j++)
                                        {
                                            Target.InsertControlPoint(Target.ControlPoints[i]);
                                        }
                                    }
                                }
                            }
                        }
                        EditorGUI.BeginChangeCheck();
                        if (Utility.GUIButton("Remove All", UltiDraw.DarkRed, UltiDraw.White))
                        {
                            for (int i = 0; i < Target.ControlPoints.Count; i++)
                            {
                                Utility.Destroy(Target.ControlPoints[i].GameObject);
                                Target.ControlPoints.RemoveAt(i);
                                i--;
                            }
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            if (Application.isPlaying)
                            {
                                Target.UpdateLookUpPoints(Target.TimeDelta);
                            }
                        }
                    }
                }
            }
        }
Beispiel #22
0
        private void InspectEditor()
        {
            if (Target.Data == null)
            {
                return;
            }

            MotionData.Frame frame = Target.Data.GetFrame(Target.Timestamp);

            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.Mustard);
                    using (new EditorGUILayout.VerticalScope("Box")) {
                        Utility.ResetGUIColor();

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

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

                        EditorGUILayout.ObjectField("Data", Target.Data, typeof(MotionData), true);
                    }

                    Utility.SetGUIColor(UltiDraw.LightGrey);
                    using (new EditorGUILayout.VerticalScope("Box")) {
                        Utility.ResetGUIColor();
                        EditorGUILayout.BeginHorizontal();
                        GUILayout.FlexibleSpace();
                        EditorGUILayout.LabelField("Frames: " + Target.Data.GetTotalFrames(), GUILayout.Width(100f));
                        EditorGUILayout.LabelField("Time: " + Target.Data.GetTotalTime().ToString("F3") + "s", GUILayout.Width(100f));
                        EditorGUILayout.LabelField("Framerate: " + Target.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));
                        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.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();

                    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.InspectCamera = EditorGUILayout.Toggle("Camera", Target.InspectCamera);
                        }

                        if (Target.InspectCamera)
                        {
                            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);
                        }
                    }

                    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("Frame", Target.InspectFrame);
                        }

                        if (Target.InspectFrame)
                        {
                            Color[] colors = UltiDraw.GetRainbowColors(Target.Data.Styles.Length);
                            for (int i = 0; i < Target.Data.Styles.Length; i++)
                            {
                                float height = 25f;
                                EditorGUILayout.BeginHorizontal();
                                if (Utility.GUIButton(Target.Data.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.Data.Sequences.Length; i++)
                            {
                                float   start = rect.x + (float)(Target.Data.Sequences[i].Start - 1) / (float)(Target.Data.GetTotalFrames() - 1) * rect.width;
                                float   end   = rect.x + (float)(Target.Data.Sequences[i].End - 1) / (float)(Target.Data.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.Data.Styles.Length; i++)
                            {
                                int x = 0;
                                for (int j = 1; j < Target.Data.GetTotalFrames(); j++)
                                {
                                    float val = Target.Data.Frames[j].StyleValues[i];
                                    if (
                                        Target.Data.Frames[x].StyleValues[i] < 1f && val == 1f ||
                                        Target.Data.Frames[x].StyleValues[i] > 0f && val == 0f
                                        )
                                    {
                                        float xStart = rect.x + (float)(Mathf.Max(x - 1, 0)) / (float)(Target.Data.GetTotalFrames() - 1) * rect.width;
                                        float xEnd   = rect.x + (float)j / (float)(Target.Data.GetTotalFrames() - 1) * rect.width;
                                        float yStart = rect.y + (1f - Target.Data.Frames[Mathf.Max(x - 1, 0)].StyleValues[i]) * rect.height;
                                        float yEnd   = rect.y + (1f - Target.Data.Frames[j].StyleValues[i]) * rect.height;
                                        UltiDraw.DrawLine(new Vector3(xStart, yStart, 0f), new Vector3(xEnd, yEnd, 0f), colors[i]);
                                        x = j;
                                    }
                                    if (
                                        Target.Data.Frames[x].StyleValues[i] == 0f && val > 0f ||
                                        Target.Data.Frames[x].StyleValues[i] == 1f && val < 1f
                                        )
                                    {
                                        float xStart = rect.x + (float)(x) / (float)(Target.Data.GetTotalFrames() - 1) * rect.width;
                                        float xEnd   = rect.x + (float)(j - 1) / (float)(Target.Data.GetTotalFrames() - 1) * rect.width;
                                        float yStart = rect.y + (1f - Target.Data.Frames[x].StyleValues[i]) * rect.height;
                                        float yEnd   = rect.y + (1f - Target.Data.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.Data.GetTotalFrames() - 1)
                                    {
                                        float xStart = rect.x + (float)x / (float)(Target.Data.GetTotalFrames() - 1) * rect.width;
                                        float xEnd   = rect.x + (float)(j - 1) / (float)(Target.Data.GetTotalFrames() - 1) * rect.width;
                                        float yStart = rect.y + (1f - Target.Data.Frames[x].StyleValues[i]) * rect.height;
                                        float yEnd   = rect.y + (1f - Target.Data.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.Data.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.Data.GetTotalTime() : next.Timestamp);
                            }
                            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.InspectExport = EditorGUILayout.Toggle("Export", Target.InspectExport);
                        }

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

                                    EditorGUILayout.BeginHorizontal();
                                    GUILayout.FlexibleSpace();
                                    if (Utility.GUIButton("Auto", UltiDraw.DarkGrey, UltiDraw.White, 80f, 16f))
                                    {
                                        Target.Data.Sequences[i].AutoInterval();
                                    }
                                    EditorGUILayout.LabelField("Start", GUILayout.Width(50f));
                                    Target.Data.Sequences[i].SetStart(EditorGUILayout.IntField(Target.Data.Sequences[i].Start, GUILayout.Width(100f)));
                                    EditorGUILayout.LabelField("End", GUILayout.Width(50f));
                                    Target.Data.Sequences[i].SetEnd(EditorGUILayout.IntField(Target.Data.Sequences[i].End, GUILayout.Width(100f)));
                                    //EditorGUILayout.LabelField("Export", GUILayout.Width(50f));
                                    //Target.Data.Sequences[i].Export = EditorGUILayout.IntField(Target.Data.Sequences[i].Export, GUILayout.Width(100f));
                                    GUILayout.FlexibleSpace();
                                    EditorGUILayout.EndHorizontal();

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

                        if (Target.InspectSettings)
                        {
                            string[] presets = new string[4] {
                                "Select preset...", "Dan", "Dog", "Interaction"
                            };
                            switch (EditorGUILayout.Popup(0, presets))
                            {
                            case 0:
                                break;

                            case 1:
                                Target.Data.DepthMapAxis = MotionData.Axis.ZPositive;
                                Target.Data.SetUnitScale(10f);
                                Target.Data.MirrorAxis = MotionData.Axis.XPositive;
                                for (int i = 0; i < Target.Data.Corrections.Length; i++)
                                {
                                    Target.Data.SetCorrection(i, Vector3.zero);
                                }
                                Target.Data.ClearStyles();
                                Target.Data.AddStyle("Idle");
                                Target.Data.AddStyle("Walk");
                                Target.Data.AddStyle("Run");
                                Target.Data.AddStyle("Jump");
                                Target.Data.AddStyle("Crouch");
                                break;

                            case 2:
                                Target.Data.DepthMapAxis = MotionData.Axis.XPositive;
                                Target.Data.SetUnitScale(100f);
                                Target.Data.MirrorAxis = MotionData.Axis.ZPositive;
                                for (int i = 0; i < Target.Data.Corrections.Length; i++)
                                {
                                    if (i == 4 || i == 5 || i == 6 || i == 11)
                                    {
                                        Target.Data.SetCorrection(i, new Vector3(90f, 90f, 90f));
                                    }
                                    else if (i == 24)
                                    {
                                        Target.Data.SetCorrection(i, new Vector3(-45f, 0f, 0f));
                                    }
                                    else
                                    {
                                        Target.Data.SetCorrection(i, new Vector3(0f, 0f, 0f));
                                    }
                                }
                                Target.Data.ClearStyles();
                                Target.Data.AddStyle("Idle");
                                Target.Data.AddStyle("Walk");
                                Target.Data.AddStyle("Pace");
                                Target.Data.AddStyle("Trot");
                                Target.Data.AddStyle("Canter");
                                Target.Data.AddStyle("Jump");
                                Target.Data.AddStyle("Sit");
                                Target.Data.AddStyle("Stand");
                                Target.Data.AddStyle("Lie");
                                break;

                            case 3:
                                Target.Data.DepthMapAxis = MotionData.Axis.ZPositive;
                                Target.Data.SetUnitScale(100f);
                                Target.Data.MirrorAxis = MotionData.Axis.XPositive;
                                for (int i = 0; i < Target.Data.Corrections.Length; i++)
                                {
                                    Target.Data.SetCorrection(i, Vector3.zero);
                                }
                                Target.Data.ClearStyles();
                                Target.Data.AddStyle("Idle");
                                Target.Data.AddStyle("Walk");
                                Target.Data.AddStyle("Run");
                                Target.Data.AddStyle("Jump");
                                Target.Data.AddStyle("Crouch");
                                Target.Data.AddStyle("Sit");
                                break;
                            }

                            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.Data.SetUnitScale(EditorGUILayout.FloatField("Unit Scale", Target.Data.UnitScale));
                                Target.Data.MotionSmoothing = EditorGUILayout.IntField("Motion Smoothing", Target.Data.MotionSmoothing);

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

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

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

                            Utility.SetGUIColor(UltiDraw.LightGrey);
                            using (new EditorGUILayout.VerticalScope("Box")) {
                                Utility.ResetGUIColor();
                                EditorGUILayout.LabelField("Mirroring");
                                Target.Data.MirrorAxis = (MotionData.Axis)EditorGUILayout.EnumPopup("Axis", Target.Data.MirrorAxis);
                                string[] names = new string[Target.Data.Source.Bones.Length];
                                for (int i = 0; i < Target.Data.Source.Bones.Length; i++)
                                {
                                    names[i] = Target.Data.Source.Bones[i].Name;
                                }
                                for (int i = 0; i < Target.Data.Source.Bones.Length; i++)
                                {
                                    EditorGUILayout.BeginHorizontal();
                                    EditorGUI.BeginDisabledGroup(true);
                                    EditorGUILayout.TextField(names[i]);
                                    EditorGUI.EndDisabledGroup();
                                    Target.Data.SetSymmetry(i, EditorGUILayout.Popup(Target.Data.Symmetry[i], names));
                                    Target.Data.SetCorrection(i, EditorGUILayout.Vector3Field("", Target.Data.Corrections[i]));
                                    EditorGUILayout.EndHorizontal();
                                }
                            }
                        }
                    }

                    Utility.SetGUIColor(UltiDraw.Mustard);
                    using (new EditorGUILayout.VerticalScope("Box")) {
                        Utility.ResetGUIColor();
                        if (Utility.GUIButton("Unload", UltiDraw.DarkGrey, UltiDraw.White))
                        {
                            Target.UnloadFile();
                        }
                    }
                }
            }
        }
Beispiel #23
0
    public override void OnInspectorGUI()
    {
        // Update the serializedProperty - always do this in the beginning of OnInspectorGUI.
        serializedObject.Update();

        GUILayout.BeginHorizontal();

        GUILayout.Label("Action Type: ");
        ActionType action = (ActionType)EditorGUILayout.EnumPopup("", (ActionType)actionType.enumValueIndex);

        actionType.enumValueIndex = (int)action;

        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();

        GUILayout.Label("Target Layers: ");
        LayerMask tempMask = EditorGUILayout.MaskField(InternalEditorUtility.LayerMaskToConcatenatedLayersMask(interactableLayers.intValue), InternalEditorUtility.layers);

        interactableLayers.intValue = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask);

        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();

        GUILayout.Label("Within Range Colour: ");

        GUILayout.FlexibleSpace();

        WithinRangeHighlightColour.colorValue = EditorGUILayout.ColorField(WithinRangeHighlightColour.colorValue);

        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();

        GUILayout.Label("Valid Colour: ");

        GUILayout.FlexibleSpace();

        ValidHighlightColour.colorValue = EditorGUILayout.ColorField(ValidHighlightColour.colorValue);

        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();

        GUILayout.Label("Invalid Colour: ");

        GUILayout.FlexibleSpace();

        InvalidHighlightColour.colorValue = EditorGUILayout.ColorField(InvalidHighlightColour.colorValue);

        GUILayout.EndHorizontal();

        GUILayout.BeginHorizontal();

        GUILayout.Label("Distance Check: ");

        GUILayout.FlexibleSpace();

        useDistanceCheck.boolValue = EditorGUILayout.Toggle(useDistanceCheck.boolValue);

        GUILayout.EndHorizontal();

        if (useDistanceCheck.boolValue == true)
        {
            GUILayout.BeginHorizontal();

            GUILayout.Label("Distance Formulae: ");

            DistanceType distanceLength = (DistanceType)EditorGUILayout.EnumPopup("", (DistanceType)distanceCheckLength.enumValueIndex);
            distanceCheckLength.enumValueIndex = (int)distanceLength;

            GUILayout.EndHorizontal();

            GUILayout.BeginHorizontal();

            GUILayout.Label("Use Unit's : ");

            DistanceCheck distanceType = (DistanceCheck)EditorGUILayout.EnumPopup("", (DistanceCheck)distanceCheckType.enumValueIndex);
            distanceCheckType.enumValueIndex = (int)distanceType;

            GUILayout.EndHorizontal();

            if (distanceType == DistanceCheck.custom)
            {
                GUILayout.BeginHorizontal();

                GUILayout.Label("Maximum Distance: ");

                GUILayout.FlexibleSpace();

                maxDistance.intValue = EditorGUILayout.IntField(maxDistance.intValue);

                GUILayout.EndHorizontal();
            }
        }

        GUILayout.BeginHorizontal();

        GUILayout.Label("Team Check: ");

        GUILayout.FlexibleSpace();

        useTeamCheck.boolValue = EditorGUILayout.Toggle(useTeamCheck.boolValue);

        GUILayout.EndHorizontal();

        if (useTeamCheck.boolValue == true)
        {
            GUILayout.BeginHorizontal();

            GUILayout.Label("Target Team: ");

            GUILayout.FlexibleSpace();

            TargetTeam team = (TargetTeam)EditorGUILayout.EnumPopup((TargetTeam)targetTeam.enumValueIndex);
            targetTeam.enumValueIndex = (int)team;

            GUILayout.EndHorizontal();
        }

        if (tempMask.value == 32)
        {
            GUILayout.BeginHorizontal();

            GUILayout.Label("Tile Occupation Check: ");

            GUILayout.FlexibleSpace();

            useTileOccupation.boolValue = EditorGUILayout.Toggle(useTileOccupation.boolValue);

            GUILayout.EndHorizontal();

            if (useTileOccupation.boolValue == true)
            {
                GUILayout.BeginHorizontal();

                GUILayout.Label("Tile state: ");

                GUILayout.FlexibleSpace();

                TileOccupation occupation = (TileOccupation)EditorGUILayout.EnumPopup((TileOccupation)targetOccupation.enumValueIndex);
                targetOccupation.enumValueIndex = (int)occupation;

                GUILayout.EndHorizontal();
            }
        }

        serializedObject.ApplyModifiedProperties();
    }
Beispiel #24
0
        public void Inspector(MotionEditor editor)
        {
            UltiDraw.Begin();
            Utility.SetGUIColor(UltiDraw.Grey);
            using (new EditorGUILayout.VerticalScope("Box")) {
                Utility.ResetGUIColor();

                EditorGUILayout.BeginHorizontal();
                if (Utility.GUIButton("+", UltiDraw.DarkGrey, UltiDraw.White, 20f, 20f))
                {
                    AddBone(0);
                }
                EditorGUILayout.LabelField("Group", GUILayout.Width(40f));
                SetName(EditorGUILayout.TextField(ID, GUILayout.Width(100f)));
                EditorGUILayout.LabelField("Mask", GUILayout.Width(40));
                Mask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUILayout.MaskField(InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Mask), InternalEditorUtility.layers, GUILayout.Width(100f)));
                EditorGUILayout.LabelField("Offset", GUILayout.Width(40f));
                Offset = EditorGUILayout.Vector3Field("", Offset, GUILayout.Width(125f));
                EditorGUILayout.LabelField("Threshold", GUILayout.Width(60f));
                Threshold = EditorGUILayout.FloatField(Threshold, GUILayout.Width(30f));
                EditorGUILayout.LabelField("Velocity", GUILayout.Width(60f));
                Velocity = EditorGUILayout.FloatField(Velocity, GUILayout.Width(30f));
                EditorGUILayout.EndHorizontal();

                for (int i = 0; i < Bones.Length; i++)
                {
                    EditorGUILayout.BeginHorizontal();
                    if (Utility.GUIButton("-", UltiDraw.DarkGrey, UltiDraw.White, 20f, 20f))
                    {
                        RemoveBone(i);
                        i--;
                    }
                    else
                    {
                        SetBone(i, EditorGUILayout.Popup(Bones[i], editor.GetAsset().Source.GetBoneNames()));
                    }
                    EditorGUILayout.EndHorizontal();
                }

                Frame      frame = editor.GetCurrentFrame();
                MotionData data  = editor.GetAsset();

                EditorGUILayout.BeginVertical(GUILayout.Height(10f));
                Rect ctrl = EditorGUILayout.GetControlRect();
                Rect rect = new Rect(ctrl.x, ctrl.y, ctrl.width, 10f);
                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 > data.GetTotalTime())
                {
                    startTime -= endTime - data.GetTotalTime();
                    endTime    = data.GetTotalTime();
                }
                startTime = Mathf.Max(0f, startTime);
                endTime   = Mathf.Min(data.GetTotalTime(), endTime);
                int start    = data.GetFrame(startTime).Index;
                int end      = data.GetFrame(endTime).Index;
                int elements = end - start;

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

                start = Mathf.Clamp(start, 1, Module.Data.Frames.Length);
                end   = Mathf.Clamp(end, 1, Module.Data.Frames.Length);

                //Contacts
                for (int i = start; i <= end; i++)
                {
                    if (GetContact(data.GetFrame(i), editor.Mirror) == 1f)
                    {
                        float left  = rect.xMin + (float)(i - start) / (float)elements * rect.width;
                        float right = left;
                        while (i < end && GetContact(data.GetFrame(i), editor.Mirror) == 1f)
                        {
                            i++;
                            right = rect.xMin + (float)(i - start) / (float)elements * rect.width;
                        }
                        if (left != right)
                        {
                            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.Green);
                            UltiDraw.DrawTriangle(b, c, d, UltiDraw.Green);
                        }
                    }
                }

                //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);

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

                EditorGUILayout.EndVertical();
            }
            UltiDraw.End();
        }
Beispiel #25
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("Import", UltiDraw.DarkGrey, UltiDraw.White))
                        {
                            Target.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);

                        EditorGUILayout.BeginHorizontal();
                        string[] names = new string[Target.Files.Length];
                        if (names.Length == 0)
                        {
                            Target.LoadFile(EditorGUILayout.Popup("Data " + "(" + names.Length + ")", -1, names));
                        }
                        else
                        {
                            for (int i = 0; i < names.Length; i++)
                            {
                                names[i] = Target.Files[i].name;
                            }
                            Target.LoadFile(EditorGUILayout.Popup("Data " + "(" + names.Length + ")", Target.ID, names));
                        }
                        EditorGUILayout.EndHorizontal();
                        Target.LoadFile(EditorGUILayout.IntSlider(Target.ID, 0, 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("Frame", 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)
                            {
                                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();
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #26
0
        private void OnGUI()
        {
            scene = SceneManager.GetActiveScene().name;

            GUILayout.BeginHorizontal();
            GUILayout.Label("Fog of War Baking Tool", EditorStyles.largeLabel);
            GUILayout.EndHorizontal();

            GUILayout.Space(5);

            LayerMask tempVisionMask = EditorGUILayout.MaskField("Vision Blocking Layers: ", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(visionMask), InternalEditorUtility.layers);

            visionMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempVisionMask);

            GUILayout.Space(5);

            LayerMask tempCamoMask = EditorGUILayout.MaskField("Camouflage layers: ", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(camoMask), InternalEditorUtility.layers);

            camoMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempCamoMask);

            if (scene != lastScene)
            {
                lastScene = scene;
                terrain   = null;
            }

            FOWLevelBakingInfo levelInfo = AssetDatabase.LoadAssetAtPath <FOWLevelBakingInfo>(LevelBakingInfoPath + scene + ".Asset");

            GUILayout.Space(10);
            Rect rect = EditorGUILayout.GetControlRect(false, 2);

            EditorGUI.DrawRect(rect, new Color(0, 0, 0, 0.5f));
            GUILayout.Space(10);

            scrollPosition = GUILayout.BeginScrollView(scrollPosition);

            if (levelInfo != null)
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("Baking Info:", EditorStyles.boldLabel);
                if (GUILayout.Button("Delete", GUILayout.ExpandWidth(false)))
                {
                    AssetDatabase.DeleteAsset(LevelBakingInfoPath + scene + ".Asset");
                    return;
                }
                GUILayout.EndHorizontal();

                GUILayout.Space(5);
                levelInfo.unsafeMode = EditorGUILayout.Toggle("Unsafe mode:", levelInfo.unsafeMode);
                GUILayout.Space(5);

                if (levelInfo.unsafeMode)
                {
                    levelInfo.sceneName        = EditorGUILayout.TextField("Scene name:", levelInfo.sceneName);
                    levelInfo.mapSize          = EditorGUILayout.IntField("Map size:", levelInfo.mapSize);
                    levelInfo.eyeHeight        = EditorGUILayout.FloatField("Eye height:", levelInfo.eyeHeight);
                    levelInfo.maxVisionRange   = EditorGUILayout.FloatField("Max vision range:", levelInfo.maxVisionRange);
                    levelInfo.tileSize         = EditorGUILayout.IntField("Tile size:", levelInfo.tileSize);
                    levelInfo.maxTerrainHeight = EditorGUILayout.FloatField("Max terrain height:", levelInfo.maxTerrainHeight);
                    levelInfo.terrainOffset    = EditorGUILayout.Vector3Field("Terrain offset:", levelInfo.terrainOffset);
                }
                else
                {
                    int maxMapSize = 128 * levelInfo.tileSize;
                    int minMapSize = 2 * levelInfo.tileSize;

                    levelInfo.sceneName      = EditorGUILayout.TextField("Scene name:", levelInfo.sceneName);
                    levelInfo.mapSize        = EditorGUILayout.IntSlider("Map size:", levelInfo.mapSize, minMapSize, maxMapSize);
                    levelInfo.eyeHeight      = EditorGUILayout.Slider("Eye height:", levelInfo.eyeHeight, 0.05f, 10);
                    levelInfo.maxVisionRange = EditorGUILayout.Slider("Max vision range:", levelInfo.maxVisionRange, 1, 150);
                    levelInfo.tileSize       = EditorGUILayout.IntSlider("Tile size:", levelInfo.tileSize, 1, 4);

                    if (levelInfo.tileSize == 3)
                    {
                        levelInfo.tileSize = 4;
                    }

                    levelInfo.maxTerrainHeight = EditorGUILayout.Slider("Max terrain height:", levelInfo.maxTerrainHeight, 1, 200);
                    levelInfo.terrainOffset    = EditorGUILayout.Vector3Field("Terrain offset:", levelInfo.terrainOffset);
                }

                GUILayout.Space(20);

                GUILayout.Label("Baked Data:", EditorStyles.boldLabel);
                levelInfo.filePath = EditorGUILayout.TextField("File path:", levelInfo.filePath);

                bool tileMapMismatch = levelInfo.mapSize % levelInfo.tileSize != 0;

                if (!File.Exists(levelInfo.filePath))
                {
                    GUILayout.Space(10);
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("No file found in file path. Bake new?", EditorStyles.boldLabel);

                    EditorGUI.BeginDisabledGroup(tileMapMismatch);
                    if (GUILayout.Button("Bake", GUILayout.ExpandWidth(false)))
                    {
                        FOWBaker baker = new FOWBaker(levelInfo);
                        baker.BakeAndSaveData(visionMask, camoMask);
                        AssetDatabase.Refresh();
                    }
                    EditorGUI.EndDisabledGroup();
                    GUILayout.EndHorizontal();

                    if (tileMapMismatch)
                    {
                        GUILayout.Space(30);
                        GUILayout.Label("Map size must be dividable by tile size.", EditorStyles.miniBoldLabel);
                    }

                    GUILayout.Space(5);
                }
                else
                {
                    GUILayout.Space(5);

                    GUILayout.BeginHorizontal();
                    long fileSize = new FileInfo(levelInfo.filePath).Length / 1024 / 1024;
                    GUILayout.Label("Size: " + fileSize + " MB");

                    EditorGUI.BeginDisabledGroup(tileMapMismatch);
                    if (GUILayout.Button("Re-bake", GUILayout.ExpandWidth(false)))
                    {
                        FOWBaker baker = new FOWBaker(levelInfo);
                        baker.BakeAndSaveData(visionMask, camoMask);
                        AssetDatabase.Refresh();
                    }
                    EditorGUI.EndDisabledGroup();

                    if (GUILayout.Button("Delete", GUILayout.ExpandWidth(false)))
                    {
                        File.Delete(levelInfo.filePath);
                        AssetDatabase.Refresh();
                    }
                    GUILayout.EndHorizontal();

                    if (tileMapMismatch)
                    {
                        GUILayout.Space(30);
                        GUILayout.Label("Map size must be dividable by tile size.", EditorStyles.miniBoldLabel);
                    }

                    GUILayout.Space(5);
                }
            }
            else
            {
                GUILayout.BeginHorizontal();
                GUILayout.Label("No baking info for scene '" + scene + "'", EditorStyles.boldLabel);
                GUILayout.EndHorizontal();

                GUILayout.BeginHorizontal();
                terrain = EditorGUILayout.ObjectField("Terrain:", terrain, typeof(Terrain), true) as Terrain;

                EditorGUI.BeginDisabledGroup(terrain == null);
                if (GUILayout.Button("Add data", GUILayout.ExpandWidth(false)))
                {
                    levelInfo = CreateLevelBakingInfo(scene + ".Asset");
                }
                EditorGUI.EndDisabledGroup();
                GUILayout.EndHorizontal();
            }

            GUILayout.EndScrollView();

            if (GUI.changed)
            {
                EditorPrefs.SetInt("FOWLayerMask", visionMask);
                EditorPrefs.SetInt("CamoLayerMask", camoMask);
                if (levelInfo != null)
                {
                    EditorPrefs.SetFloat("LastEyeHeight", levelInfo.eyeHeight);
                    EditorPrefs.SetFloat("LastVisionRange", levelInfo.maxVisionRange);
                }
                EditorUtility.SetDirty(levelInfo);
            }
        }
Beispiel #27
0
 private void OnGUI()
 {
     GUILayout.BeginVertical(GUILayout.Width(300));
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     EditorGUILayout.Space();
     {
         GUILayout.BeginHorizontal();
         GUILayout.FlexibleSpace();
         GUILayout.Label("寻路");
         GUILayout.FlexibleSpace();
         GUILayout.EndHorizontal();
     }
     DrawUILine();
     {
         GUILayout.BeginHorizontal();
         GUILayout.FlexibleSpace();
         GUILayout.Label("不可行走:");
         LayerMask tempMask = EditorGUILayout.MaskField(InternalEditorUtility.LayerMaskToConcatenatedLayersMask(unwalkableMask), InternalEditorUtility.layers);
         unwalkableMask = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask);
         GUILayout.EndHorizontal();
     }
     {
         GUILayout.BeginHorizontal();
         GUILayout.FlexibleSpace();
         GUILayout.Label("区域大小:");
         gridWorldSize = EditorGUILayout.Vector2Field("", gridWorldSize);
         GUILayout.EndHorizontal();
     }
     {
         GUILayout.BeginHorizontal();
         GUILayout.FlexibleSpace();
         GUILayout.Label("方格半径:");
         nodeRadius = EditorGUILayout.FloatField(nodeRadius);
         GUILayout.EndHorizontal();
     }
     {
         GUILayout.BeginHorizontal();
         GUILayout.FlexibleSpace();
         if (GUILayout.Button("生成格子", GUILayout.Width(70)))
         {
             var obj = UnityEngine.Object.FindObjectOfType <Grid>();
             if (obj != null)
             {
                 obj.GetComponent <Grid>().RebuildGrid(unwalkableMask, gridWorldSize, nodeRadius);
             }
         }
         GUILayout.FlexibleSpace();
         GUILayout.EndHorizontal();
     }
     DrawUILine();
     {
         GUILayout.BeginHorizontal();
         GUILayout.FlexibleSpace();
         GUILayout.Label("体型大小:");
         unitSize = EditorGUILayout.IntField(unitSize);
         GUILayout.EndHorizontal();
     }
     {
         GUILayout.BeginHorizontal();
         GUILayout.FlexibleSpace();
         if (GUILayout.Button("寻路", GUILayout.Width(70)))
         {
             var obj = UnityEngine.Object.FindObjectOfType <PathFinder>();
             if (obj != null)
             {
                 obj.GetComponent <PathFinder>().FindPath(unitSize);
             }
         }
         GUILayout.FlexibleSpace();
         GUILayout.EndHorizontal();
     }
     DrawUILine();
     GUILayout.EndVertical();
 }
Beispiel #28
0
        private void DrawField(StateFieldInfo info)
        {
            foreach (object attribute in info.info.GetCustomAttributes(true))
            {
                if (attribute is HeaderAttribute header)
                {
                    EditorGUILayout.LabelField(header.header, EditorStyles.boldLabel);
                }
            }

            switch (info.fieldType)
            {
            case FieldType.INT:
                info.intValue = EditorGUILayout.DelayedIntField(info.name, info.intValue);
                break;

            case FieldType.FLOAT:
                info.floatValue = EditorGUILayout.DelayedFloatField(info.name, info.floatValue);
                break;

            case FieldType.STRING:
                info.stringValue = EditorGUILayout.DelayedTextField(info.name, info.stringValue);
                break;

            case FieldType.BOOLEAN:
                info.boolValue = EditorGUILayout.Toggle(info.name, info.boolValue);
                break;

            case FieldType.VECTOR3:
                info.vector3Value = EditorGUILayout.Vector3Field(info.name, info.vector3Value);
                break;

            case FieldType.VECTOR2:
                info.vector2Value = EditorGUILayout.Vector2Field(info.name, info.vector2Value);
                break;

            case FieldType.UNITY:
                info.unityObjectValue = EditorGUILayout.ObjectField(info.name, info.unityObjectValue, typeof(Object), false);
                break;

            case FieldType.LAYERMASK:
                LayerMask tempMask = EditorGUILayout.MaskField(
                    info.name,
                    InternalEditorUtility.LayerMaskToConcatenatedLayersMask(info.layerMaskValue),
                    InternalEditorUtility.layers);

                info.layerMaskValue = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(tempMask);
                break;

            case FieldType.OBJECT:

                break;

            case FieldType.INVALID:
                string invalidFormat = string.Format("Invalid field type of {0} with the name {1}", info.type, info.name);
                EditorGUILayout.HelpBox(invalidFormat, MessageType.Warning, true);
                break;

            default:
                break;
            }
        }
 protected override void DerivedInspector(MotionEditor editor)
 {
     Radius = EditorGUILayout.FloatField("Radius", Radius);
     Mask   = InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(EditorGUILayout.MaskField("Mask", InternalEditorUtility.LayerMaskToConcatenatedLayersMask(Mask), InternalEditorUtility.layers));
 }
        void OnGUI()
        {
            var dirtyCount = PhysicsVisualizationSettings.dirtyCount;

            EditorGUILayout.BeginHorizontal(EditorStyles.toolbar);

            GUILayout.FlexibleSpace();

            if (GUILayout.Button("Reset", EditorStyles.toolbarButton))
            {
                PhysicsVisualizationSettings.Reset();
            }

            EditorGUILayout.EndHorizontal();

            m_MainScrollPos = GUILayout.BeginScrollView(m_MainScrollPos);

            {
                EditorGUILayout.Space();
                m_ShowInfoFoldout.value = EditorGUILayout.Foldout(m_ShowInfoFoldout.value, Style.selectedObjectInfo);
                if (m_ShowInfoFoldout.value)
                {
                    EditorGUI.indentLevel++;
                    EditorGUILayout.Space();
                    EditorGUI.BeginDisabledGroup(true);
                    var transforms = Selection.transforms;
                    if (transforms.Length > 0)
                    {
                        foreach (var tr in transforms)
                        {
                            EditorGUILayout.TextField(Style.gameObject, tr.name);
                            EditorGUILayout.TextField(Style.scene, tr.gameObject.scene.name);
                        }
                    }
                    EditorGUI.EndDisabledGroup();
                    Repaint();
                    EditorGUI.indentLevel--;
                }
            }
            GUILayout.Space(4);

            int           sceneCount = SceneManager.sceneCount;
            List <string> options    = new List <string>();

            for (int i = 0; i < sceneCount; ++i)
            {
                var scene = SceneManager.GetSceneAt(i);
                options.Add(string.Format("{0} ", scene.name));
            }

            int newPhysicsSceneMask = EditorGUILayout.MaskField(Style.showPhysicsScenes, PhysicsVisualizationSettings.GetShowPhysicsSceneMask(), options.ToArray());

            PhysicsVisualizationSettings.SetShowPhysicsSceneMask(newPhysicsSceneMask);

            // Layers
            int oldConcatenatedMask = InternalEditorUtility.LayerMaskToConcatenatedLayersMask(
                PhysicsVisualizationSettings.GetShowCollisionLayerMask());

            int newConcatenatedMask = EditorGUILayout.MaskField(
                Style.showLayers, oldConcatenatedMask, InternalEditorUtility.layers);

            PhysicsVisualizationSettings.SetShowCollisionLayerMask(
                (int)InternalEditorUtility.ConcatenatedLayersMaskToLayerMask(newConcatenatedMask));

            // Static Colliders
            PhysicsVisualizationSettings.SetShowStaticColliders(EditorGUILayout.Toggle(
                                                                    Style.showStaticCollider, PhysicsVisualizationSettings.GetShowStaticColliders()));

            // Triggers
            PhysicsVisualizationSettings.SetShowTriggers(EditorGUILayout.Toggle(
                                                             Style.showTriggers, PhysicsVisualizationSettings.GetShowTriggers()));

            // Rigidbodies
            PhysicsVisualizationSettings.SetShowRigidbodies(EditorGUILayout.Toggle(
                                                                Style.showRigibodies, PhysicsVisualizationSettings.GetShowRigidbodies()));

            // Kinematic Bodies
            PhysicsVisualizationSettings.SetShowKinematicBodies(EditorGUILayout.Toggle(
                                                                    Style.showKinematicBodies, PhysicsVisualizationSettings.GetShowKinematicBodies()));

            // Sleeping Bodies
            PhysicsVisualizationSettings.SetShowSleepingBodies(EditorGUILayout.Toggle(
                                                                   Style.showSleepingBodies, PhysicsVisualizationSettings.GetShowSleepingBodies()));

            m_ShowColliderTypeFoldout.value = EditorGUILayout.Foldout(m_ShowColliderTypeFoldout.value, Style.colliderTypes);
            if (m_ShowColliderTypeFoldout.value)
            {
                EditorGUI.indentLevel++;
                float oldWidth = EditorGUIUtility.labelWidth;
                EditorGUIUtility.labelWidth = 200;

                // BoxCollider
                PhysicsVisualizationSettings.SetShowBoxColliders(EditorGUILayout.Toggle(
                                                                     Style.showBoxCollider, PhysicsVisualizationSettings.GetShowBoxColliders()));

                // SphereCollider
                PhysicsVisualizationSettings.SetShowSphereColliders(EditorGUILayout.Toggle(
                                                                        Style.showSphereCollider, PhysicsVisualizationSettings.GetShowSphereColliders()));

                // CapsuleCollider
                PhysicsVisualizationSettings.SetShowCapsuleColliders(EditorGUILayout.Toggle(
                                                                         Style.showCapsuleCollider, PhysicsVisualizationSettings.GetShowCapsuleColliders()));

                // MeshCollider convex
                PhysicsVisualizationSettings.SetShowMeshColliders(PhysicsVisualizationSettings.MeshColliderType.Convex, EditorGUILayout.Toggle(
                                                                      Style.showConvexMeshCollider, PhysicsVisualizationSettings.GetShowMeshColliders(PhysicsVisualizationSettings.MeshColliderType.Convex)));

                // MeshCollider non-convex
                PhysicsVisualizationSettings.SetShowMeshColliders(PhysicsVisualizationSettings.MeshColliderType.NonConvex, EditorGUILayout.Toggle(
                                                                      Style.showConcaveMeshCollider, PhysicsVisualizationSettings.GetShowMeshColliders(PhysicsVisualizationSettings.MeshColliderType.NonConvex)));

                // TerrainCollider
                PhysicsVisualizationSettings.SetShowTerrainColliders(EditorGUILayout.Toggle(
                                                                         Style.showTerrainCollider, PhysicsVisualizationSettings.GetShowTerrainColliders()));

                EditorGUIUtility.labelWidth = oldWidth;
                EditorGUI.indentLevel--;
            }

            GUILayout.Space(4);

            // Selection buttons
            GUILayout.BeginHorizontal();

            bool selectNone = GUILayout.Button(Style.showNone);
            bool selectAll  = GUILayout.Button(Style.showAll);

            if (selectNone || selectAll)
            {
                PhysicsVisualizationSettings.SetShowForAllFilters(selectAll);
            }

            GUILayout.EndHorizontal();

            m_ColorFoldout.value = EditorGUILayout.Foldout(m_ColorFoldout.value, Style.colors);
            if (m_ColorFoldout.value)
            {
                EditorGUI.indentLevel++;

                PhysicsVisualizationSettings.staticColor =
                    EditorGUILayout.ColorField(Style.staticColor, PhysicsVisualizationSettings.staticColor);

                PhysicsVisualizationSettings.triggerColor =
                    EditorGUILayout.ColorField(Style.triggerColor, PhysicsVisualizationSettings.triggerColor);

                PhysicsVisualizationSettings.rigidbodyColor =
                    EditorGUILayout.ColorField(Style.rigidbodyColor, PhysicsVisualizationSettings.rigidbodyColor);

                PhysicsVisualizationSettings.kinematicColor =
                    EditorGUILayout.ColorField(Style.kinematicColor, PhysicsVisualizationSettings.kinematicColor);

                PhysicsVisualizationSettings.sleepingBodyColor =
                    EditorGUILayout.ColorField(Style.sleepingBodyColor, PhysicsVisualizationSettings.sleepingBodyColor);

                PhysicsVisualizationSettings.colorVariance =
                    EditorGUILayout.Slider(Style.colorVariaition, PhysicsVisualizationSettings.colorVariance, 0f, 1f);

                EditorGUI.indentLevel--;
            }

            m_RenderingFoldout.value = EditorGUILayout.Foldout(m_RenderingFoldout.value, Style.rendering);
            if (m_RenderingFoldout.value)
            {
                EditorGUI.indentLevel++;

                PhysicsVisualizationSettings.baseAlpha = 1f - EditorGUILayout.Slider(Style.transparency
                                                                                     , 1f - PhysicsVisualizationSettings.baseAlpha, 0f, 1f);

                PhysicsVisualizationSettings.forceOverdraw = EditorGUILayout.Toggle(Style.forceOverdraw
                                                                                    , PhysicsVisualizationSettings.forceOverdraw);

                PhysicsVisualizationSettings.viewDistance = EditorGUILayout.FloatField(Style.viewDistance
                                                                                       , PhysicsVisualizationSettings.viewDistance);

                PhysicsVisualizationSettings.terrainTilesMax = EditorGUILayout.IntField(Style.terrainTilesMax
                                                                                        , PhysicsVisualizationSettings.terrainTilesMax);

                EditorGUI.indentLevel--;
            }

            if (Unsupported.IsDeveloperMode() || PhysicsVisualizationSettings.devOptions)
            {
                PhysicsVisualizationSettings.devOptions = EditorGUILayout.Toggle(Style.devOptions
                                                                                 , PhysicsVisualizationSettings.devOptions);
            }

            if (PhysicsVisualizationSettings.devOptions)
            {
                PhysicsVisualizationSettings.dotAlpha = EditorGUILayout.Slider(Style.dotAlpha
                                                                               , PhysicsVisualizationSettings.dotAlpha, -1f, 1f);

                PhysicsVisualizationSettings.forceDot = EditorGUILayout.Toggle(Style.forceDot
                                                                               , PhysicsVisualizationSettings.forceDot);

                Tools.hidden = EditorGUILayout.Toggle(Style.toolsHidden
                                                      , Tools.hidden);
            }

            GUILayout.EndScrollView();

            if (dirtyCount != PhysicsVisualizationSettings.dirtyCount)
            {
                RepaintSceneAndGameViews();
            }
        }