Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by bormeth · Feb 08, 2012 at 02:02 PM · editortransform

Transform override

How would i go around making a "new" standard transform.

Atm it looks like 123, 245, 886 in the editor. How would i do so unity make the funky number the standard "1,1,1".

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image tingham · Feb 08, 2012 at 02:22 PM 0
Share

You could mean either:

  1. You want to create an empty game object that exists at a specific position in which case: GameObject g = new GameObject(); g.transform.position = Vector3.one;

  2. You want to create a new transform object; which won't work.

  3. You want to normalize your transform so that your values are bounded inside of 0f - 1f in which case: Vector3 nPos = transform.position.normalized;

There might be a fourth case but without more detail in your question it's hard to guess.

3 Replies

· Add your reply
  • Sort: 
avatar image
1

Answer by Loius · Feb 08, 2012 at 02:29 PM

For what purpose?

Build a static method like

class weirdtransform {
 public static transform( t : Transform ) : Transform {
  var x : Transform;
  x.rotation = t.rotation;
  x.position = t.position - Vector3(123,456,886);
  return x;
 }
}

And then never use transform calls directly from code again, instead of gameObject.Transform.anything, use weirdtransform.transform( gameObject.Transform ).anything

That said, you may want to rethink what you're doing. 1,1,1 is a very nice central location.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image tingham · Feb 08, 2012 at 02:31 PM 0
Share

It seems likely to me that @bormeth wants to create a Vector3. Hopefully we'll get some more detail.

avatar image
0

Answer by bormeth · Feb 08, 2012 at 02:41 PM

Hey :) i want to normalize the transformer when looking in the unity editor.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by Matt-Downey · Apr 24, 2017 at 10:23 AM

This is my solution.

 public abstract class CustomComponent : Component
 {
     public new CustomTransform transform;
 }
   
 public class CustomTransform
 {   
     public Vector3 position
     {
         get
         {
             initialize_transform();
             return transform_reference.position;
         }
         set
         {
             initialize_transform();
             transform_reference.position = value;
             transform_reference.position.Normalize();
         }
     }

     private void initialize_transform()
     {
         if (transform_reference == null)
         {
             transform_reference = this.GetComponent<Transform>();
         }
     }
     
     Transform transform_reference;
 }

This strategy can be done with any class with Transform transform, but bear in mind that 1) You still have to change the Transform in CustomTransform and 2) Using a reference to the Component (rather than CustomComponent) will alter Transform (not CustomTransform).

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

unity not undoing transform changes? 1 Answer

how to make a plane's height be Y instead of Z 1 Answer

How is transform.position affected by scaling? 1 Answer

Transform component of Inspector panel changes 1 Answer

My rigged mesh does not react in Unity 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges