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 estar · Nov 16, 2013 at 10:42 AM · scrollvisible

i need script c# scrollview object hide/unhide

alt text

metalstorm: ace would like to implement parts of the plane scrolling.

Current list of their friends by creating a number of objects

Left, right, scroll was implemented.

When you create an object, but as friends can create more than 100 objects can be.

Moving the scroll on the screen and the rest of the object being rendered, but hidden game speed and I would like to free up memory.

Please tell me how to do that.

my script source (i'm ngui is not used.)

 void Start()
 {
     GameData gameData = GameObject.Find("_GameData").GetComponent<GameData>();
     NetworkProcess networkProcess = GameObject.Find("_NetworkProcess").GetComponent<NetworkProcess>();
     
     saber = GameObject.Find("saber");
     
     if( saber == null )
     {
         GameObject prefab = Resources.Load("Prefab/saber", typeof(GameObject)) as GameObject;
         saber = (GameObject)Instantiate( prefab, new Vector3(82.0f, 10.0f, -76.0f), Quaternion.identity );
         saber.name = "saber";
     }

     hangar.transform.position = new Vector3(0.0f, 0.0f, 20.0f);
                 
     list = 30.0f;
     friendList = Mathf.Ceil(list/5.0f);
     
     aircraftFloor.Add((int)friendList);
     
     if(GameObject.Find("FloorObj") == null)
     {    
         objFloor2 = Resources.Load("Prefab/FloorObj", typeof(GameObject)) as GameObject;
         objFloor = (GameObject)Instantiate(objFloor2, new Vector3(164.0f, 0.6f, -57.0f), Quaternion.identity);
     }
     
     if(GameObject.Find("BottomFloor") == null)
     {    
         bFloor2 = Resources.Load("Prefab/BottomFloor", typeof(GameObject)) as GameObject;
         bFloor = (GameObject)Instantiate(bFloor2, new Vector3(0.0f, 0.6f, -57.0f), Quaternion.identity);
     }        
     
     //aircraft floor create
     if(obj == null)
     {
         GameObject newObj = Resources.Load("Prefab/floor_circle", typeof(GameObject)) as GameObject;

         for(int i = 0; i < friendList; i++) //Friends can create as many objects
         {    
             obj = (GameObject)Instantiate(newObj, new Vector3(164.0f+(409.0f*i), 0.6f, -57.0f), Quaternion.identity);
             obj.name = "floor_circle"+i;
             obj.transform.Rotate(270f, -180f, 0f);        
             //aircraftFloor배열에 오브젝트 저장
             aircraftFloor.Add(obj);
             obj.transform.parent = objFloor.transform;
         }
     }
     //floor object create
     floor = GameObject.Find("floor");
     
     
     
     //createNum = Mathf.Ceil((float)gameData.lobbyUserList.Length/5.0f);
     createNum = Mathf.Ceil(list/5.0f);
     bottomFloor.Add((int)createNum);
     if( floor == null )
     {
         GameObject floorPrefab = Resources.Load("Prefab/floor", typeof(GameObject)) as GameObject;
         for(int i  = 0; i < 2; i++ )
         {
             floor = (GameObject)Instantiate( floorPrefab, new Vector3(0.0f+(364.0f*i), -3.5f, -74.5f), Quaternion.identity);
             floor.name = "floor"+i;
             floor.transform.Rotate(270f, -180f, 0f);
             bottomFloor.Add(floor);
             floor.transform.parent = bFloor.transform;
         }
     }    
 }
 
 
 
 
 
 void Update(){
     
     if(Input.GetMouseButtonDown(0)){
         objPushed = true;
         vMouseLastPos = Input.mousePosition;
         bInAutoSlideMode = false;
     }

     if(Input.GetMouseButtonUp(0)){
         
         if( Time.deltaTime > 0.0000001f )
         {
             float speedMax = Screen.height*5.0f;
             float fCurrentSpeed = (Input.mousePosition.x - vMouseLastPos.x)/Time.deltaTime;
             if( Mathf.Abs(fCurrentSpeed)/(float)Screen.height > 0.1f )
             {
                 bInAutoSlideMode = true;
                 fAutoSlideSpeed = fCurrentSpeed;
                 if( fAutoSlideSpeed > speedMax ) fAutoSlideSpeed = speedMax;
                 if( fAutoSlideSpeed < -speedMax ) fAutoSlideSpeed = -speedMax;
             }
         }
         
         objPushed = false;
     }
     
     
     //friendList = Mathf.Ceil((float)gameData.lobbyUserList.Length);            
     friendList = Mathf.Ceil((float)list);
     float mulFactor = 120.0f;
     float oneSetWidth = 82.0f;
     float oneSetWidth2 = 82.0f*(friendList-1);
     
     if( !objPushed && bInAutoSlideMode )
     {
         float xDelta = fAutoSlideSpeed*Time.deltaTime;
         float xDeltaScreenRate = xDelta/(float)Screen.height;
         xDeltaScreenRate *= mulFactor;
         
         fSlideXOffset += xDeltaScreenRate;
         if( fSlideXOffset < -oneSetWidth2 )
         {
             fSlideXOffset = -oneSetWidth2;
             bInAutoSlideMode = false;
         }
         
         //aircraft don't move slide
         if( fSlideXOffset >= oneSetWidth*0 ) 
         {
             fSlideXOffset = oneSetWidth*0;
             bInAutoSlideMode = false;
         }
         //aircraft move
         objFloor.transform.position = new Vector3( fSlideXOffset+164.0f, objFloor.transform.position.y, objFloor.transform.position.z );
         bFloor.transform.position = new Vector3( fSlideXOffset*0.1f, bFloor.transform.position.y, bFloor.transform.position.z );    
         
         float fractionRate = (float)Screen.height*5;
         if( fAutoSlideSpeed > 0 )
         {
             fAutoSlideSpeed = fAutoSlideSpeed-Time.deltaTime*fractionRate;
             if( fAutoSlideSpeed < 0 )
             {
                 fAutoSlideSpeed = 0;
                 bInAutoSlideMode =false;
             }
         }
         else
         {
             fAutoSlideSpeed = fAutoSlideSpeed+Time.deltaTime*fractionRate;
             if( fAutoSlideSpeed > 0 )
             {
                 fAutoSlideSpeed = 0;
                 bInAutoSlideMode =false;
             }
         }
     }
     
     if(objPushed){
         
         float xDelta = Input.mousePosition.x - vMouseLastPos.x;
         float xDeltaScreenRate = xDelta/(float)Screen.height;
         xDeltaScreenRate *= mulFactor;
         
         fSlideXOffset += xDeltaScreenRate;
         if( fSlideXOffset < -oneSetWidth2 ) fSlideXOffset = -oneSetWidth2;
         if( fSlideXOffset >= oneSetWidth*0 ) fSlideXOffset = oneSetWidth*0; //첫번째 랭크 받침대에 도달하면 이동 못하도록 설정
             
         //전투기 받침대 이동 자표(부모 오브젝트의 위치를 이동함으로써 등록된 자식 오브젝트의 위치를 한번에 이동할 수 있도록 설정)
         objFloor.transform.position = new Vector3( fSlideXOffset+164.0f, objFloor.transform.position.y, objFloor.transform.position.z );    
         bFloor.transform.position = new Vector3( fSlideXOffset*0.1f, bFloor.transform.position.y, bFloor.transform.position.z );                        
         vMouseLastPos = Input.mousePosition;
     }
 }

}

metalstorm-aces-fighter-jets.jpg (92.1 kB)
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 ffxz7ff · Nov 16, 2013 at 10:53 AM 0
Share

...You want a part of the plane scrolling?

0 Replies

· Add your reply
  • Sort: 

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

18 People are following this question.

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

Related Questions

scroll wheel get weapon 3 Answers

Unity OnGUI 1 Answer

How to remove/hide GUI scroll bar 7 Answers

Scrolling level Instantiate after cycle 0 Answers

[4.6] Adding scroll to this combo? 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