Exemple #1
0
        private static void CreateSuperPlane()
        {
            GameObject obj = new GameObject("SuperPlane");

            obj.AddComponent <BoxCollider>();
            obj.AddComponent <SuperPlane>().Build(true);
            obj.GetComponent <Renderer>().sharedMaterial = EditorTools.GetDefaultMaterial();

            Vector3 snap = new Vector3(EditorPrefs.GetFloat("MoveSnapX"), EditorPrefs.GetFloat("MoveSnapY"), EditorPrefs.GetFloat("MoveSnapZ"));

            obj.transform.position = SuperCubeEditorUtil.SnapVector(SuperCubeEditorUtil.GetSpawnPos(), snap);

            Selection.activeGameObject = obj;
            EditorGUIUtility.PingObject(obj);
        }
Exemple #2
0
        private static void CreateSuperCube()
        {
            GameObject obj = new GameObject("SuperCube");

            obj.AddComponent <BoxCollider>();
            obj.AddComponent <SuperCube>().Build(true);
            obj.GetComponent <Renderer>().sharedMaterial = EditorTools.GetDefaultMaterial();

            Vector3 snap = EditorTools.GetUnitySnap();

            obj.transform.position = SuperCubeEditorUtil.SnapVector(SuperCubeEditorUtil.GetSpawnPos() + new Vector3(0, 0.5f, 0), snap);

            Selection.activeGameObject = obj;
            EditorGUIUtility.PingObject(obj);
        }
Exemple #3
0
        internal static void Handle(PivotType aSides, Transform aTransform, bool aLockX, bool aLockY, bool aLockZ, Vector3 aSnap, ref Vector3 lbf, ref Vector3 rtb, Handles.DrawCapFunction aCap)
        {
            Vector3 pt   = new Vector3(0, 0, 0);
            Vector3 mask = new Vector3(aLockX?1:0, aLockY?1:0, aLockZ?1:0);

            if ((aSides & PivotType.Left) > 0)
            {
                pt.x = lbf.x;
            }
            if ((aSides & PivotType.Right) > 0)
            {
                pt.x = rtb.x;
            }
            if ((aSides & PivotType.Top) > 0)
            {
                pt.y = rtb.y;
            }
            if ((aSides & PivotType.Bottom) > 0)
            {
                pt.y = lbf.y;
            }
            if ((aSides & PivotType.Front) > 0)
            {
                pt.z = lbf.z;
            }
            if ((aSides & PivotType.Back) > 0)
            {
                pt.z = rtb.z;
            }
            pt = aTransform.TransformPoint(pt);

            Vector3 result = Handles.FreeMoveHandle(pt, Quaternion.identity, HandleUtility.GetHandleSize(pt) * mHandleSize, Vector3.zero, aCap);

            if (result != pt)
            {
                Vector3 dir = SuperCubeEditorUtil.CreateBillboardNormal(pt, aLockX, aLockY, aLockZ);
                result = SuperCubeEditorUtil.SnapVector(Vector3.Scale(SuperCubeEditorUtil.GetPlanePoint(result, new Plane(dir, pt)), mask), aSnap);
                result = aTransform.InverseTransformPoint(result);

                if ((aSides & PivotType.Left) > 0)
                {
                    lbf.x = result.x;
                }
                if ((aSides & PivotType.Right) > 0)
                {
                    rtb.x = result.x;
                }
                if ((aSides & PivotType.Top) > 0)
                {
                    rtb.y = result.y;
                }
                if ((aSides & PivotType.Bottom) > 0)
                {
                    lbf.y = result.y;
                }
                if ((aSides & PivotType.Front) > 0)
                {
                    lbf.z = result.z;
                }
                if ((aSides & PivotType.Back) > 0)
                {
                    rtb.z = result.z;
                }
            }
        }