コード例 #1
0
 private void OnEnable()
 {
     instance = (GSplineCreator)target;
     InitModifierClasses();
     instance.Editor_Vertices = instance.GenerateVerticesWithFalloff();
     Tools.hidden             = true;
 }
コード例 #2
0
 public static void MarkSplineChanged(GSplineCreator sender)
 {
     if (Editor_SplineChanged != null)
     {
         Editor_SplineChanged.Invoke(sender);
     }
 }
コード例 #3
0
        public override void OnInspectorGUI()
        {
            EditorGUI.BeginChangeCheck();
            GUI.enabled      = !GEditorSettings.Instance.splineTools.showTransformGizmos;
            instance.GroupId = GEditorCommon.ActiveTerrainGroupPopupWithAllOption("Group Id", instance.GroupId);

            GEditorSettings.Instance.splineTools.raycastLayer = EditorGUILayout.LayerField("Raycast Layer", GEditorSettings.Instance.splineTools.raycastLayer);
            GEditorSettings.Instance.splineTools.autoTangent  = EditorGUILayout.Toggle("Auto Tangent", GEditorSettings.Instance.splineTools.autoTangent);

            instance.EnableTerrainMask = EditorGUILayout.Toggle("Enable Terrain Mask", instance.EnableTerrainMask);
            GEditorSettings.Instance.topographic.enable = EditorGUILayout.Toggle("Enable Topographic", GEditorSettings.Instance.topographic.enable);

            DrawInstructionGUI();
            GUI.enabled = true;
            DrawTransformGUI();
            GUI.enabled = !GEditorSettings.Instance.splineTools.showTransformGizmos;
            DrawAnchorDefaultValueGUI();
            DrawSelectedAnchorGUI();
            DrawSegmentDefaultValueGUI();
            DrawSelectedSegmentGUI();
            DrawGizmosGUI();
            DrawActionsGUI();
            GEditorCommon.DrawBackupHelpBox();
            GUI.enabled = false;
            //DrawDebugGUI();
            if (EditorGUI.EndChangeCheck())
            {
                instance.Editor_Vertices = instance.GenerateVerticesWithFalloff();
                GSplineCreator.MarkSplineChanged(instance);
                GUtilities.MarkCurrentSceneDirty();
            }
        }
コード例 #4
0
 private void DuringSceneGUI(SceneView sv)
 {
     EditorGUI.BeginChangeCheck();
     splineEditingDrawer.Draw();
     if (EditorGUI.EndChangeCheck())
     {
         instance.Editor_Vertices = instance.GenerateVerticesWithFalloff();
         GSplineCreator.MarkSplineChanged(instance);
         GUtilities.MarkCurrentSceneDirty();
     }
 }
コード例 #5
0
        private void OnEnable()
        {
            instance = (GSplineCreator)target;
            InitModifierClasses();
            instance.Editor_Vertices = instance.GenerateVerticesWithFalloff();
            Tools.hidden             = true;
            splineEditingDrawer      = new GSplineEditingGUIDrawer(instance);

            GCommon.RegisterBeginRender(OnBeginRender);
            GCommon.RegisterBeginRenderSRP(OnBeginRenderSRP);
            SceneView.duringSceneGui += DuringSceneGUI;
        }
コード例 #6
0
        public static List <GStylizedTerrain> OverlapTest(int groupId, GSplineCreator spline)
        {
            List <GStylizedTerrain> terrains = new List <GStylizedTerrain>();

            GCommon.ForEachTerrain(groupId, (t) =>
            {
                if (spline.OverlapTest(t))
                {
                    terrains.Add(t);
                }
            });

            return(terrains);
        }
コード例 #7
0
        private void SetPivotToMedianPoint()
        {
            Vector3 localMedian          = Vector3.zero;
            List <GSplineAnchor> anchors = instance.Spline.Anchors;

            if (anchors.Count == 0)
            {
                return;
            }

            for (int i = 0; i < anchors.Count; ++i)
            {
                localMedian += anchors[i].Position;
            }
            localMedian = localMedian / anchors.Count;

            Vector3   worldMedian   = instance.transform.TransformPoint(localMedian);
            Matrix4x4 medianToLocal = Matrix4x4.TRS(
                worldMedian,
                instance.transform.rotation,
                instance.transform.lossyScale).inverse;
            Matrix4x4 localToWorld         = instance.transform.localToWorldMatrix;
            Matrix4x4 transformationMatrix = medianToLocal * localToWorld;

            for (int i = 0; i < anchors.Count; ++i)
            {
                anchors[i].Position = transformationMatrix.MultiplyPoint(anchors[i].Position);
            }

            List <GSplineSegment> segments = instance.Spline.Segments;

            for (int i = 0; i < segments.Count; ++i)
            {
                segments[i].StartTangent = transformationMatrix.MultiplyPoint(segments[i].StartTangent);
                segments[i].EndTangent   = transformationMatrix.MultiplyPoint(segments[i].EndTangent);
            }

            instance.transform.position = worldMedian;
            instance.Editor_Vertices    = instance.GenerateVerticesWithFalloff();
            GSplineCreator.MarkSplineChanged(instance);
        }
コード例 #8
0
 public GSplineEditingGUIDrawer(GSplineCreator splineCreator)
 {
     this.splineCreator = splineCreator;
 }