当前位置: 首页>>代码示例>>C#>>正文


C# Bounds.SetMinMax方法代码示例

本文整理汇总了C#中UnityEngine.Bounds.SetMinMax方法的典型用法代码示例。如果您正苦于以下问题:C# Bounds.SetMinMax方法的具体用法?C# Bounds.SetMinMax怎么用?C# Bounds.SetMinMax使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UnityEngine.Bounds的用法示例。


在下文中一共展示了Bounds.SetMinMax方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetBounds

    public static Bounds GetBounds(Renderer r)
    {
        if (r is SkinnedMeshRenderer) {
            SkinnedMeshRenderer smr = r as SkinnedMeshRenderer;
            Mesh mesh = smr.sharedMesh;

            Vector3[] vertices = mesh.vertices;
            if (vertices.Length <= 0) {
                return r.bounds;
            }
            int idx = 0;
            Vector3 min, max;
            min = max = r.transform.TransformPoint (vertices [idx++]);

            for (int i = idx; i < vertices.Length; i++) {
                Vector3 v = vertices [i];
                Vector3 V = r.transform.TransformPoint (v);
                for (int n = 0; n < 3; n++) {
                    if (V [n] > max [n])
                        max [n] = V [n];
                    if (V [n] < min [n])
                        min [n] = V [n];
                }
            }

            Bounds b = new Bounds ();;
            b.SetMinMax (min, max);
            return b;

        } else {
            return r.bounds;
        }
    }
开发者ID:shinobushiva,项目名称:Unity-Utils,代码行数:33,代码来源:Helper.cs

示例2: GetBounds

        // Compute bounding box
        //
        public Bounds GetBounds()
        {
            float xmin = Mathf.Infinity;
            float ymin = Mathf.Infinity;
            float xmax = -Mathf.Infinity;
            float ymax = -Mathf.Infinity;
            Point v;
            float vx, vy;

            for (int i = this.halfEdges.Count - 1; i >= 0; i--)
            {
                v = this.halfEdges[i].GetStartPoint();
                vx = v.x;
                vy = v.y;
                if (vx < xmin) { xmin = vx; }
                if (vy < ymin) { ymin = vy; }
                if (vx > xmax) { xmax = vx; }
                if (vy > ymax) { ymax = vy; }
                // we dont need to take into account end point,
                // since each end point matches a start point
            }

            // TODO: verify y
            Bounds bounds = new Bounds();
            bounds.SetMinMax(new Vector3(xmin, 0, xmax), new Vector3(ymin, 0, ymax));

            return bounds;
        }
开发者ID:jesta88,项目名称:Unity-Voronoi,代码行数:30,代码来源:Cell.cs

示例3: Render

        public void Render(Vector3 position, float pointGranularity, Color drawColor)
        {
            Bounds b = new Bounds();
            b.SetMinMax(
                position + new Vector3(0f, 5f, 0f),
                position + new Vector3(_sizeX * pointGranularity, 5f, _sizeZ * pointGranularity));

            Gizmos.color = drawColor;
            Gizmos.DrawCube(b.center, b.size);
        }
开发者ID:forwolk,项目名称:UnityApex,代码行数:10,代码来源:HeightDictionary.cs

示例4: GetViewportBounds

        protected Bounds GetViewportBounds(Vector3 screenPosition1, Vector3 screenPosition2) {
            var v1 = Camera.main.ScreenToViewportPoint(screenPosition1);
            var v2 = Camera.main.ScreenToViewportPoint(screenPosition2);
            var min = Vector3.Min(v1, v2);
            var max = Vector3.Max(v1, v2);
            min.z = Camera.main.nearClipPlane;
            max.z = Camera.main.farClipPlane;

            var bounds = new Bounds();
            bounds.SetMinMax(min, max);
            return bounds;
        }
开发者ID:Niller,项目名称:LastStand,代码行数:12,代码来源:TrySelectUnitGroupCommand.cs

示例5: GetViewportBounds

    //This returns the boudns to detect units inside the rect.
    public static Bounds GetViewportBounds( Camera camera, Vector3 screenPosition1, Vector3 screenPosition2 )
    {
        var v1 = camera.ScreenToViewportPoint( screenPosition1 );
        var v2 = camera.ScreenToViewportPoint( screenPosition2 );
        var min = Vector3.Min( v1, v2 );
        var max = Vector3.Max( v1, v2 );
        min.z = camera.nearClipPlane;
        max.z = camera.farClipPlane;

        var bounds = new Bounds();
        bounds.SetMinMax( min, max );
        return bounds;
    }
开发者ID:jgirald,项目名称:ES2015F,代码行数:14,代码来源:RectDrawer.cs

示例6: Intersect

    public static Bounds Intersect(this Bounds a, Bounds b)
    {
        float x1 = Mathf.Max(a.min.x, b.min.x);
        float x2 = Mathf.Min(a.max.x, b.max.x);
        float y1 = Mathf.Max(a.min.y, b.min.y);
        float y2 = Mathf.Min(a.max.y, b.max.y);

        var bounds = new Bounds();
        if (x2 >= x1 && y2 >= y1)
        {
            bounds.SetMinMax(new Vector3(x1, y1, 0), new Vector3(x2, y2, 0));
        }
        return bounds;
    }
开发者ID:Crashkila101,项目名称:ScratchyUnitySpaceInvaders,代码行数:14,代码来源:ScratchyExtensions.cs

示例7: GetViewportBounds

        public static Bounds GetViewportBounds(Vector3 originViewportPoint, Camera currentCamera, Vector3 currentScreenPosition)
        {
            Vector3 v1 = originViewportPoint;
            Vector3 v2 = currentCamera.ScreenToViewportPoint(currentScreenPosition);

            Vector3 min = Vector3.Min(v1, v2);
            Vector3 max = Vector3.Max(v1, v2);
            min.z = currentCamera.nearClipPlane;
            max.z = currentCamera.farClipPlane;

            Bounds bounds = new Bounds();
            bounds.SetMinMax(min, max);
            return bounds;
        }
开发者ID:HyroVitalyProtago,项目名称:KingdomsRebellion,代码行数:14,代码来源:BoxTools.cs

示例8: BoundsOfPoints

    public static Bounds BoundsOfPoints(IList<ScreenCoordinate> points)
    {
        float minX = 0.0f, minY = 0.0f, maxX = 0.0f, maxY = 0.0f;

        foreach (ScreenCoordinate p in points) {
            if (p.position.x < minX) { minX = p.position.x; }
            if (p.position.x > maxX) { maxX = p.position.x; }
            if (p.position.y < minY) { minY = p.position.y; }
            if (p.position.y > maxY) { maxY = p.position.y; }
        }
        Bounds b = new Bounds();
        b.SetMinMax(new Vector3(minX, minY), new Vector3(maxX, maxY));
        return b;
    }
开发者ID:RelicViper,项目名称:UnityHexGrid,代码行数:14,代码来源:HexGrid.cs

示例9: initConfig

        public void initConfig()
        {
            keyForward = KeyCode.W;
            keyBack = KeyCode.S;
            keyRight = KeyCode.D;
            keyLeft = KeyCode.A;
            keyUp = KeyCode.E;
            keyDown = KeyCode.Q;
            keyRun = KeyCode.Space;
            keySneak = KeyCode.LeftControl;
            keySwitchMode = KeyCode.Alpha5;

            enableExperimentalEditorExtensionsCompatibility = true;
            defaultCamera = true;
            enforceBounds = true;
            mouseWheelActive = true;

            sensitivity = 14;
            acceleration = 150;
            friction = 10;
            runMultiplier = 2;
            sneakMultiplier = 0.3f;
            mouseWheelAcceleration = 1.75f;

            //vab = cfg.vab;
            vab = new EditorConfig();
            sph = new EditorConfig();

            vab.initialPosition = new Vector3(-6.1f,17.7f, -1.9f);
            vab.initialPitch = 16.386f;
            vab.initialYaw = 72.536f;
            Vector3 min = new Vector3(-28.8f, 0.8f, -22.5f);
            Vector3 max = new Vector3(29.7f, 70f, 22.7f);
            var result = new Bounds();
            result.SetMinMax(min, max);
            vab.bounds = result;

            // sph = cfg.sph;
            sph.initialPosition = new Vector3(-8.6f, 14.4f,  2.7f);
            sph.initialPitch = 14.080f;
            sph.initialYaw = 120.824f;

            min = new Vector3(-43.2f, 1.4f, -56f);
            max = new Vector3(43.0f, 30.3f, 56.0f);
            result = new Bounds();
            result.SetMinMax(min, max);
            sph.bounds = result;
        }
开发者ID:linuxgurugamer,项目名称:WasdEditorCameraContinued,代码行数:48,代码来源:Config.cs

示例10: GetRendererBoundsInChildren

    static Bounds GetRendererBoundsInChildren(Transform root, HashSet<Transform> ignoreItems, Transform transform, bool includeAllChildren) {
        Vector3 vector3Min = new Vector3(float.MinValue, float.MinValue, float.MinValue);
        Vector3 vector3Max = new Vector3(float.MaxValue, float.MaxValue, float.MaxValue);
        Vector3[] minMax = new Vector3[] {
            vector3Max,
            vector3Min
        };

        GetRendererBoundsInChildren( root.worldToLocalMatrix, minMax, ignoreItems, transform, includeAllChildren);

        Bounds b = new Bounds();
        if (minMax[0] != vector3Max && minMax[1] != vector3Min) {
            b.SetMinMax(minMax[0], minMax[1]);
        }
        return b;
    }
开发者ID:sundayliu,项目名称:HelloWorld-unity3d,代码行数:16,代码来源:tk2dUIItemBoundsHelper.cs

示例11: getBGLimits

    public Bounds getBGLimits()
    {
        Bounds BGBounds = GameObject.Find(BGObjectTag).GetComponent<SpriteRenderer>().bounds;
        Bounds BGBoundLimits = new Bounds();
        Vector3 BGBoundsMin = new Vector3();
        Vector3 BGBoundsMax = new Vector3();

        if (BGBounds.min.x < 0)
        {
            BGBoundsMin.x = BGBounds.min.x + 1;
        }
        else
        {
            BGBoundsMin.x = BGBounds.min.x - 1;
        }

        if (BGBounds.max.x < 0)
        {
            BGBoundsMax.x = BGBounds.max.x + 1;
        }
        else
        {
            BGBoundsMax.x = BGBounds.max.x - 1;
        }

        if (BGBounds.min.y < 0)
        {
            BGBoundsMin.y = BGBounds.min.y + 1;
        }
        else
        {
            BGBoundsMin.y = BGBounds.min.y - 1;
        }

        if (BGBounds.max.y < 0)
        {
            BGBoundsMax.y = BGBounds.max.y + 1;
        }
        else
        {
            BGBoundsMax.y = BGBounds.max.y - 1;
        }

        BGBoundLimits.SetMinMax(BGBoundsMin, BGBoundsMax);

        return BGBoundLimits;
    }
开发者ID:LUDUSLab,项目名称:Loona,代码行数:47,代码来源:BGLimits.cs

示例12: CalculateBoundingBox

 public static Bounds CalculateBoundingBox(GameObject aObj)
 {
     if (aObj == null) {
         Debug.LogError("CalculateBoundingBox: object is null");
         return new Bounds(Vector3.zero, Vector3.one);
     }
     Transform myTransform = aObj.transform;
     Mesh mesh = null;
     MeshFilter mF = aObj.GetComponent<MeshFilter>();
     if (mF != null) mesh = mF.mesh;
     else {
         SkinnedMeshRenderer sMR = aObj.GetComponent<SkinnedMeshRenderer>();
         if (sMR != null) mesh = sMR.sharedMesh;
     }
     if (mesh == null) {
         Debug.LogError("CalculateBoundingBox: no mesh found on the given object");
         return new Bounds(aObj.transform.position, Vector3.one);
     }
     Vector3[] vertices = mesh.vertices;
     if (vertices.Length <=0) {
         Debug.LogError("CalculateBoundingBox: mesh doesn't have vertices");
         return new Bounds(aObj.transform.position, Vector3.one);
     }
     Vector3 min, max;
     min = max = myTransform.TransformPoint(vertices[0]);
     for (int i = 1; i < vertices.Length; i++) {
         Vector3 V = myTransform.TransformPoint(vertices[i]);
         for (int n = 0; n < 3; n++) {
             if (V[n] > max[n]) max[n] = V[n];
             if (V[n] < min[n]) min[n] = V[n];
         }
     }
     Bounds B = new Bounds();
     B.SetMinMax(min, max);
     return B;
 }
开发者ID:imclab,项目名称:box-chart-test,代码行数:36,代码来源:GraphManager.cs

示例13: getBoundsOfTrackPiece

    public Bounds getBoundsOfTrackPiece(MeshRenderer[] mrList)
    {
        Bounds trackBounds = new Bounds();

        float minx = float.MaxValue;
        float minz = float.MaxValue;
        float maxx = float.MinValue;
        float maxz = float.MinValue;
        foreach (MeshRenderer mr in mrList)
        {
            if (minx > mr.bounds.min.x)
                minx = mr.bounds.min.x;
            if (maxx < mr.bounds.max.x)
                maxx = mr.bounds.max.x;
            if (minz > mr.bounds.min.z)
                minz = mr.bounds.min.z;
            if (maxz < mr.bounds.max.z)
                maxz = mr.bounds.max.z;
        }

        trackBounds.SetMinMax(new Vector3(minx, 0, minz), new Vector3(maxx, 0, maxz));

        return trackBounds;
    }
开发者ID:JeanPascalEvette,项目名称:DodgeThisRacing,代码行数:24,代码来源:GameLogic.cs

示例14: FillMesh

	Mesh FillMesh(Mesh mesh) {
		Vector3 anchorOffset = Vector3.zero;
		switch (anchor) {
			case tk2dBaseSprite.Anchor.UpperLeft: 		anchorOffset = new Vector3(0, -size.y, 0); break;
			case tk2dBaseSprite.Anchor.UpperCenter: 	anchorOffset = new Vector3(-size.x / 2, -size.y, 0); break;
			case tk2dBaseSprite.Anchor.UpperRight: 		anchorOffset = new Vector3(-size.x, -size.y, 0); break;
			case tk2dBaseSprite.Anchor.MiddleLeft: 		anchorOffset = new Vector3(0, -size.y / 2, 0); break;
			case tk2dBaseSprite.Anchor.MiddleCenter: 	anchorOffset = new Vector3(-size.x / 2, -size.y / 2, 0); break;
			case tk2dBaseSprite.Anchor.MiddleRight: 	anchorOffset = new Vector3(-size.x, -size.y / 2, 0); break;
			case tk2dBaseSprite.Anchor.LowerLeft: 		anchorOffset = new Vector3(0, 0, 0); break;
			case tk2dBaseSprite.Anchor.LowerCenter: 	anchorOffset = new Vector3(-size.x / 2, 0, 0); break;
			case tk2dBaseSprite.Anchor.LowerRight: 		anchorOffset = new Vector3(-size.x, 0, 0); break;
		}

		Vector3[] positions = new Vector3[4] {
			anchorOffset + new Vector3( 0,  0, -depth),
			anchorOffset + new Vector3( size.x,  0, -depth),
			anchorOffset + new Vector3( 0,  size.y, -depth),
			anchorOffset + new Vector3( size.x,  size.y, -depth)
		};

		mesh.vertices = positions;
		mesh.uv = uv;
		mesh.triangles = indices;
		
		// Recalculate bounds, and reset bounds center, i.e. determining draw order for
		// transparent sprites
		Bounds bounds = new Bounds();
		bounds.SetMinMax(anchorOffset, anchorOffset + new Vector3(size.x, size.y, 0));
		mesh.bounds = bounds;

		return mesh;
	}
开发者ID:AtwoodDeng,项目名称:GGJ2015,代码行数:33,代码来源:tk2dUIMask.cs

示例15: Scan

        public static void Scan(GameObject meshObject, float voxelSize)
        {
            Transform meshTransform = meshObject.transform;

            Mesh mesh = null;
            MeshFilter mF = meshObject.GetComponent<MeshFilter>();
            if (mF != null)
                mesh = mF.sharedMesh;
            else
            {
                SkinnedMeshRenderer sMR = meshObject.GetComponent<SkinnedMeshRenderer>();
                if (sMR != null)
                    mesh = sMR.sharedMesh;
            }
            if (mesh == null) return;

               // bool addedCollider = false;
            GameObject mcContainer = new GameObject("PVMCC");
            mcContainer.transform.SetParent(meshObject.transform, false);
            MeshCollider mc = mcContainer.AddComponent<MeshCollider>();
            mc.sharedMesh = mesh;

            GameObject mcContainerRev = new GameObject("PVMCCR");
            mcContainerRev.transform.SetParent(meshObject.transform, false);
            Mesh reverseMesh = (Mesh)UnityEngine.Object.Instantiate(mesh);
            reverseMesh.triangles = mesh.triangles.Reverse().ToArray();
            MeshCollider mcr = mcContainerRev.AddComponent<MeshCollider>();
            mcr.sharedMesh = reverseMesh;

            Vector3[] vertices = mesh.vertices;
            if (vertices.Length <= 0) return;

            Texture2D renderTex =null;
            Color materialColor = Color.white;
            Renderer rend = meshObject.GetComponent<Renderer>();
            if (rend != null && rend.sharedMaterial != null && rend.sharedMaterial.mainTexture != null)
            {
                renderTex = (Texture2D)rend.sharedMaterial.mainTexture;
                try
                {
                    renderTex.GetPixel(0, 0);
                }
                catch (Exception)
                {
                    string path = AssetDatabase.GetAssetPath(rend.sharedMaterial.mainTexture);
                    TextureImporter ti = (TextureImporter)TextureImporter.GetAtPath(path);
                    ti.isReadable = true;
                    AssetDatabase.ImportAsset(path);
                    ti.isReadable = false;

                    try
                    {
                        renderTex.GetPixel(0, 0);
                    }
                    catch (Exception)
                    {
                        renderTex = null;
                    }
                }
            }
            else if (rend != null && rend.sharedMaterial != null)
            {
                materialColor = rend.sharedMaterial.color;
            }

            Vector3 min, max;
            min = max = meshTransform.TransformPoint(vertices[0]);
            for (int i = 1; i < vertices.Length; i++)
            {
                Vector3 V = meshTransform.TransformPoint(vertices[i]);
                for (int n = 0; n < 3; n++)
                {
                    if (V[n] > max[n])
                        max[n] = V[n];
                    if (V[n] < min[n])
                        min[n] = V[n];
                }

                vertices[i] = V;
            }
            vertices[0] = meshTransform.TransformPoint(vertices[0]);
            Bounds bounds = new Bounds();
            bounds.SetMinMax(min, max);

            if (bounds.size.x <= 0f || bounds.size.y <= 0f || bounds.size.z <= 0f) return;

            var newObject = Editor.Instantiate(EditorUtility.VoxelVolumePrefab, Vector3.zero, Quaternion.identity) as GameObject;
            newObject.name = meshObject.name+" (Voxels)";
            newObject.GetComponent<Volume>().Material = EditorUtility.PicaVoxelDiffuseMaterial;
            newObject.GetComponent<Volume>().GenerateBasic(FillMode.None);
            Volume voxelVolume = newObject.GetComponent<Volume>();

            voxelVolume.XSize = (int)(bounds.size.x/voxelSize)+1;
            voxelVolume.YSize = (int)(bounds.size.y / voxelSize)+1;
            voxelVolume.ZSize = (int)(bounds.size.z / voxelSize)+1;
            voxelVolume.Frames[0].XSize = voxelVolume.XSize;
            voxelVolume.Frames[0].YSize = voxelVolume.YSize;
            voxelVolume.Frames[0].ZSize = voxelVolume.ZSize;
            voxelVolume.Frames[0].Voxels = new Voxel[voxelVolume.XSize * voxelVolume.YSize * voxelVolume.ZSize];
            for (int i = 0; i < voxelVolume.Frames[0].Voxels.Length; i++) voxelVolume.Frames[0].Voxels[i].Value = 128;
//.........这里部分代码省略.........
开发者ID:arancauchi,项目名称:Mini-Games,代码行数:101,代码来源:MeshScanner.cs


注:本文中的UnityEngine.Bounds.SetMinMax方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。