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 sebascontra · Jun 05, 2012 at 03:46 PM · c#if statement

[c#} Combining if statements

Hi there, I'm newbie scripting and I want to draw lines (or thin cylinders) to connect the nodes represented in this code.

Let me explain a bit how it works: Given an certain atlas, this function calls some nodes from a specific label and plots them in an "empty universe". I'm trying to connect them by colored lines assigned to each label.

I mean, for example, if I create nodes from the labels 1, 2, 3 and 4, I want to connect the nodes having the same starting point or ending point.

Here is the code:

 //nodes    
 foreach (Transform location in subregion)
 {
     foreach (atlasRegionSubregionLocation node in connectomeModel.NodesGlobalIndexer.Values)
     {
         if(location.name == node.globalIndex.ToString())
         {
             GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere);
             sphere.transform.position = location.position;
                             
             MeshRenderer currentSubRegionRenderer = sphere.GetComponent ("MeshRenderer") as MeshRenderer;    
             Material material = new Material(Shader.Find("Transparent/Diffuse"));
             Color color; 
             if (node.regionRef.label == "lateralorbitofrontal")
                 color = new Color (1,0,0);
             else
                 color = new Color(0.5f, 0.5f, 0.5f);
                                                         
             material.color = color;
             currentSubRegionRenderer.material = material;
             continue;
 
             // how to add another if statement to create a Primitive as a
             // cylinder (or a simple line) and render it if its in the same
             // label or Index than the node??
         }
     }
 } 

 // Berenger : I don't know what are those, you must have forgot
 // the beginning of your code.    
 /*        }
     }
     RENDER = true;
 }*/


thanks in advance for any help

Comment
Add comment
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

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by sebascontra · Jun 05, 2012 at 07:51 PM

well, I have this part of code that creates a polyhedron to connect btw locations, the thing is how to merge them?

     // nodes
             foreach (Transform location in subregion)
             {
                 try 
                 {
                     int nodeindex = System.Convert.ToInt16(location.gameObject.name);
                     atlasRegionSubregionLocation currentNode  = connectomeModel.NodesGlobalIndexer[nodeindex] as atlasRegionSubregionLocation;
                      
                     int edgeinstanceIndex = 0; 
                     
                     foreach (int edgeIndex in currentNode.EdgeTo)
                     {
                         ConnectomeModel.Edge currentEdge = connectomeModel.Edges[edgeIndex];
                         
                         // Look for gameobjects representing edges
                         Vector3 fromCoord = (GameObject.Find(currentEdge.NodeFrom.ToString())).transform.position;
     
                         
                         // transform to local region
                         fromCoord = fromCoord - subregion.transform.position;
                         Vector3 toCoord =  (GameObject.Find(currentEdge.NodeTo.ToString())).transform.position;
                         toCoord = toCoord - subregion.transform.position;
                         instanceEdge(fromCoord , toCoord , (float)currentEdge.Weight  * 1.5f +  0.5f, edgeinstanceIndex, ref tempEdges, ref tempTriangles);
                         edgeinstanceIndex++;
                     }
                 } 
                 catch (System.Exception e)
                 {
                     Debug.Log("Skipped Node " + e.Message +" " + e.Source + " " + e.Data);
                     continue;
                 }
             
             }     
             currentSubRegionMesh.mesh.vertices = tempEdges;
             currentSubRegionMesh.mesh.triangles = tempTriangles;
             currentSubRegionMesh.mesh.uv = new Vector2[ NodeTo_EdgeCount*12];
             currentSubRegionMesh.mesh.RecalculateNormals();
             currentSubRegionMesh.mesh.RecalculateBounds();            
         }
     }

thanks!

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

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Conflicting Animator SetTrigger 0 Answers

If statement is being ignored 1 Answer

if statement only ever triggering the first condition even if it's false and the second one is true 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