public override ModularPlacableObject Duplicate()
        {
            ModularPiece DuplicatedPiece = (ModularPiece)base.Duplicate();

            DuplicatedPiece.Initialize(ParentSet);              // initialize modular set
            DuplicatedPiece.InitializeID(ID);
            DuplicatedPiece.InitializeTextureData(this.CurrentTextureKeys);
            DuplicatedPiece.InitializeColors(this.Colors);
            this.ParentSet.AddModularPiece(DuplicatedPiece);             // add duplicated piece to modular sets
            DuplicatedPiece.RegisterUndoable();
            return(DuplicatedPiece);
        }
        public ModularPiece InitStoreItem(ModularPieceSaveData PieceSaveData)
        {
            ModularPieceData PieceData = GameManager.I.Modular.FindPiece(PieceSaveData.ID);             // find modular piece

            if (PieceData != null)
            {
                ModularPiece piece = InitStoreItem(PieceData, PieceSaveData.LocalScale, Vector3.zero, PieceSaveData.LocalEulerAngles, PieceSaveData.LocalPosition);
                piece.InitializeTextureData(PieceSaveData.TextureDataKeys);
                piece.InitializeColors(PieceSaveData.Colors);                  // initialize colors
                return(piece);
            }
            return(null);
        }
        public ModularPiece InitStoreItem(ModularPieceData Piece, Vector3 Scale, Vector3 RotationOffset = default(Vector3), Vector3 InitRotation = default(Vector3), Vector3 InitPosition = default(Vector3))
        {
            if (Piece != null)
            {
                GameObject obj = Piece.Prefab;                 // pick base object

                // instantiate item
                ModularPiece piece = GameObject.Instantiate(obj, InitPosition, Quaternion.identity).GetComponent <ModularPiece> ();
                piece.gameObject.name = Piece.Name;
                piece.InitializeID(Piece.Key);
                piece.InitializeTextureData();
                piece.InitializeColors();
                piece.transform.localScale    = Scale;
                piece.transform.localPosition = InitPosition;
                piece.NoneOffsettedRotation   = Quaternion.Euler(InitRotation);     // set rotation with rotation property
                piece.RotationOffset          = Quaternion.Euler(RotationOffset);   // set rotation offset
                piece.Initialize(GameManager.I.Modular.ScopedSet);                  // initialize piece data
                return(piece);
            }
            return(null);
        }