コード例 #1
0
 private static void UpdateWorld(Transform NewWorld)
 {
     if (MyTargetWorld != NewWorld)
     {
         MyTargetWorld = NewWorld;
         if (MyTargetWorld)
         {
             MyWorld = MyTargetWorld.GetComponent <VoxelEngine.World> ();
             if (MyWorld)
             {
                 //MyWorld.DebugChunkPositions ();
             }
             else
             {
                 MyTargetWorld = null;
             }
         }
     }
 }
コード例 #2
0
ファイル: AnimateSize.cs プロジェクト: Deus0/Zeltex-v2
 public void SetWorld(GameObject MyWorld)
 {
     DestroyingWorld = MyWorld.GetComponent <VoxelEngine.World> ();
 }
コード例 #3
0
    public static void RayTraceVoxels(SceneView MySceneView)
    {
        if (IsEditVoxels)
        {
            SceneCamera = MySceneView.camera;
            string  DebugRayString  = "";
            Vector3 MyMousePosition = Event.current.mousePosition;
            MyMousePosition.y = LevelSelectGui.GetMainCamera().pixelHeight - MyMousePosition.y;
            Ray MyRay = LevelSelectGui.GetMainCamera().ScreenPointToRay(MyMousePosition);

            RaycastHit MyHit;
            if (Physics.Raycast(MyRay, out MyHit))
            {
                DebugRayString += " Ray YES hit.\n";
                SetSelectionVisibility(true);
            }
            else
            {
                DebugRayString += " Ray NO hit.\n";
                SetSelectionVisibility(false);
            }
            if (MyHitObject != null)
            {
                DebugRayString += " Selected in debugger: " + MyHitObject.name + ".\n";
            }
            else
            {
                DebugRayString += " Debugger - Null Selected.\n";
            }

            if (Selection.activeObject)
            {
                DebugRayString += " Selected: " + Selection.activeObject.name + ".\n";
            }
            else
            {
                DebugRayString += " Heirarchy - Null Selected.\n";
            }
            var style = new GUIStyle(GUI.skin.button);
            style.normal.textColor = Color.white;
            //GUILayout.Label (DebugRayString, style, GUILayout.Width (80), GUILayout.Width (500));


            if (MyHit.collider && MyHit.collider.gameObject)                    // if was hit
            {
                MyHitObject = MyHit.collider.gameObject.transform;
                if (MyHitObject.GetComponent <VoxelEngine.Chunk> ())
                {
                    if (MyCube == null)
                    {
                        MyCube = GameObject.Find("SelectionMesh");
                    }
                    if (MyCube == null)
                    {
                        MyCube = GameObject.CreatePrimitive(PrimitiveType.Cube);
                        //DestroyImmediate (MyCube.GetComponent<BoxCollider> ());
                        MyCube.name = "SelectionMesh";
                    }
                    if (MyCube != null)
                    {
                        //MyHitObject.parent.GetComponent<VoxelEngine.World>(),MyHit.point))
                        MyCube.transform.position = MyHitObject.parent.TransformPoint(VoxelEngine.World.RayHitToBlockPosition(MyHit, (BlockType == 0)) + MyHitObject.transform.lossyScale / 2f);
                        MyCube.transform.rotation = MyHitObject.parent.transform.rotation;
                    }
                }
                // Retrieve the control Id
                if (BlockType >= 0)
                {
                    if (Event.current.isMouse && Event.current.type == EventType.MouseDown && Event.current.button == 0)
                    {
                        int controlId = GUIUtility.GetControlID(FocusType.Passive);
                        Event.current.Use();
                        {
                            //Debug.DrawLine(MyRay.origin, MyHit.point, Color.blue, 60);
                            if (MyHitObject.GetComponent <VoxelEngine.Chunk> ())
                            {
                                MyWorld = MyHitObject.parent.GetComponent <VoxelEngine.World> ();
                                if (MyWorld)
                                {
                                    MyWorld.UpdateBlockType(MyHit, BlockType, UpdateSize);

                                    /*VoxelEngine.World.UpdateBlockCamera(MySceneView.camera,
                                     *                          BlockType,
                                     *                          UpdateSize/2f,
                                     *                          10000);*/
                                }
                            }
                            MyHitObject = MyHitObject.parent;
                        }
                        GUIUtility.hotControl = controlId;
                    }
                }
                // Tell the UI your event is the main one to use, it override the selection in  the scene view
            }
        }
    }