Ejemplo n.º 1
0
 public override void NodeUI(UnityEditor.Graphs.GraphGUI host)
 {
     base.graphGUI = host as UnityEditor.Graphs.AnimationStateMachine.GraphGUI;
     Assert.NotNull(base.graphGUI);
     if (UnityEditor.Graphs.AnimationStateMachine.Node.IsLeftClick())
     {
         host.edgeGUI.EndSlotDragging(Enumerable.First<Slot>(base.inputSlots), true);
     }
     if (UnityEditor.Graphs.AnimationStateMachine.Node.IsDoubleClick())
     {
         if (this.stateMachine == base.graphGUI.stateMachineGraph.parentStateMachine)
         {
             base.graphGUI.tool.GoToBreadCrumbTarget(this.stateMachine);
         }
         else
         {
             base.graphGUI.tool.AddBreadCrumb(this.stateMachine);
         }
         Event.current.Use();
     }
     if (UnityEditor.Graphs.AnimationStateMachine.Node.IsRightClick() && (this.stateMachine != base.graphGUI.stateMachineGraph.parentStateMachine))
     {
         GenericMenu menu = new GenericMenu();
         menu.AddItem(new GUIContent("Make Transition"), false, new GenericMenu.MenuFunction(this.MakeTransitionCallback));
         menu.AddItem(new GUIContent("Copy"), false, new GenericMenu.MenuFunction(this.CopyStateMachineCallback));
         menu.AddItem(new GUIContent("Delete"), false, new GenericMenu.MenuFunction(this.DeleteStateMachineCallback));
         menu.ShowAsContext();
         Event.current.Use();
     }
 }
			/// <summary>
			/// Construct from a Unity SceneSetup
			/// </summary>
			public SceneEntry( UnityEditor.SceneManagement.SceneSetup sceneSetup )
			{
				scene = new AmsSceneReference( sceneSetup.path );

				loadInEditor = sceneSetup.isLoaded;
				loadMethod = LoadMethod.Additive;
			}
Ejemplo n.º 3
0
 public override void Connect(UnityEditor.Graphs.AnimationStateMachine.Node toNode, UnityEditor.Graphs.Edge edge)
 {
     if (toNode is StateNode)
     {
         base.graphGUI.stateMachineGraph.rootStateMachine.AddAnyStateTransition((toNode as StateNode).state);
         base.graphGUI.stateMachineGraph.RebuildGraph();
     }
     if (toNode is StateMachineNode)
     {
         StateMachineNode node = toNode as StateMachineNode;
         if (node.stateMachine != base.graphGUI.parentStateMachine)
         {
             UnityEditor.Graphs.AnimationStateMachine.Node.GenericMenuForStateMachineNode(toNode as StateMachineNode, true, delegate (object data) {
                 if (data is AnimatorState)
                 {
                     base.graphGUI.stateMachineGraph.rootStateMachine.AddAnyStateTransition(data as AnimatorState);
                 }
                 else if (data is AnimatorStateMachine)
                 {
                     base.graphGUI.stateMachineGraph.rootStateMachine.AddAnyStateTransition(data as AnimatorStateMachine);
                 }
                 base.graphGUI.stateMachineGraph.RebuildGraph();
             });
         }
     }
     if (toNode is EntryNode)
     {
         base.graphGUI.stateMachineGraph.rootStateMachine.AddAnyStateTransition(base.graphGUI.activeStateMachine);
     }
 }
Ejemplo n.º 4
0
 public override void NodeUI(UnityEditor.Graphs.GraphGUI host)
 {
     if (UnityEditor.Graphs.AnimationStateMachine.Node.IsLeftClick())
     {
         host.edgeGUI.EndSlotDragging(Enumerable.First<Slot>(base.inputSlots), true);
     }
 }
Ejemplo n.º 5
0
 public static UnityEngine.Object[] GetFiltered(System.Type type, UnityEditor.SelectionMode mode)
 {
     ArrayList list = new ArrayList();
     if ((type == typeof(Component)) || type.IsSubclassOf(typeof(Component)))
     {
         foreach (Transform transform in GetTransforms(mode))
         {
             Component component = transform.GetComponent(type);
             if (component != null)
             {
                 list.Add(component);
             }
         }
     }
     else if ((type == typeof(GameObject)) || type.IsSubclassOf(typeof(GameObject)))
     {
         foreach (Transform transform2 in GetTransforms(mode))
         {
             list.Add(transform2.gameObject);
         }
     }
     else
     {
         foreach (UnityEngine.Object obj2 in GetObjectsMode(mode))
         {
             if ((obj2 != null) && ((obj2.GetType() == type) || obj2.GetType().IsSubclassOf(type)))
             {
                 list.Add(obj2);
             }
         }
     }
     return (UnityEngine.Object[]) list.ToArray(typeof(UnityEngine.Object));
 }
 private static List<MemoryElement> GenerateObjectTypeGroups(UnityEditor.ObjectInfo[] memory, ObjectTypeFilter filter)
 {
     List<MemoryElement> list = new List<MemoryElement>();
     MemoryElement item = null;
     foreach (UnityEditor.ObjectInfo info in memory)
     {
         if (GetObjectTypeFilter(info) == filter)
         {
             if ((item == null) || (info.className != item.name))
             {
                 item = new MemoryElement(info.className);
                 list.Add(item);
             }
             item.AddChild(new MemoryElement(info, true));
         }
     }
     list.Sort(new Comparison<MemoryElement>(MemoryElementDataManager.SortByMemorySize));
     foreach (MemoryElement element2 in list)
     {
         element2.children.Sort(new Comparison<MemoryElement>(MemoryElementDataManager.SortByMemorySize));
         if ((filter == ObjectTypeFilter.Other) && !HasValidNames(element2.children))
         {
             element2.children.Clear();
         }
     }
     return list;
 }
Ejemplo n.º 7
0
 public override void Connect(UnityEditor.Graphs.AnimationStateMachine.Node toNode, UnityEditor.Graphs.Edge edge)
 {
     if (toNode is StateNode)
     {
         base.graphGUI.stateMachineGraph.activeStateMachine.AddStateMachineTransition(this.stateMachine, (toNode as StateNode).state);
         base.graphGUI.stateMachineGraph.RebuildGraph();
     }
     else if (toNode is StateMachineNode)
     {
         UnityEditor.Graphs.AnimationStateMachine.Node.GenericMenuForStateMachineNode(toNode as StateMachineNode, true, delegate (object data) {
             if (data is AnimatorState)
             {
                 base.graphGUI.stateMachineGraph.activeStateMachine.AddStateMachineTransition(this.stateMachine, data as AnimatorState);
             }
             else
             {
                 base.graphGUI.stateMachineGraph.activeStateMachine.AddStateMachineTransition(this.stateMachine, data as AnimatorStateMachine);
             }
             base.graphGUI.stateMachineGraph.RebuildGraph();
         });
     }
     else if (toNode is ExitNode)
     {
         base.graphGUI.stateMachineGraph.activeStateMachine.AddStateMachineExitTransition(this.stateMachine);
         base.graphGUI.stateMachineGraph.RebuildGraph();
     }
 }
Ejemplo n.º 8
0
 private static void SaveToIndex(UnityEditor.MenuCommand mc, int index) {
   PositionSwapper ps = mc.context as PositionSwapper;
   while (ps.Positions.Length <= index) {
     UnityEditor.ArrayUtility.Add<Vector3>(ref ps.Positions, Vector3.zero);
   }
   ps.Positions[index] = ps.transform.localPosition;
 }
Ejemplo n.º 9
0
 public static void SetAttribute( UnityEditor.PropertyDrawer drawer, PropertyAttribute attribute )
 {
     FieldInfo fi = TargetType.GetField( "m_Attribute", BindingFlags.NonPublic | BindingFlags.Instance );
     if( fi == null ){
         Debug.Log( "Error, FieldInfo not found" );
         return;
     }
     fi.SetValue( drawer, attribute );
 }
        public override void OnGUI(Rect position, UnityEditor.SerializedProperty property, GUIContent label)
        {
            string fieldName;
            bool notifyPropertyChanged;
            {
                var attr = this.attribute as InspectorDisplayAttribute;
                fieldName = (attr == null) ? "value" : attr.FieldName;
                notifyPropertyChanged = (attr == null) ? true : attr.NotifyPropertyChanged;
            }

            if (notifyPropertyChanged)
            {
                EditorGUI.BeginChangeCheck();
            }
            var targetSerializedProperty = property.FindPropertyRelative(fieldName);
            if (targetSerializedProperty == null)
            {
                UnityEditor.EditorGUI.LabelField(position, label, new GUIContent() { text = "InspectorDisplay can't find target:" + fieldName });
                if (notifyPropertyChanged)
                {
                    EditorGUI.EndChangeCheck();
                }
                return;
            }
            else
            {
                EmitPropertyField(position, targetSerializedProperty, label);
            }

            if (notifyPropertyChanged)
            {
                if (EditorGUI.EndChangeCheck())
                {
                    var propInfo = fieldInfo.FieldType.GetProperty(fieldName, BindingFlags.IgnoreCase | BindingFlags.GetProperty | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

                    property.serializedObject.ApplyModifiedProperties(); // deserialize to field

                    var paths = property.propertyPath.Split('.'); // X.Y.Z...
                    var attachedComponent = property.serializedObject.targetObject;

                    var targetProp = (paths.Length == 1)
                        ? fieldInfo.GetValue(attachedComponent)
                        : GetValueRecursive(attachedComponent, 0, paths);
                    var modifiedValue = propInfo.GetValue(targetProp, null); // retrieve new value

                    var methodInfo = fieldInfo.FieldType.GetMethod("SetValueAndForceNotify", BindingFlags.IgnoreCase | BindingFlags.InvokeMethod | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
                    if (methodInfo != null)
                    {
                        methodInfo.Invoke(targetProp, new object[] { modifiedValue });
                    }
                }
                else
                {
                    property.serializedObject.ApplyModifiedProperties();
                }
            }
        }
Ejemplo n.º 11
0
 public static Type GetInspectedType( UnityEditor.CustomEditor editor )
 {
     if( m_InspectedType == null )
         m_InspectedType = TargetType.GetField( "m_InspectedType", BindingFlags.NonPublic | BindingFlags.Instance );
     if( m_InspectedType == null ){
         Debug.Log( "FieldInfo Not Found" );
         return null;
     }
     return m_InspectedType.GetValue( editor ) as Type;
 }
Ejemplo n.º 12
0
		////////////////////////////////////////
		///////////GUI AND EDITOR STUFF/////////
		////////////////////////////////////////
		#if UNITY_EDITOR

		protected override UnityEditor.GenericMenu OnContextMenu(UnityEditor.GenericMenu menu){

			menu.AddItem( new GUIContent("Breakpoint"), isBreakpoint, ()=> { isBreakpoint = !isBreakpoint; } );
			menu.AddItem (new GUIContent ("Convert to SubTree"), false, ()=> { MakeNestedSubTree(this); });
            if (outConnections.Count > 0){
				menu.AddItem (new GUIContent ("Delete Branch"), false, ()=> { DeleteBranch(this); } );
				menu.AddItem(new GUIContent("Duplicate Branch"), false, ()=> { DuplicateBranch(this, graph); });
			}
			return menu;
		}		
Ejemplo n.º 13
0
 public static void SetSerializedObject( UnityEditor.Editor editor, UnityEditor.SerializedObject obj )
 {
     if( m_SerializedObjectFieldInfo == null )
         m_SerializedObjectFieldInfo = TargetType.GetField( "m_SerializedObject",
                                                            BindingFlags.NonPublic | BindingFlags.Instance );
     if( m_SerializedObjectFieldInfo == null ){
         Debug.Log( "FieldInfo Not Found" );
         return;
     }
     m_SerializedObjectFieldInfo.SetValue( editor, obj );
 }
    // AnimatorController内のステートを取得する
    private List<UnityEditor.Animations.AnimatorState> FindAnimationClips(
		UnityEditor.Animations.AnimatorController animatorController)
    {
        var stateList = new List<UnityEditor.Animations.AnimatorState> ();
        foreach (var layer in animatorController.layers) {
            foreach (var state in layer.stateMachine.states) {
                stateList.Add (state.state);
            }
        }
        return stateList;
    }
Ejemplo n.º 15
0
 ////////////////////////////////////////
 ///////////GUI AND EDITOR STUFF/////////
 ////////////////////////////////////////
 protected override UnityEditor.GenericMenu OnContextMenu(UnityEditor.GenericMenu menu)
 {
     menu.AddItem( new GUIContent("Breakpoint"), isBreakpoint, ()=> { isBreakpoint = !isBreakpoint; } );
     menu.AddItem (new GUIContent ("Convert to SubTree"), false, ()=> { MakeNestedSubTree(this); });
     if (outConnections.Count > 0){
         menu.AddItem (new GUIContent ("Delete Branch"), false, ()=> { DeleteBranch(this); } );
         menu.AddItem(new GUIContent("Duplicate Branch"), false, ()=> { DuplicateBranch(this, graph); });
     }
     menu = EditorUtils.GetTypeSelectionMenu(typeof(BTComposite), (t)=>{ ReplaceWith(t); }, menu, "Replace");
     return menu;
 }
 override public void OnGUI(Rect position, MaterialProperty prop, string label,
                            UnityEditor.MaterialEditor editor) {
   EditorGUI.BeginChangeCheck();
   prop.textureValue = editor.TextureProperty(prop, label);
   if (EditorGUI.EndChangeCheck()) {
     if (prop.textureValue == null) {
       (editor.target as Material).DisableKeyword(keywordName + "_ON");
     } else {
       (editor.target as Material).EnableKeyword(keywordName + "_ON");
     }
   }
 }
		public static void OnPostProcessBuild(UnityEditor.BuildTarget buildTarget, string buildPath) {
			string libpdcsharpTargetPath = Path.GetDirectoryName(buildPath) + Path.AltDirectorySeparatorChar + "libpdcsharp.dll";
			string pthreadGC2TargetPath = Path.GetDirectoryName(buildPath) + Path.AltDirectorySeparatorChar + "pthreadGC2.dll";
		
			if (!File.Exists(libpdcsharpTargetPath)) {
				File.Copy(LibpdcsharpPath, libpdcsharpTargetPath);
			}
		
			if (!File.Exists(pthreadGC2TargetPath)) {
				File.Copy(PthreadGC2Path, pthreadGC2TargetPath);
			}
		}
Ejemplo n.º 18
0
 public override void NodeUI(UnityEditor.Graphs.GraphGUI host)
 {
     base.graphGUI = host as UnityEditor.Graphs.AnimationStateMachine.GraphGUI;
     Assert.NotNull(base.graphGUI);
     Event current = Event.current;
     if (UnityEditor.Graphs.AnimationStateMachine.Node.IsRightClick())
     {
         GenericMenu menu = new GenericMenu();
         menu.AddItem(new GUIContent("Make Transition"), false, new GenericMenu.MenuFunction(this.MakeTransitionCallback));
         menu.ShowAsContext();
         current.Use();
     }
 }
Ejemplo n.º 19
0
    public static string GetPatchableResourcesPath(int iIdx, UnityEditor.BuildTarget eBuildTarget)
    {
        string sPath = GetRootResourcesPath();
        Star.Foundation.CPath.AddRightSlash(ref sPath);
        sPath += "patchable_resources_";
        sPath += iIdx;

        if (eBuildTarget == UnityEditor.BuildTarget.iOS) sPath += "/ios/";
        else if (eBuildTarget == UnityEditor.BuildTarget.Android) sPath += "/android/";
        else sPath += "/windows/";

        return sPath;
    }
Ejemplo n.º 20
0
		void RefleshClipList (UnityEditor.Animations.AnimatorController controller)
		{
			if (controller == null)
				return;

			clipList.Clear ();

			var allAsset = AssetDatabase.LoadAllAssetsAtPath (AssetDatabase.GetAssetPath (controller));
			foreach (var asset in allAsset) {
				if (asset is AnimationClip) {
					var removeClip = asset as AnimationClip;
					if (!clipList.Contains (removeClip)) {
						clipList.Add (removeClip);
					}
				}
			}
		}
Ejemplo n.º 21
0
 private static void OnUpdateComponents(UnityEditor.MenuCommand aCommand)
 {
     UIToggle context = aCommand.context as UIToggle;
     UIImage image = context.GetComponentInChildren<UIImage>();
     if(image != null)
     {
         image.GenerateMaterial();
         image.GenerateMesh();
         image.SetTexture();
         image.SetColor();
     }
     UILabel label = context.GetComponentInChildren<UILabel>();
     if(label != null)
     {
         label.UpdateComponents();
     }
     
 }
Ejemplo n.º 22
0
    public static void PostProcessBuild(UnityEditor.BuildTarget target, string pathToBuiltProject)
    {
        const string DATA_FOLDER = "{0}_Data";

        Debug.Log(string.Format("Post-processing build '{0}' at '{1}'.", target, pathToBuiltProject));

        // The file name is integrated in some folder/file names of the built game. It may be needed to create references to these dynamic folders/files.
        string fileName = Path.GetFileNameWithoutExtension(pathToBuiltProject);
        // The build directory is the build path, without file name and extension and appended with the custom path.
        string buildDirectory = Path.Combine(Path.Combine(Path.GetDirectoryName(pathToBuiltProject) ?? string.Empty,
                                                            string.Format(DATA_FOLDER, fileName)),
                                                BUILD_LEVELS_FILE_DIRECTORY);

        Debug.Log(string.Format("Detected levels file directory '{0}'.", buildDirectory));

        WriteLevelsFile(buildDirectory);

        Debug.Log("Post-processed build.");
    }
Ejemplo n.º 23
0
 public static void main(string[] args)
 {
     GameObject x=GameObject.Find("Cube");
     Vector3[] newVertices = new[] { new Vector3(0f, 0f, 0f), new Vector3(1f, 1f, 1f), new Vector3(0f, 1f, 0f) };//changed initialization, it should work with colons but wasn't for me so will solve later.     
     //var newVertices : Vector3[];
     Vector2[] newUV = new[] { new Vector2(0f, 0f), new Vector2(1f, 1f),new Vector2(0f,1f) };
     //var newUV : Vector2;
     int[] newTriangles={0,1,2};
     //var newTriangles : int[];
     // Mesh mesh = new Mesh();
     //var mesh : Mesh = new Mesh ();
     Mesh mesh;
     MeshFilter objectmesh = x.GetComponent<MeshFilter>();// (MeshFilter.mesh.get);
     mesh = objectmesh.sharedMesh;
     //GetComponent.<MeshFilter>().mesh = mesh;
     mesh.vertices = newVertices;
     mesh.uv = newUV;
     mesh.triangles = newTriangles;
 }
Ejemplo n.º 24
0
        private static ObjectTypeFilter GetObjectTypeFilter(UnityEditor.ObjectInfo info)
        {
            switch (info.reason)
            {
                case 1:
                    return ObjectTypeFilter.BuiltinResource;

                case 2:
                    return ObjectTypeFilter.DontSave;

                case 3:
                case 8:
                case 9:
                    return ObjectTypeFilter.Asset;

                case 10:
                    return ObjectTypeFilter.Other;
            }
            return ObjectTypeFilter.Scene;
        }
Ejemplo n.º 25
0
 private static void UpdateSceneTable(UnityEditor.MenuCommand command)
 {
     GameEngine context = (GameEngine)command.context;
     List<string> scenes = new List<string>();
     string path;
     foreach (UnityEditor.EditorBuildSettingsScene s in UnityEditor.EditorBuildSettings.scenes)
     {
         if (s.enabled)
         {
             int sep = s.path.IndexOf("Assets/Resources/");
             if (sep == 0)
                 path = s.path.Substring(17, s.path.IndexOf('/', 17) - 17) + ":";
             else
                 path = "";
             sep = s.path.LastIndexOf('/');
             scenes.Add(path + s.path.Substring(sep + 1, s.path.LastIndexOf('.') - sep - 1));
         }
     }
     context.sceneTable = scenes.ToArray();
 }
Ejemplo n.º 26
0
 /**
  *  from build target group to human friendly string for display purpose.
  */
 public static string GroupToHumaneString(UnityEditor.BuildTargetGroup g)
 {
     switch(g) {
     case BuildTargetGroup.Android:
         return "Android";
     case BuildTargetGroup.iOS:
         return "iOS";
     case BuildTargetGroup.Nintendo3DS:
         return "Nintendo 3DS";
     case BuildTargetGroup.PS3:
         return "PlayStation 3";
     case BuildTargetGroup.PS4:
         return "PlayStation 4";
     case BuildTargetGroup.PSM:
         return "PlayStation Mobile";
     case BuildTargetGroup.PSP2:
         return "PlayStation Vita";
     case BuildTargetGroup.SamsungTV:
         return "Samsung TV";
     case BuildTargetGroup.Standalone:
         return "PC/Mac/Linux Standalone";
     case BuildTargetGroup.Tizen:
         return "Tizen";
     case BuildTargetGroup.tvOS:
         return "tvOS";
     case BuildTargetGroup.WebGL:
         return "WebGL";
     case BuildTargetGroup.WiiU:
         return "Wii U";
     case BuildTargetGroup.WSA:
         return "Windows Store Apps";
     case BuildTargetGroup.XBOX360:
         return "Xbox 360";
     case BuildTargetGroup.XboxOne:
         return "Xbox One";
     case BuildTargetGroup.Unknown:
         return "Unknown";
     default:
         return g.ToString() + "(deprecated)";
     }
 }
Ejemplo n.º 27
0
 public static BuildTarget GroupToTarget(UnityEditor.BuildTargetGroup g)
 {
     switch(g) {
     case BuildTargetGroup.Android:
         return BuildTarget.Android;
     case BuildTargetGroup.iOS:
         return BuildTarget.iOS;
     case BuildTargetGroup.Nintendo3DS:
         return BuildTarget.Nintendo3DS;
     case BuildTargetGroup.PS3:
         return BuildTarget.PS3;
     case BuildTargetGroup.PS4:
         return BuildTarget.PS4;
     case BuildTargetGroup.PSM:
         return BuildTarget.PSM;
     case BuildTargetGroup.PSP2:
         return BuildTarget.PSP2;
     case BuildTargetGroup.SamsungTV:
         return BuildTarget.SamsungTV;
     case BuildTargetGroup.Standalone:
         return BuildTarget.StandaloneWindows;
     case BuildTargetGroup.Tizen:
         return BuildTarget.Tizen;
     case BuildTargetGroup.tvOS:
         return BuildTarget.tvOS;
     case BuildTargetGroup.WebGL:
         return BuildTarget.WebGL;
     case BuildTargetGroup.WiiU:
         return BuildTarget.WiiU;
     case BuildTargetGroup.WSA:
         return BuildTarget.WSAPlayer;
     case BuildTargetGroup.XBOX360:
         return BuildTarget.XBOX360;
     case BuildTargetGroup.XboxOne:
         return BuildTarget.XboxOne;
     default:
         // temporarily assigned for default value (BuildTargetGroup.Unknown)
         return (BuildTarget)int.MaxValue;
     }
 }
Ejemplo n.º 28
0
 static void DrawSphere(float radius, Vector3 position, Quaternion rotation)
 {
     var vectorArray = new[] { rotation * Vector3.right, rotation * Vector3.up, rotation * Vector3.forward, rotation * -Vector3.right, rotation * -Vector3.up, rotation * -Vector3.forward };
     float num4 = radius * radius;
     Vector3 forward = position - Camera.current.transform.position;
     float sqrMagnitude = forward.sqrMagnitude;
     float f = (num4 * num4) / sqrMagnitude;
     float y = Mathf.Sqrt(num4 - f);
     Handles.DrawWireDisc(position - (((num4 * forward) / sqrMagnitude)), forward, y);
     float num6 = f / num4;
     for (int k = 0; k < 3; k++)
     {
         if (num6 < 1f)
         {
             float b = Vector3.Angle(forward, vectorArray[k]);
             b = 90f - Mathf.Min(b, 180f - b);
             float num10 = Mathf.Tan(b * 0.01745329f);
             float num11 = Mathf.Sqrt(f + ((num10 * num10) * f)) / radius;
             if (num11 < 1f)
             {
                 float angle = Mathf.Asin(num11) * 57.29578f;
                 Vector3 from = Vector3.Cross(vectorArray[k], forward).normalized;
                 from = Quaternion.AngleAxis(angle, vectorArray[k]) * @from;
                 DrawTwoShadedWireDisc(position, vectorArray[k], from, (90f - angle) * 2f, radius);
             }
             else
             {
                 DrawTwoShadedWireDisc(position, vectorArray[k], radius);
             }
         }
         else
         {
             DrawTwoShadedWireDisc(position, vectorArray[k], radius);
         }
     }
 }
		public static void SetAudioImporterTreeD(UnityEditor.AudioImporter importer, bool p)
		{
#if UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6
			//3Dサウンドをオフに
			importer.threeD = false;
#else
#endif

		}
Ejemplo n.º 30
0
 public static bool HasModifiedProperties( UnityEditor.SerializedObject obj )
 {
     PropertyInfo pi = TargetType.GetProperty( "hasModifiedProperties",
                                               BindingFlags.NonPublic | BindingFlags.Instance );
     return (bool)pi.GetValue( obj, null );
 }
Ejemplo n.º 31
0
        internal static void StartListen()
        {
            try
            {
                Console.WriteLine("Starting TCP listener...");
                var listener = new TcpListener(IPAddress.Parse("127.0.0.1"), 6111);
                listener.Server.SetSocketOption(SocketOptionLevel.Socket, SocketOptionName.ReuseAddress, 1);
                listener.Start();

                while (true)
                {
                    IEditorHandler editor = null;

                    Socket client = listener.AcceptSocket();
                    Console.WriteLine("Connection accepted.");
                    var session = Guid.NewGuid().ToString();

                    var childSocketThread =
                        new Thread(() =>
                    {
                        try
                        {
                            var response = SocketHelper.SendMessage(client, new Dictionary <string, string> {
                                { Parameters.Method, Methods.RegisterEditor }, { Parameters.Session, session }
                            });
                            if (response.ContainsKey(Parameters.Method) && response[Parameters.Method] == Methods.RegisterEditor)
                            {
                                if (response[Parameters.Result] == EditorTypes.Unity)
                                {
                                    if (response.ContainsKey(Parameters.Session) && response[Parameters.Session] != session)
                                    {
                                        try
                                        {
                                            ConnectionManager.ReconnectEditor(client, response[Parameters.Session]);
                                        }
                                        catch (InvalidOperationException e)
                                        {
                                            Console.WriteLine(e);
                                            editor = new UnityEditor(client, response[Parameters.Session]);
                                            ConnectionManager.AddEditor(editor);
                                        }
                                    }
                                    else
                                    {
                                        editor = new UnityEditor(client, session);
                                        ConnectionManager.AddEditor(editor);
                                    }
                                }
                                else
                                {
                                    Console.WriteLine($"Unsupported editor type: {response["editortype"]}. Socket is being closed");
                                    client.Close();
                                }
                            }
                            var ping = new Dictionary <string, string> {
                                { Parameters.Method, Methods.Ping }
                            };
                            while (SocketHelper.IsSocketConnected(client))
                            {
                                var pong = SocketHelper.SendMessage(client, ping);
                                if (!pong.ContainsKey(Parameters.Method) || pong[Parameters.Method] != Methods.Ping || pong[Parameters.Result] != Methods.Pong)
                                {
                                    throw new Exception("Unexpected response from socket");
                                }

                                Thread.Sleep(3000);
                            }

                            //ConnectionManager.RemoveEditor(editor);
                            client.Close();
                            Console.WriteLine("Socket connection closed.");
                        }
                        catch (SocketException e)
                        {
                            Console.WriteLine(e);
                            //ConnectionManager.RemoveEditor(editor);
                            client.Close();
                            Console.WriteLine("Socket connection closed.");
                        }
                        catch (IOException e)
                        {
                            Console.WriteLine(e);
                            //ConnectionManager.RemoveEditor(editor);
                            client.Close();
                            Console.WriteLine("Socket connection closed.");
                        }
                        catch (NullReferenceException e)
                        {
                            Console.WriteLine(e);
                            //ConnectionManager.RemoveEditor(editor);
                            client.Close();
                            Console.WriteLine("Socket connection closed.");
                        }
                    });

                    childSocketThread.Start();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine("Error: " + e.StackTrace);
                Console.WriteLine("Error: " + e.Message);
            }
        }