コード例 #1
0
ファイル: SortingArea.cs プロジェクト: IJkeB/Ekster_Final
 public SortingArea(SortingArea lastArea)
 {
     z     = lastArea.z + 1f;
     order = lastArea.order + 1;
     layer = "";
     scale = lastArea.scale;
     color = GetRandomColor();
 }
コード例 #2
0
ファイル: SortingArea.cs プロジェクト: mcbodge/eidolon
 /**
  * A Constructor that creates a new SortingArea based on the last one currently on the SortingMap.
  */
 public SortingArea(SortingArea lastArea)
 {
     z = lastArea.z + 1f;
     order = lastArea.order + 1;
     layer = "";
     scale = lastArea.scale;
     color = GetRandomColor ();
 }
コード例 #3
0
ファイル: SortingArea.cs プロジェクト: mcbodge/eidolon
        /**
         * A Constructor that creates a new SortingArea by interpolating between two others.
         */
        public SortingArea(SortingArea area1, SortingArea area2)
        {
            z = (area1.z + area2.z) / 2f;

            float _avOrder = (float) area1.order + (float) area2.order;
            order = (int) (_avOrder / 2f);

            float _avScale = (float) area1.scale + (float) 	area2.scale;
            scale = (int) (_avScale / 2f);

            layer = "";
            color = GetRandomColor ();
        }
コード例 #4
0
ファイル: SortingArea.cs プロジェクト: IJkeB/Ekster_Final
        public SortingArea(SortingArea area1, SortingArea area2)
        {
            z = (area1.z + area2.z) / 2f;

            float _avOrder = (float)area1.order + (float)area2.order;

            order = (int)(_avOrder / 2f);

            float _avScale = (float)area1.scale + (float)area2.scale;

            scale = (int)(_avScale / 2f);

            layer = "";
            color = GetRandomColor();
        }
コード例 #5
0
        public override void OnInspectorGUI()
        {
            SortingMap _target = (SortingMap)target;

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Properties", EditorStyles.boldLabel);

            _target.mapType     = (SortingMapType)CustomGUILayout.EnumPopup("Affect sprite's:", _target.mapType);
            _target.affectScale = CustomGUILayout.Toggle("Affect Character scale?", _target.affectScale, "", "If True, characters that follow this map should have their scale affected");
            if (_target.affectScale)
            {
                _target.affectSpeed = CustomGUILayout.Toggle("Affect Character speed?", _target.affectSpeed, "", "If True, characters that follow this map should have their movement speed affected by the scale factor");

                _target.sortingMapScaleType = (SortingMapScaleType)CustomGUILayout.EnumPopup("Character scaling mode:", _target.sortingMapScaleType, "", "How scaling values are defined");
                if (_target.sortingMapScaleType == SortingMapScaleType.Linear || _target.sortingAreas.Count == 0)
                {
                    _target.originScale = CustomGUILayout.IntField("Start scale (%):", _target.originScale, "", "The scale (as a percentage) that characters will have at the very top of the map");

                    if (_target.sortingMapScaleType == SortingMapScaleType.AnimationCurve)
                    {
                        EditorGUILayout.HelpBox("The Sorting Map must have at least one area defined to make use of an animation curve.", MessageType.Warning);
                    }
                }
                else
                {
                    if (_target.scalingAnimationCurve == null)
                    {
                        _target.scalingAnimationCurve = AnimationCurve.Linear(0f, 0.1f, 1f, 1f);
                    }
                    _target.scalingAnimationCurve = CustomGUILayout.CurveField("Scaling curve:", _target.scalingAnimationCurve, "", "The AnimationCurve used to define character scaling, where 0s is the smallest scale, and 1s is the largest");
                    EditorGUILayout.HelpBox("The curve's values will be read from 0s to 1s only.", MessageType.Info);
                }

                if (_target.sortingMapScaleType == SortingMapScaleType.Linear && _target.sortingAreas.Count > 1)
                {
                    if (GUILayout.Button("Interpolate in-between scales"))
                    {
                        Undo.RecordObject(_target, "Interpolate scales");
                        _target.SetInBetweenScales();
                        EditorUtility.SetDirty(_target);
                    }
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Sorting areas", EditorStyles.boldLabel);
            foreach (SortingArea area in _target.sortingAreas)
            {
                int i = _target.sortingAreas.IndexOf(area);

                EditorGUILayout.BeginVertical();
                EditorGUILayout.BeginHorizontal();

                area.color = EditorGUILayout.ColorField(area.color);

                EditorGUILayout.LabelField("Position:", GUILayout.Width(50f));
                area.z = EditorGUILayout.FloatField(area.z, GUILayout.Width(80f));

                if (_target.mapType == SortingMapType.OrderInLayer)
                {
                    EditorGUILayout.LabelField("Order:", labelWidth);
                    area.order = EditorGUILayout.IntField(area.order);
                }
                else if (_target.mapType == SortingMapType.SortingLayer)
                {
                    EditorGUILayout.LabelField("Layer:", labelWidth);
                    area.layer = EditorGUILayout.TextField(area.layer);
                }

                if (GUILayout.Button(insertContent, EditorStyles.miniButtonLeft, buttonWidth))
                {
                    Undo.RecordObject(_target, "Add area");
                    if (i < _target.sortingAreas.Count - 1)
                    {
                        _target.sortingAreas.Insert(i + 1, new SortingArea(area, _target.sortingAreas[i + 1]));
                    }
                    else
                    {
                        _target.sortingAreas.Insert(i + 1, new SortingArea(area));
                    }
                    break;
                }
                if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                {
                    Undo.RecordObject(_target, "Delete area");
                    _target.sortingAreas.Remove(area);
                    break;
                }

                EditorGUILayout.EndHorizontal();

                if (_target.affectScale && _target.sortingMapScaleType == SortingMapScaleType.Linear)
                {
                    area.scale = CustomGUILayout.IntField("End scale (%):", area.scale, "", "The factor by which characters that use FollowSortingMap will be scaled by when positioned at the bottom boundary of this region");
                }

                EditorGUILayout.EndVertical();
                GUILayout.Box(string.Empty, GUILayout.ExpandWidth(true), GUILayout.Height(1));
            }

            if (GUILayout.Button("Add area"))
            {
                Undo.RecordObject(_target, "Add area");

                if (_target.sortingAreas.Count > 0)
                {
                    SortingArea lastArea = _target.sortingAreas [_target.sortingAreas.Count - 1];
                    _target.sortingAreas.Add(new SortingArea(lastArea));
                }
                else
                {
                    _target.sortingAreas.Add(new SortingArea(_target.transform.position.z + 1f, 1));
                }
            }

            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            if (SceneSettings.IsTopDown())
            {
            }
            else if (SceneSettings.IsUnity2D())
            {
            }
            else
            {
                if (GUILayout.Button("Face active camera"))
                {
                    Undo.RecordObject(_target, "Face active camera");
                    Vector3 forwardVector = Camera.main.transform.forward;
                    _target.transform.forward = -forwardVector;
                    EditorUtility.SetDirty(_target);
                }
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }
コード例 #6
0
        public override void OnInspectorGUI()
        {
            SortingMap _target = (SortingMap)target;

            EditorGUILayout.BeginVertical("Button");
            _target.mapType     = (SortingMapType)EditorGUILayout.EnumPopup("Affect sprite's:", _target.mapType);
            _target.affectScale = EditorGUILayout.Toggle("Affect Character scale?", _target.affectScale);
            if (_target.affectScale)
            {
                _target.affectSpeed = EditorGUILayout.Toggle("Affect Character speed?", _target.affectSpeed);
                _target.originScale = EditorGUILayout.IntField("Start scale (%):", _target.originScale);
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            foreach (SortingArea area in _target.sortingAreas)
            {
                int i = _target.sortingAreas.IndexOf(area);

                EditorGUILayout.BeginVertical("Button");
                EditorGUILayout.BeginHorizontal();

                area.color = EditorGUILayout.ColorField(area.color);

                EditorGUILayout.LabelField("Position:", GUILayout.Width(50f));
                area.z = EditorGUILayout.FloatField(area.z, GUILayout.Width(80f));

                if (_target.mapType == SortingMapType.OrderInLayer)
                {
                    EditorGUILayout.LabelField("Order:", labelWidth);
                    area.order = EditorGUILayout.IntField(area.order);
                }
                else if (_target.mapType == SortingMapType.SortingLayer)
                {
                    EditorGUILayout.LabelField("Layer:", labelWidth);
                    area.layer = EditorGUILayout.TextField(area.layer);
                }

                if (GUILayout.Button(insertContent, EditorStyles.miniButtonLeft, buttonWidth))
                {
                    Undo.RecordObject(_target, "Add area");
                    if (i < _target.sortingAreas.Count - 1)
                    {
                        _target.sortingAreas.Insert(i + 1, new SortingArea(area, _target.sortingAreas[i + 1]));
                    }
                    else
                    {
                        _target.sortingAreas.Insert(i + 1, new SortingArea(area));
                    }
                    break;
                }
                if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                {
                    Undo.RecordObject(_target, "Delete area");
                    _target.sortingAreas.Remove(area);
                    break;
                }

                EditorGUILayout.EndHorizontal();

                if (_target.affectScale)
                {
                    area.scale = EditorGUILayout.IntField("End scale (%):", area.scale);
                }

                EditorGUILayout.EndVertical();
            }

            if (GUILayout.Button("Add area"))
            {
                Undo.RecordObject(_target, "Add area");

                if (_target.sortingAreas.Count > 0)
                {
                    SortingArea lastArea = _target.sortingAreas [_target.sortingAreas.Count - 1];
                    _target.sortingAreas.Add(new SortingArea(lastArea));
                }
                else
                {
                    _target.sortingAreas.Add(new SortingArea(_target.transform.position.z + 1f, 1));
                }
            }

            EditorGUILayout.Space();

            if (AdvGame.GetReferences() && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.IsTopDown())
            {
            }
            else if (AdvGame.GetReferences() && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.IsUnity2D())
            {
            }
            else
            {
                if (GUILayout.Button("Face active camera"))
                {
                    Undo.RecordObject(_target, "Face active camera");
                    Vector3 forwardVector = Camera.main.transform.forward;
                    _target.transform.forward = -forwardVector;
                    EditorUtility.SetDirty(_target);
                }
            }

            if (_target.affectScale && _target.sortingAreas.Count > 1)
            {
                if (GUILayout.Button("Interpolate in-between scales"))
                {
                    Undo.RecordObject(_target, "Interpolate scales");
                    _target.SetInBetweenScales();
                    EditorUtility.SetDirty(_target);
                }
            }

            if (GUI.changed)
            {
                EditorUtility.SetDirty(_target);
            }
        }
コード例 #7
0
        public override void OnInspectorGUI()
        {
            SortingMap _target = (SortingMap)target;

            EditorGUILayout.BeginVertical("Button");
            _target.mapType     = (SortingMapType)EditorGUILayout.EnumPopup("Affect sprite's:", _target.mapType);
            _target.affectScale = EditorGUILayout.Toggle("Affect Character scale?", _target.affectScale);
            if (_target.affectScale)
            {
                _target.affectSpeed = EditorGUILayout.Toggle("Affect Character speed?", _target.affectSpeed);

                _target.sortingMapScaleType = (SortingMapScaleType)EditorGUILayout.EnumPopup("Character scaling mode:", _target.sortingMapScaleType);
                if (_target.sortingMapScaleType == SortingMapScaleType.Linear || _target.sortingAreas.Count == 0)
                {
                    _target.originScale = EditorGUILayout.IntField("Start scale (%):", _target.originScale);

                    if (_target.sortingMapScaleType == SortingMapScaleType.AnimationCurve)
                    {
                        EditorGUILayout.HelpBox("The Sorting Map must have at least one area defined to make use of an animation curve.", MessageType.Warning);
                    }
                }
                else
                {
                    if (_target.scalingAnimationCurve == null)
                    {
                        _target.scalingAnimationCurve = AnimationCurve.Linear(0f, 0.1f, 1f, 1f);
                    }
                    _target.scalingAnimationCurve = EditorGUILayout.CurveField("Scaling curve:", _target.scalingAnimationCurve);
                    EditorGUILayout.HelpBox("The curve's values will be read from 0s to 1s only.", MessageType.Info);
                }
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.Space();

            foreach (SortingArea area in _target.sortingAreas)
            {
                int i = _target.sortingAreas.IndexOf(area);

                EditorGUILayout.BeginVertical("Button");
                EditorGUILayout.BeginHorizontal();

                area.color = EditorGUILayout.ColorField(area.color);

                EditorGUILayout.LabelField("Position:", GUILayout.Width(50f));
                area.z = EditorGUILayout.FloatField(area.z, GUILayout.Width(80f));

                if (_target.mapType == SortingMapType.OrderInLayer)
                {
                    EditorGUILayout.LabelField("Order:", labelWidth);
                    area.order = EditorGUILayout.IntField(area.order);
                }
                else if (_target.mapType == SortingMapType.SortingLayer)
                {
                    EditorGUILayout.LabelField("Layer:", labelWidth);
                    area.layer = EditorGUILayout.TextField(area.layer);
                }

                if (GUILayout.Button(insertContent, EditorStyles.miniButtonLeft, buttonWidth))
                {
                    Undo.RecordObject(_target, "Add area");
                    if (i < _target.sortingAreas.Count - 1)
                    {
                        _target.sortingAreas.Insert(i + 1, new SortingArea(area, _target.sortingAreas[i + 1]));
                    }
                    else
                    {
                        _target.sortingAreas.Insert(i + 1, new SortingArea(area));
                    }
                    break;
                }
                if (GUILayout.Button(deleteContent, EditorStyles.miniButtonRight, buttonWidth))
                {
                    Undo.RecordObject(_target, "Delete area");
                    _target.sortingAreas.Remove(area);
                    break;
                }

                EditorGUILayout.EndHorizontal();

                if (_target.affectScale && _target.sortingMapScaleType == SortingMapScaleType.Linear)
                {
                    area.scale = EditorGUILayout.IntField("End scale (%):", area.scale);
                }

                EditorGUILayout.EndVertical();
            }

            if (GUILayout.Button("Add area"))
            {
                Undo.RecordObject(_target, "Add area");

                if (_target.sortingAreas.Count > 0)
                {
                    SortingArea lastArea = _target.sortingAreas [_target.sortingAreas.Count - 1];
                    _target.sortingAreas.Add(new SortingArea(lastArea));
                }
                else
                {
                    _target.sortingAreas.Add(new SortingArea(_target.transform.position.z + 1f, 1));
                }
            }

            EditorGUILayout.Space();

            if (AdvGame.GetReferences() && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.IsTopDown())
            {
            }
            else if (AdvGame.GetReferences() && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.IsUnity2D())
            {
            }
            else
            {
                if (GUILayout.Button("Face active camera"))
                {
                    Undo.RecordObject(_target, "Face active camera");
                    Vector3 forwardVector = Camera.main.transform.forward;
                    _target.transform.forward = -forwardVector;
                    EditorUtility.SetDirty(_target);
                }
            }

            if (_target.affectScale && _target.sortingAreas.Count > 1 && _target.sortingMapScaleType == SortingMapScaleType.Linear)
            {
                if (GUILayout.Button("Interpolate in-between scales"))
                {
                    Undo.RecordObject(_target, "Interpolate scales");
                    _target.SetInBetweenScales();
                    EditorUtility.SetDirty(_target);
                }
            }

            UnityVersionHandler.CustomSetDirty(_target);
        }