コード例 #1
0
ファイル: TilePainter.cs プロジェクト: MeelisPerli/ProcMaze
 public void Drag(Vector3 mouse, TileLayerEditor.TileOperation op)
 {
     Resize();
     if (tileobs == null)
     {
         Restore();
     }
     if (this.ValidCoords((int)cursor.x, (int)cursor.y))
     {
         if (op == TileLayerEditor.TileOperation.Sampling)
         {
             UnityEngine.Object s = PrefabUtility.GetPrefabParent(tileobs[(int)cursor.x, (int)cursor.y]);
             if (s != null)
             {
                 color          = s;
                 color_rotation = tileobs[(int)cursor.x, (int)cursor.y].transform.localRotation;
             }
         }
         else
         {
             DestroyImmediate(tileobs[(int)cursor.x, (int)cursor.y]);
             if (op == TileLayerEditor.TileOperation.Drawing)
             {
                 if (color == null)
                 {
                     return;
                 }
                 GameObject o = CreatePrefab(color, new Vector3(), color_rotation);
                 o.transform.parent = tiles.transform;
                 BlockMover bm = o.GetComponent <BlockMover>();
                 if (bm == null)
                 {
                     o.transform.localPosition = (cursor * gridsize);
                 }
                 else
                 {
                     o.transform.localPosition = (cursor * gridsize) + bm.dist;
                 }
                 o.transform.localRotation             = color_rotation;
                 tileobs[(int)cursor.x, (int)cursor.y] = o;
             }
         }
     }
     else
     {
         if (op == TileLayerEditor.TileOperation.Sampling)
         {
             if (cursor.y == -1 && cursor.x >= 0 && cursor.x < palette.Count)
             {
                 color          = palette[(int)cursor.x];
                 color_rotation = Quaternion.identity;
             }
         }
     }
 }
コード例 #2
0
 public void Drag(Vector3 mouse, TileLayerEditor.TileOperation op)
 {
     Resize();
     if (tileobs == null)
     {
         Restore();
     }
     if (this.ValidCoords((int)cursor.x, (int)cursor.z))
     {
         if (op == TileLayerEditor.TileOperation.Sampling)
         {
             UnityEngine.Object s = PrefabUtility.GetPrefabParent(tileobs[(int)cursor.x, (int)cursor.z]);
             if (s != null)
             {
                 color          = s;
                 color_rotation = tileobs[(int)cursor.x, (int)cursor.z].transform.localRotation;
             }
         }
         else
         {
             DestroyImmediate(tileobs[(int)cursor.x, (int)cursor.z]);
             if (op == TileLayerEditor.TileOperation.Drawing)
             {
                 if (color == null)
                 {
                     return;
                 }
                 GameObject o = CreatePrefab(color, new Vector3(), color_rotation);
                 o.transform.parent                    = tiles.transform;
                 o.transform.localPosition             = (cursor * gridsize);
                 o.transform.localRotation             = color_rotation;
                 tileobs[(int)cursor.x, (int)cursor.z] = o;
             }
         }
     }
     else
     {
         if (cursor.z == -1 && cursor.x >= 0 && cursor.x < palette.Count)
         {
             if (op == TileLayerEditor.TileOperation.Sampling || op == TileLayerEditor.TileOperation.Drawing)
             {
                 color = palette[(int)cursor.x];
                 Debug.Log("Choose tile: " + color.name);
                 color_rotation = ((GameObject)color).transform.localRotation;
             }
         }
     }
 }