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 da_chinese · Nov 22, 2012 at 04:11 PM · serversvnperforceassetserver

Asset Server - Manual commit from script

Hi, In order to finish the continuous integration of our project, I need to submit nightly-builded libs into our unity asset server.

Is there a way to submit something into the UAS from code (c# or script(python/bash)) ?

That is quite a basic operation, a simple submit, but I haven't seen anything like that in the doc and it is really missing.

Could this be done in command line with psql ?

Could this be done by faking a click in "commit" button in the UnityEditor.ASMainWindow ?

Cheers,

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
1

Answer by da_chinese · Nov 23, 2012 at 02:40 PM

Ok - After some investigation with ILspy, here is the solution I came up with.

It is certainly not perfect, using Reflection to call on private members, but well, it gets the job done.

The code will certainly break if the UnityTeam decides to changes internal names,

Hope that can be useful to some of you,

     static void UASCommit ( string[] _files, string _messageCommit )
     {   
         if (    _files == null
              || _files.Length == 0
              || string.IsNullOrEmpty( _messageCommit ) )
         {
             Debug.Log ( "UASCommit -- Invalid Arguments." );
             return;
         }
         
         string menuPath = "Window/Asset Server";
         string defaultTitle = "Server";
         System.Reflection.Assembly assembly =  typeof(UnityEditor.EditorWindow).Assembly;
         System.Type type = assembly.GetType( "UnityEditor.ASMainWindow" );
         
         EditorApplication.ExecuteMenuItem(menuPath);
         EditorWindow window = EditorWindow.GetWindow(type, false, defaultTitle);
                      
         try
         { 
             List<UnityEngine.Object> selectionList = new List<UnityEngine.Object>();
             foreach ( string file in _files )
             {
                 UnityEngine.Object assetFromFile = AssetDatabase.LoadMainAssetAtPath( file ) ;
                 if ( assetFromFile != null )
                 {
                     selectionList.Add ( assetFromFile );
                 }
             }
              
             Selection.objects = selectionList.ToArray();
             if (Selection.objects.Length != _files.Length)
             {
                 Debug.LogError(
                     string.Format( "Selection size is incorrect. Selection has '{0}' items whereas we asked for '{1}' files to be submitted.",
                         Selection.objects.Length, _files.Length ) );
                 
                 return;
             }
             
             type.InvokeMember("StartCommitting", 
                 System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic 
                 , null, window, null); 
                         
             // set value of private field: private double _number
             type.InvokeMember("commitMessage",
                 BindingFlags.SetField | BindingFlags.Instance | BindingFlags.NonPublic,
                 null, window, new string[] { _messageCommit } ); 
                  
             type.InvokeMember("DoCommit", 
                 System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic 
                 , null, window, null);
              
         }
         catch ( System.Reflection.TargetInvocationException targetInvocationException )
         {
             if ( targetInvocationException.InnerException is UnityEngine.ExitGUIException )
             { 
                 // Do Commit finish by a "GUIUtility.ExitGUI();"
                 //
                 // UnityEngine.GUIUtility
                 // public static void ExitGUI()
                 // {
                 //         throw new ExitGUIException();
                 // }
                 // 
                 // So appenrently that is "normal" to throw an exception -
                  // Well, I am going to eat it silently 
             }
             else
             {
                 Debug.LogError ( targetInvocationException.InnerException.Message );
                 throw targetInvocationException.InnerException;
             }
         }
     } 
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

9 People are following this question.

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

Related Questions

Should we stick with the Asset Server? 1 Answer

Can I change the Asset Server default port from 10733? 1 Answer

Perforce not selectable in Unity Pro 4 1 Answer

Unity networking tutorial? 6 Answers

Export Unity Asset Server Commit Log History 1 Answer


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