Inheritance: Object
Ejemplo n.º 1
1
	public override void OnGUI(Object actionObj)
	{
		StateChangeAction action = actionObj as StateChangeAction;
		if (action == null) { GUILayout.Label("Error: Delete this Action."); return; }

		EditorGUILayout.BeginHorizontal();
		{
			action.setState = (0 == EditorGUILayout.Popup((action.setState ? 0 : 1), options));
			UniRPGEdGui.TargetTypeField(this.ed, "on", action.subject, TargetTypeHelp);
			GUILayout.FlexibleSpace();
		}
		EditorGUILayout.EndHorizontal();
		GUILayout.Space(15);

		scroll = UniRPGEdGui.BeginScrollView(scroll, UniRPGEdGui.ScrollViewNoTLMarginStyle, GUILayout.Height(200));
		for (int i = 0; i < UniRPGEditorGlobal.DB.states.Count; i++)
		{
			if (UniRPGEdGui.ToggleButton(UniRPGEditorGlobal.DB.states[i] == action.state, UniRPGEditorGlobal.DB.states[i].screenName, EditorStyles.miniButton, UniRPGEdGui.ButtonOnColor, GUILayout.Width(270)))
			{
				action.state = UniRPGEditorGlobal.DB.states[i];
			}
		}
		UniRPGEdGui.EndScrollView();
		showAcceptButton = (action.state != null);
	}
Ejemplo n.º 2
0
	    void OnGUI()
	    {
			GUILayout.Label("UMA Slot Builder");
			GUILayout.Space(20);
			normalReferenceMesh = EditorGUILayout.ObjectField("Seams Mesh (Optional)", normalReferenceMesh, typeof(SkinnedMeshRenderer), false) as SkinnedMeshRenderer;
	        slotMesh = EditorGUILayout.ObjectField("Slot Mesh", slotMesh, typeof(SkinnedMeshRenderer), false) as SkinnedMeshRenderer;
			slotMaterial = EditorGUILayout.ObjectField("UMAMaterial", slotMaterial, typeof(UMAMaterial), false) as UMAMaterial;
	        slotFolder = EditorGUILayout.ObjectField("Slot Destination Folder", slotFolder, typeof(UnityEngine.Object), false) as UnityEngine.Object;
			EnforceFolder(ref slotFolder);
			slotName = EditorGUILayout.TextField("Element Name", slotName);
			
	        if (GUILayout.Button("Create Slot"))
	        {
	            Debug.Log("Processing...");
	            if (CreateSlot() != null)
	            {
	                Debug.Log("Success.");
	            }
	        }
	      
	        GUILayout.Label("", EditorStyles.boldLabel);
	        Rect dropArea = GUILayoutUtility.GetRect(0.0f, 50.0f, GUILayout.ExpandWidth(true));
	        GUI.Box(dropArea, "Drag meshes here");
	        GUILayout.Label("Automatic Drag and Drop processing", EditorStyles.boldLabel);
	        relativeFolder = EditorGUILayout.ObjectField("Relative Folder", relativeFolder, typeof(UnityEngine.Object), false) as UnityEngine.Object;
	        EnforceFolder(ref relativeFolder);

	        DropAreaGUI(dropArea);
	    }
Ejemplo n.º 3
0
		public Link this[Object obj]
		{
			get
			{
				return Links.FirstOrDefault(link => link.InstanceTarget == obj);
			}
		}
Ejemplo n.º 4
0
        /// <summary>
        /// Since all of the tree displays use the selection change, I decided to implement it in superclass
        /// </summary>
        internal void ProcessSelectionChange()
        {
            //Debug.Log("ProcessSelectionChange: " + Selection.activeObject);
            if (null == Selection.activeGameObject)
                return;

            GameObject go = Selection.activeGameObject;

            /*if (null == go)
                throw new Exception("Couldn't get the selection");*/

            Adapter = go.GetComponent(typeof(ComponentAdapter)) as ComponentAdapter;
            if (null == Adapter)
            {
                /**
                 * Not a GUI component
                 * S hould do cleanup and handle selection (deselect basically)
                 * */
                GroupAdapter = null;
                //HandleSelectionChange();
                return;
            }
            Target = Adapter;
            GroupAdapter = Target as GroupAdapter;
            
            HandleSelectionChange();
        }
Ejemplo n.º 5
0
	public override string ActionShortNfo(Object actionObj)
	{
		DebugLogAction action = actionObj as DebugLogAction;
		if (action == null) return "!ERROR!";
		if (action.inclNum) return string.Format("Debug: {0} ({1})", action.text.GetValOrName(), action.num.GetValOrName());
		else return string.Format("Debug: {0}", action.text.GetValOrName());
	}
Ejemplo n.º 6
0
	public override string ActionShortNfo(Object actionObj)
	{
		StateChangeAction action = actionObj as StateChangeAction;
		if (action == null) return "!ERROR!";
		if (action.state) return string.Format("{0} State ({1}) on {2}", (action.setState ? "Set" : "Clear"), action.state.screenName, action.subject.type);
		else return string.Format("Set/Clear State (!ERROR!) on {0}", action.subject.type);
	}
 public bool Matches(Object item)
 {
     if (mInvert)
         return Matches(mRoot, item, mType);
     else
         return Matches(item, mRoot, mType);
 }
Ejemplo n.º 8
0
 public void Register( Object owner, Action action )
 {
     actionList.AddLast( new EventSubscriber {
         action = action,
         owner = owner
     } );
 }
Ejemplo n.º 9
0
		public override void OnInteraction (Object actor) {
			if (this.lightShip != null) {
				if (this.lightShipSeat != null) {
					(actor as Humanoid).TakeControl (this.lightShip, this.lightShipSeat);
				}
			}
		}
 public override void Initialize(Object[] targets)
 {
   base.Initialize(targets);
   this.GetNetworkInformation(this.target as NetworkManager);
   this.m_ShowServerMessagesLabel = new GUIContent("Server Message Handlers:", "Registered network message handler functions");
   this.m_ShowClientMessagesLabel = new GUIContent("Client Message Handlers:", "Registered network message handler functions");
 }
Ejemplo n.º 11
0
	public override string ActionShortNfo(Object actionObj)
	{
		SkillChangeAction action = actionObj as SkillChangeAction;
		if (action == null) return "!ERROR!";
		if (action.skillPrefab) return string.Format("{0} Skill ({1}) on {2}", (action.addSkill ? "Add" : "Remove"), action.skillName, action.subject.type);
		else return string.Format("Add/Remove Skill (!ERROR!) on {0}", action.subject.type);
	}
Ejemplo n.º 12
0
        /// <summary>
        /// Gets the asset path of a object.
        /// </summary>
        /// <returns>The asset path.</returns>
        /// <param name="obj">Object.</param>
        public static string GetAssetPath(Object obj)
        {
            if (obj == null)
                return string.Empty;

            return AssetDatabase.GetAssetPath(obj);
        }
Ejemplo n.º 13
0
	public override void OnGUI(Object actionObj)
	{
		LoadSceneAction action = actionObj as LoadSceneAction;
		if (action == null) { GUILayout.Label("Error: Delete this Action."); return; }

		EditorGUILayout.BeginHorizontal();
		{
			GUILayout.Label("Load");
			EditorGUILayout.Space();
			EditorGUILayout.BeginVertical();
			{
				action.loadBy = EditorGUILayout.Popup(action.loadBy, options);
				if (action.loadBy == 0)
				{
					action.gameSceneIdx = EditorGUILayout.Popup(action.gameSceneIdx, UniRPGEditorGlobal.DB.gameSceneNames.ToArray());
					UniRPGEdGui.LookLikeControls();
					action.num = UniRPGEdGui.GlobalNumericVarOrValueField(this.ed, "SpawnPoint Ident", action.num, 120);
					EditorGUILayout.Space();
					EditorGUILayout.HelpBox("The 'SpawnPoint Ident' is the unique identifier number you entered for the SpawnPoint. Leave this at (-1) if you want UniRPG to use the first available Player Spawn point or use the world center.", MessageType.Info);
				}
				else if (action.loadBy == 1)
				{
					// no options
				}
				else if (action.loadBy == 2)
				{
					action.sceneName = UniRPGEdGui.GlobalStringVarOrValueField(this.ed, null, action.sceneName);
				}
			}
			EditorGUILayout.EndVertical();
		}
		EditorGUILayout.EndHorizontal();
	}
Ejemplo n.º 14
0
	public override string ActionShortNfo(Object actionObj)
	{
		SoundAction action = actionObj as SoundAction;
		if (action.doWhat == 0) return "Start Sound or Music";
		if (action.doWhat == 1) return "Play Target Sound";
		return "Stop Target Sound";
	}
        private VariantReference(System.Runtime.Serialization.SerializationInfo info, System.Runtime.Serialization.StreamingContext context)
        {
            _valueReference = null;
            _unityObjectReference = null;

            _type = (VariantType)info.GetInt32("type");
            switch (_type)
            {
                case VariantType.Object:
                case VariantType.GameObject:
                case VariantType.Component:
                    //do nothing
                    break;
                case VariantType.Vector2:
                case VariantType.Vector3:
                case VariantType.Quaternion:
                case VariantType.Color:
                    var arr = StringUtil.SplitFixedLength(info.GetString("vector"), ",", 4);
                    //_vectorStore = new Vector4(ConvertUtil.ToSingle(arr[0]),
                    //                           ConvertUtil.ToSingle(arr[1]),
                    //                           ConvertUtil.ToSingle(arr[2]),
                    //                           ConvertUtil.ToSingle(arr[3]));
                    break;
                default:
                    _valueReference = info.GetString("value");
                    break;
            }
            (this as ISerializationCallbackReceiver).OnAfterDeserialize();
        }
Ejemplo n.º 16
0
 public static GenericDisplayedBioBrick Create(
   Transform parentTransform
   ,Vector3 localPosition
   ,string spriteName
   ,BioBrick biobrick
   ,Object externalPrefab = null
   )
 {

    string usedSpriteName = ((spriteName!=null)&&(spriteName!=""))?spriteName:getSpriteName(biobrick);
    string nullSpriteName = ((spriteName!=null)&&(spriteName!=""))?"":"(null)=>"+usedSpriteName;

    if(genericPrefab == null) genericPrefab = Resources.Load(prefabURI);
    Object prefabToUse = (externalPrefab==null)?genericPrefab:externalPrefab;

    Logger.Log("GenericDisplayedBioBrick::Create(parentTransform="+parentTransform
      + ", localPosition="+localPosition
      + ", spriteName="+spriteName+nullSpriteName
      + ", biobrick="+biobrick
      , Logger.Level.TRACE
      );

    GenericDisplayedBioBrick result = (GenericDisplayedBioBrick)DisplayedElement.Create(
      parentTransform
      ,localPosition
      ,usedSpriteName
      ,prefabToUse
      );

    Initialize(result, biobrick);

    return result;
 }
		public override void Reset() {
			
			base.Reset();

			this.tempObject = null;
			
		}
		public override void Validate(Object item) {
			
			base.Validate(item);

			if (item == null) {
				
				if (this.tempObject != null) {
					
					item = this.tempObject;
					
				}

				if (item == null) return;
				
			}
			
			var tempSprite = item as Sprite;
			
			if (tempSprite != null) {
				
				var imp = UnityEditor.TextureImporter.GetAtPath(this.assetPath) as UnityEditor.TextureImporter;
				this.multiObjects = false;
				if (imp != null && imp.spriteImportMode == UnityEditor.SpriteImportMode.Multiple) {

					var allObjects = Resources.LoadAll(this.resourcesPath);
					this.multiObjects = true;
					this.objectIndex = System.Array.IndexOf(allObjects, item);
					
				}
				
			}

			this.tempObject = item;

		}
Ejemplo n.º 19
0
		public static void Assert(bool condition, string message, Object context=null)
		{
			if (!condition)
			{
				LogError("Assert failed", message, context);
			}
		}
Ejemplo n.º 20
0
 IEnumerator Startfight()
 {
     vague1terminée = false;
     vague2terminée = false;
     vague3terminée = false;
     System.Random ran = new System.Random();
     yield return new WaitForSeconds(3);
     ennemi1vague1 = Instantiate(Squelette, listpositionspawn[ran.Next(listpositionspawn.Count)].position, listpositionspawn[ran.Next(listpositionspawn.Count)].rotation);
     ennemi2vague1 = Instantiate(Squelette, listpositionspawn[ran.Next(listpositionspawn.Count)].position, listpositionspawn[ran.Next(listpositionspawn.Count)].rotation);
     ennemi3vague1 = Instantiate(Croco, listpositionspawn[ran.Next(listpositionspawn.Count)].position, listpositionspawn[ran.Next(listpositionspawn.Count)].rotation);
     ennemi4vague1 = Instantiate(Mob, listpositionspawn[ran.Next(listpositionspawn.Count)].position, listpositionspawn[ran.Next(listpositionspawn.Count)].rotation);
     while (ennemi1vague1 != null || ennemi2vague1 != null || ennemi3vague1 != null || ennemi4vague1 != null)
     { yield return new WaitForSeconds(1); }
     vague1terminée = true;
     ennemi1vague2 = Instantiate(Troll, listpositionspawn[ran.Next(listpositionspawn.Count)].position, listpositionspawn[ran.Next(listpositionspawn.Count)].rotation);
     while (ennemi1vague2 != null)
     { yield return new WaitForSeconds(1); }
     vague2terminée = true;
     ennemi1vague3 = Instantiate(Troll, listpositionspawn[ran.Next(listpositionspawn.Count)].position, listpositionspawn[ran.Next(listpositionspawn.Count)].rotation);
     ennemi2vague3 = Instantiate(Squelette, listpositionspawn[ran.Next(listpositionspawn.Count)].position, listpositionspawn[ran.Next(listpositionspawn.Count)].rotation);
     ennemi3vague3 = Instantiate(Squelette, listpositionspawn[ran.Next(listpositionspawn.Count)].position, listpositionspawn[ran.Next(listpositionspawn.Count)].rotation);
     while (ennemi1vague3 != null || ennemi2vague3 != null || ennemi3vague3 != null)
     { yield return new WaitForSeconds(1); }
     vague3terminée = true;
     StartCoroutine(over());
 }
Ejemplo n.º 21
0
 /// <summary>
 ///   <para>Builds the combined navmesh for the contents of multiple scenes.</para>
 /// </summary>
 /// <param name="paths">Array of paths to scenes that are used for building the navmesh.</param>
 public static void BuildNavMeshForMultipleScenes(string[] paths)
 {
   if (paths.Length == 0)
     return;
   for (int index1 = 0; index1 < paths.Length; ++index1)
   {
     for (int index2 = index1 + 1; index2 < paths.Length; ++index2)
     {
       if (paths[index1] == paths[index2])
         throw new Exception("No duplicate scene names are allowed");
     }
   }
   if (!EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo())
     return;
   if (!EditorSceneManager.OpenScene(paths[0]).IsValid())
     throw new Exception("Could not open scene: " + paths[0]);
   for (int index = 1; index < paths.Length; ++index)
     EditorSceneManager.OpenScene(paths[index], OpenSceneMode.Additive);
   NavMeshBuilder.BuildNavMesh();
   UnityEngine.Object sceneNavMeshData = NavMeshBuilder.sceneNavMeshData;
   for (int index = 0; index < paths.Length; ++index)
   {
     if (EditorSceneManager.OpenScene(paths[index]).IsValid())
     {
       NavMeshBuilder.sceneNavMeshData = sceneNavMeshData;
       EditorSceneManager.SaveScene(SceneManager.GetActiveScene());
     }
   }
 }
Ejemplo n.º 22
0
		/// <summary>
		/// Helper function so we can disable logging
		/// </summary>
		public static void LogPerf( Object context, string message, params object[] parms )
		{
#if UNITY_EDITOR
			if ( AmsPreferences.PerfLogging )
#endif
				Debug.LogFormat( context, "Ams Perf: " + message, parms );
		}
		public UniqueObject( Object obj )
		{
#if USE_STRONG_EDITOR_REFS
			editorLocalId = 0;
#endif

			scene = new AmsSceneReference();
			fullPath = string.Empty;
			componentName = string.Empty;
			version = CurrentSerializedVersion;
			componentIndex = 0;

			if ( !obj )
				return;

			GameObject gameObject = GameObjectEx.EditorGetGameObjectFromComponent( obj );
			if ( gameObject )
			{
				scene = new AmsSceneReference( gameObject.scene );
				fullPath = gameObject.GetFullName();

				Component comp = obj as Component;
				if ( comp )
				{
					componentName = obj.GetType().AssemblyQualifiedName;
					gameObject.GetComponents( obj.GetType(), _reusableComponentsList );
					componentIndex = _reusableComponentsList.IndexOf( comp );
				}
			}

#if USE_STRONG_EDITOR_REFS
			editorLocalId = GetEditorId( obj );
#endif
		}
Ejemplo n.º 24
0
		public static void RegisterCreatedObjectUndo(Object obj, string msg)
		{
			#if PB_DEBUG
			Debug.Log("RegisterCreatedObjectUndo()  ->  " + msg);
			#endif
			Undo.RegisterCreatedObjectUndo(obj, msg);
		}
Ejemplo n.º 25
0
 public override UnityObject Object(GUIContent content, UnityObject value, System.Type type, bool allowSceneObjects, Layout option)
 {
     // If we pass an empty content, ObjectField will still reserve space for an empty label ~__~
     return string.IsNullOrEmpty(content.text) ?
         EditorGUILayout.ObjectField(value, type, allowSceneObjects, option) :
         EditorGUILayout.ObjectField(content, value, type, allowSceneObjects, option);
 }
Ejemplo n.º 26
0
		/**
		 * Undo.RegisterCompleteObjectUndo
		 */
		public static void RegisterCompleteObjectUndo(Object[] objs, string msg)
		{
			#if PB_DEBUG
			Debug.Log("RegisterCompleteObjectUndo()  ->  " + msg);
			#endif
			Undo.RegisterCompleteObjectUndo(objs, msg);
		}
Ejemplo n.º 27
0
		/**
		 * Record object prior to deletion.
		 */
		public static void DestroyImmediate(Object obj, string msg)
		{
			#if PB_DEBUG
			Debug.Log("DestroyImmediate()  ->  " + msg);
			#endif
			Undo.DestroyObjectImmediate(obj);
		}
Ejemplo n.º 28
0
        public static bool CopyAndRenameAsset(Object obj, string newName, string newFolderPath)
        {
            #if UNITY_EDITOR
            string path = newFolderPath;

            if(path[path.Length - 1] != '/')
                path += "/";
            string testPath = path.Remove(path.Length - 1);

            //			if(AssetDatabase.IsValidFolder(testPath) == false)
            //			{
            //				Debug.LogError("This folder does not exist " + testPath);
            //				return false;
            //			}

            string assetPath =  AssetDatabase.GetAssetPath(obj);
            string fileName = GetFileName(assetPath);
            string extension = fileName.Remove(0, fileName.LastIndexOf('.'));

            string newFileName = path + newName + extension;

            if(System.IO.File.Exists(newFileName))
                return false;

            return AssetDatabase.CopyAsset(assetPath, newFileName);
            #else
            return false;

            #endif
        }
Ejemplo n.º 29
0
		/**
		 * Record an object for Undo.
		 */
		public static void RecordObject(Object obj, string msg)
		{
			#if PB_DEBUG
			Debug.Log("RecordObject()  ->  " + msg);
			#endif
			Undo.RecordObject(obj, msg);
		}
Ejemplo n.º 30
0
	public override string ActionShortNfo(Object actionObj)
	{
		SendMessageAction action = actionObj as SendMessageAction;
		if (action == null) return "!ERROR!";
		if (action.sendToTaggedObjects) return string.Format("SendMessage ({0}) to all with tag: {1}", action.functionName, action.tagToUse);
		else return string.Format("SendMessage ({0}) to: {1}", action.functionName, action.subject);
	}
 extern public static string GetAssetOrScenePath(Object assetObject);
Ejemplo n.º 32
0
 public void Dispose()
 {
     StatService.Get().Increase(StatService.StatName.IN_POOL_GO, -m_cached.Count);
     m_cached.Clear();
     Object.Destroy(PoolNode.gameObject);
 }
Ejemplo n.º 33
0
 /// <summary>
 /// Import settings from another plugin. You need to override this method to enable this functionality in your plugin
 /// </summary>
 /// <param name="pluginToImport">The sent UnityEngine.Object. Your plugin script should first check that this plugin is the correct type</param>
 /// <returns>True if the settings imported successfully</returns>
 public virtual bool ImportSettings(UnityEngine.Object pluginToImport, int importMethod)
 {
     Debug.LogWarning("Import Settings was not implimented for this plugin");
     return(false);
 }
Ejemplo n.º 34
0
    public CylinderLedMatrix(CylinderLeqSeq ledseq)
        : base(ledseq)
    {
        float height        = ledseq.height;
        int   floorCounter  = ledseq.floorCounter;
        int   roundsCounter = ledseq.roundsCounter;

        GameObject l = GameObject.Find("plight");

        UnityEngine.Object o = null;
        o       = Resources.Load("sampleled");
        thecube = (GameObject)GameObject.Instantiate(o, Vector3.zero, Quaternion.identity);
        Material themat = new Material(thecube.GetComponent <MeshRenderer>().material);

        themat.color = new Color(1, 1, 1, 1);

        Material transmat = (Material)Resources.Load("transmat", typeof(Material));

        transmat.color = new Color(143f / 255f, 143f / 255f, 143f / 255f, 50 / 255f);

        Vector3 pillarScale  = new Vector3(1f, height * floorCounter * 1f / 2, 1f);
        Vector3 pillarCenter = new Vector3(0f, height * floorCounter * 1f / 2, 0f) + origin;

        pillar      = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
        pillar.name = "pillar";
        pillar.transform.localScale = pillarScale + new Vector3(4f, 0, 4f);
        pillar.transform.position   = pillarCenter;
        pillar.GetComponent <MeshRenderer>().material = new Material(Shader.Find("Diffuse"));

        top      = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
        top.name = "top";
        top.transform.localScale = new Vector3(ledseq.radius * 2.2f, 2f, ledseq.radius * 2.2f);
        top.transform.position   = new Vector3(0, height * floorCounter * 1f, 0f) + origin;
        top.GetComponent <MeshRenderer>().material = new Material(Shader.Find("Diffuse"));

        Vector3[][] positions = ledseq.positions;
        pillars = new GameObject[roundsCounter][];
        parent  = new GameObject("CubeLedPillar");

        for (int i = 0; i < roundsCounter; i++)
        {
            int counter = positions[i].Length;

            pillars[i] = new GameObject[counter];
            for (int j = 0; j < counter; j++)
            {
                pillars[i][j] = GameObject.CreatePrimitive(PrimitiveType.Cylinder);
                pillars[i][j].transform.localScale = pillarScale;
                pillars[i][j].transform.position   = positions[i][j] + pillarCenter;
                pillars[i][j].GetComponent <MeshRenderer>().material = new Material(transmat);
                pillars[i][j].transform.parent = parent.transform;
            }
        }

        bounds = new Bounds(positions[0][0] + origin, new Vector3());

        parent   = new GameObject("CylinderLedMatrix");
        ledcubes = new GameObject[TOTAL];
        ledmats  = new Material[TOTAL];
        GameObject go     = null;
        int        len    = 0;
        int        ledidx = 0;

        for (int i = 0; i < floorCounter; i++)
        {
            for (int j = 0; j < roundsCounter; j++)
            {
                len = positions[j].Length;
                for (int k = 0; k < len; k++)
                {
                    ledidx = ledseq.getLedIdx(i, j, k);
                    go     = GameObject.CreatePrimitive(PrimitiveType.Cube);

                    go.transform.parent   = parent.transform;
                    go.transform.position = positions[j][k] + new Vector3(0, height * i, 0f) + origin;
                    ledcubes[ledidx]      = go;
                    ledmats[ledidx]       = go.GetComponent <MeshRenderer>().material = new Material(themat);
                    ledmats[ledidx].SetVector("_MKGlowColor", new Vector4(1f, 1f, 1f, 1f));

                    bounds.Encapsulate(go.transform.position);

                    if (reflect)
                    {
                        GameObject ll = GameObject.Instantiate(l);
                        ll.transform.position = go.transform.position;
                        ll.transform.parent   = go.transform;
                    }
                }
            }
        }
    }
Ejemplo n.º 35
0
 public void TearDown()
 {
     Object.DestroyImmediate(m_Root.gameObject);
 }
Ejemplo n.º 36
0
        /************************************************************************************************************************/

        /// <summary>Calls <see cref="EditorUtility.NaturalCompare"/> on the <see cref="Object.name"/>s.</summary>
        public static int NaturalCompare(Object a, Object b) => EditorUtility.NaturalCompare(a.name, b.name);
Ejemplo n.º 37
0
        internal LoadedAvatar(string fullPath, GameObject avatarGameObject, ILoggerProvider loggerProvider, IKHelper ikHelper, DiContainer container)
        {
            this.fullPath = fullPath ?? throw new ArgumentNullException(nameof(fullPath));
            prefab        = avatarGameObject ? avatarGameObject : throw new ArgumentNullException(nameof(avatarGameObject));
            descriptor    = avatarGameObject.GetComponent <AvatarDescriptor>() ?? throw new AvatarLoadException($"Avatar at '{fullPath}' does not have an AvatarDescriptor");

            fileName = Path.GetFileName(fullPath);

            prefab.name = $"LoadedAvatar({descriptor.name})";

            _logger = loggerProvider.CreateLogger <LoadedAvatar>(descriptor.name);

            #pragma warning disable CS0618
            VRIKManager vrikManager = prefab.GetComponentInChildren <VRIKManager>();
            IKManager   ikManager   = prefab.GetComponentInChildren <IKManager>();
            #pragma warning restore CS0618

            // migrate IKManager/IKManagerAdvanced to VRIKManager
            if (ikManager)
            {
                if (!vrikManager)
                {
                    vrikManager = container.InstantiateComponent <VRIKManager>(prefab);
                }

                _logger.Warning("IKManager and IKManagerAdvanced are deprecated; please migrate to VRIKManager");

                ApplyIKManagerFields(vrikManager, ikManager);
                Object.Destroy(ikManager);
            }

            if (vrikManager)
            {
                if (!vrikManager.areReferencesFilled)
                {
                    _logger.Warning($"References are not filled on '{vrikManager.name}'; detecting references automatically");
                    vrikManager.AutoDetectReferences();
                }
            }

            // remove any existing VRIK instances
            foreach (VRIK existingVrik in prefab.GetComponentsInChildren <VRIK>())
            {
                _logger.Warning($"Found VRIK on '{existingVrik.name}'; manually adding VRIK to an avatar is no longer needed, please remove it");

                if (existingVrik && vrikManager && existingVrik.references.isFilled && !vrikManager.areReferencesFilled)
                {
                    _logger.Warning($"Copying references from VRIK on '{existingVrik.name}'; this is deprecated behaviour and will be removed in a future release");
                    CopyReferencesFromExistingVrik(vrikManager, existingVrik.references);
                }

                Object.Destroy(existingVrik);
            }

            if (vrikManager)
            {
                ikHelper.CreateOffsetTargetsIfMissing(vrikManager, prefab.transform);
            }

            head      = prefab.transform.Find("Head");
            leftHand  = prefab.transform.Find("LeftHand");
            rightHand = prefab.transform.Find("RightHand");
            pelvis    = prefab.transform.Find("Pelvis");
            leftLeg   = prefab.transform.Find("LeftLeg");
            rightLeg  = prefab.transform.Find("RightLeg");

            if (vrikManager)
            {
                if (vrikManager.references_root != vrikManager.transform)
                {
                    _logger.Warning("VRIKManager is not on the root reference transform; this may cause unexpected issues");
                }

                CheckTargetWeight("Left Arm", leftHand, vrikManager.solver_leftArm_positionWeight, vrikManager.solver_leftArm_rotationWeight);
                CheckTargetWeight("Right Arm", rightHand, vrikManager.solver_rightArm_positionWeight, vrikManager.solver_rightArm_rotationWeight);
                CheckTargetWeight("Pelvis", pelvis, vrikManager.solver_spine_pelvisPositionWeight, vrikManager.solver_spine_pelvisRotationWeight);
                CheckTargetWeight("Left Leg", leftLeg, vrikManager.solver_leftLeg_positionWeight, vrikManager.solver_leftLeg_rotationWeight);
                CheckTargetWeight("Right Leg", rightLeg, vrikManager.solver_rightLeg_positionWeight, vrikManager.solver_rightLeg_rotationWeight);

                FixTrackingReferences(vrikManager);
            }

            if (prefab.transform.localPosition.sqrMagnitude > 0)
            {
                _logger.Warning("Avatar root position is not at origin; this may cause unexpected issues");
            }

            var poseManager = prefab.GetComponentInChildren <PoseManager>();

            isIKAvatar             = vrikManager;
            supportsFingerTracking = poseManager && poseManager.isValid;

            eyeHeight = GetEyeHeight();
            armSpan   = GetArmSpan(vrikManager);
        }
Ejemplo n.º 38
0
 public void Dispose()
 {
     Object.Destroy(prefab);
 }
Ejemplo n.º 39
0
 public override void OnObjectDropped(UnityEngine.Object obj)
 {
     SetupFromObject(obj);
 }
Ejemplo n.º 40
0
        private static void GenerateInputScreenUI()
        {
            GameObject canvas      = SingletonBehaviour <CanvasSpawner> .Instance.CanvasGO;
            GameObject menuBuilder = CreateMenu(new MenuBuilder("DVMultiplayer InputMenu", "Input", 975, 672.6f, false, false));

            menuBuilder.AddComponent <InputScreen>();

            CreateSection(new Rect(0f, -177, 925, 91.14999f), RectTransformAnchoring.TopCenter, menuBuilder.transform);
            CreateLabel("Input", "", menuBuilder.transform, new Rect(32, -215, 861, 76), FontStyles.Normal, TextAlignmentOptions.MidlineLeft, RectTransformAnchoring.TopLeft, new Vector2(0f, 0f));

            char[] row = new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-' };
            for (int i = 0; i < row.Length; i++)
            {
                char          key         = row[i];
                ButtonBuilder builder     = new ButtonBuilder($"Key {key}", $"{key}", menuBuilder.transform, new Rect(925 - (80 * 11) + (80 * i), -300, 75, 75), RectTransformAnchoring.TopLeft, new Vector2(0f, 0f), TextAlignmentOptions.Center);
                GameObject    keyInputBtn = CreateButton(builder);
                InputButton   btn         = keyInputBtn.AddComponent <InputButton>();
                btn.key = key;
            }

            row = new char[] { 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p' };
            for (int i = 0; i < row.Length; i++)
            {
                char          key         = row[i];
                ButtonBuilder builder     = new ButtonBuilder($"Key {key}", $"{key}", menuBuilder.transform, new Rect(925 - (80 * 10.5f) + (80 * i), -380, 75, 75), RectTransformAnchoring.TopLeft, new Vector2(0f, 0f), TextAlignmentOptions.Center);
                GameObject    keyInputBtn = CreateButton(builder);
                InputButton   btn         = keyInputBtn.AddComponent <InputButton>();
                btn.key = key;
            }

            row = new char[] { 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l' };
            for (int i = 0; i < row.Length; i++)
            {
                char          key         = row[i];
                ButtonBuilder builder     = new ButtonBuilder($"Key {key}", $"{key}", menuBuilder.transform, new Rect(925 - (80 * 10) + (80 * i), -460, 75, 75), RectTransformAnchoring.TopLeft, new Vector2(0f, 0f), TextAlignmentOptions.Center);
                GameObject    keyInputBtn = CreateButton(builder);
                InputButton   btn         = keyInputBtn.AddComponent <InputButton>();
                btn.key = key;
            }

            row = new char[] { 'z', 'x', 'c', 'v', 'b', 'n', 'm', '.' };
            for (int i = 0; i < row.Length; i++)
            {
                char          key         = row[i];
                ButtonBuilder builder     = new ButtonBuilder($"Key {key}", $"{key}", menuBuilder.transform, new Rect(925 - (80 * 9.5f) + (80 * i), -540, 75, 75), RectTransformAnchoring.TopLeft, new Vector2(0f, 0f), TextAlignmentOptions.Center);
                GameObject    keyInputBtn = CreateButton(builder);
                InputButton   btn         = keyInputBtn.AddComponent <InputButton>();
                btn.key = key;
            }

            ButtonBuilder builderBtn   = new ButtonBuilder($"Backspace", $"Backspace", menuBuilder.transform, new Rect(925 - (80 * 9f) - 60, -620, 180, 75), RectTransformAnchoring.TopLeft, new Vector2(0f, 0f), TextAlignmentOptions.Center);
            GameObject    backspaceBtn = CreateButton(builderBtn);
            InputButton   inputbtn     = backspaceBtn.AddComponent <InputButton>();

            inputbtn.isBackspace = true;

            builderBtn = new ButtonBuilder($"Paste", $"Paste", menuBuilder.transform, new Rect(925 - (80 * 9f) + 125, -620, 150, 75), RectTransformAnchoring.TopLeft, new Vector2(0f, 0f), TextAlignmentOptions.Center);
            GameObject  pasteBtn      = CreateButton(builderBtn);
            InputButton inputPastebtn = pasteBtn.AddComponent <InputButton>();

            inputPastebtn.isPaste = true;

            builderBtn = new ButtonBuilder($"Casing", $"Uppercase", menuBuilder.transform, new Rect(925 - (80 * 9f) + 280, -620, 180, 75), RectTransformAnchoring.TopLeft, new Vector2(0f, 0f), TextAlignmentOptions.Center);
            CreateButton(builderBtn);

            builderBtn = new ButtonBuilder($"Confirm", $"Confirm", menuBuilder.transform, new Rect(925 - (80 * 9f) + 465, -620, 150, 75), RectTransformAnchoring.TopLeft, new Vector2(0f, 0f), TextAlignmentOptions.Center);
            CreateButton(builderBtn);

            GameObject menu = Object.Instantiate(menuBuilder, canvas.transform);

            Object.DestroyImmediate(menuBuilder);
            InputScreenUI = menu.GetComponent <MenuScreen>();
        }
Ejemplo n.º 41
0
        // shared by compute shader inspector too
        internal static void ShaderErrorListUI(Object shader, ShaderMessage[] messages, ref Vector2 scrollPosition)
        {
            int n = messages.Length;

            GUILayout.Space(kSpace);
            GUILayout.Label(string.Format("Errors ({0}):", n), EditorStyles.boldLabel);
            int   errorListID = GUIUtility.GetControlID(kErrorViewHash, FocusType.Passive);
            float height      = Mathf.Min(n * 20f + 40f, 150f);

            scrollPosition = GUILayout.BeginScrollView(scrollPosition, GUISkin.current.box, GUILayout.MinHeight(height));

            EditorGUIUtility.SetIconSize(new Vector2(16.0f, 16.0f));
            float lineHeight = Styles.messageStyle.CalcHeight(EditorGUIUtility.TempContent(Styles.errorIcon), 100);

            Event e = Event.current;

            for (int i = 0; i < n; ++i)
            {
                Rect r = EditorGUILayout.GetControlRect(false, lineHeight);

                string err      = messages[i].message;
                string plat     = messages[i].platform.ToString();
                bool   warn     = messages[i].severity != ShaderCompilerMessageSeverity.Error;
                string fileName = FileUtil.GetLastPathNameComponent(messages[i].file);
                int    line     = messages[i].line;

                // Double click opens shader file at error line
                if (e.type == EventType.MouseDown && e.button == 0 && r.Contains(e.mousePosition))
                {
                    GUIUtility.keyboardControl = errorListID;
                    if (e.clickCount == 2)
                    {
                        string filePath = messages[i].file;
                        Object asset    = string.IsNullOrEmpty(filePath) ? null : AssetDatabase.LoadMainAssetAtPath(filePath);

                        // if we don't have an asset and the filePath is an absolute path, it's an error in a system
                        // cginc - open that instead
                        if (asset == null && System.IO.Path.IsPathRooted(filePath))
                        {
                            ShaderUtil.OpenSystemShaderIncludeError(filePath, line);
                        }
                        else
                        {
                            AssetDatabase.OpenAsset(asset ?? shader, line);
                        }
                        GUIUtility.ExitGUI();
                    }
                    e.Use();
                }

                // Context menu, "Copy"
                if (e.type == EventType.ContextClick && r.Contains(e.mousePosition))
                {
                    e.Use();
                    var menu = new GenericMenu();
                    // need to copy current value to be used in delegate
                    // (C# closures close over variables, not their values)
                    var errorIndex = i;
                    menu.AddItem(EditorGUIUtility.TrTextContent("Copy error text"), false, delegate {
                        string errMsg = messages[errorIndex].message;
                        if (!string.IsNullOrEmpty(messages[errorIndex].messageDetails))
                        {
                            errMsg += '\n';
                            errMsg += messages[errorIndex].messageDetails;
                        }
                        EditorGUIUtility.systemCopyBuffer = errMsg;
                    });
                    menu.ShowAsContext();
                }

                // background
                if (e.type == EventType.Repaint)
                {
                    if ((i & 1) == 0)
                    {
                        GUIStyle st = Styles.evenBackground;
                        st.Draw(r, false, false, false, false);
                    }
                }

                // error location on the right side
                Rect locRect = r;
                locRect.xMin = locRect.xMax;
                if (line > 0)
                {
                    GUIContent gc;
                    if (string.IsNullOrEmpty(fileName))
                    {
                        gc = EditorGUIUtility.TempContent(line.ToString(CultureInfo.InvariantCulture));
                    }
                    else
                    {
                        gc = EditorGUIUtility.TempContent(fileName + ":" + line.ToString(CultureInfo.InvariantCulture));
                    }

                    // calculate size so we can right-align it
                    Vector2 size = EditorStyles.miniLabel.CalcSize(gc);
                    locRect.xMin -= size.x;
                    GUI.Label(locRect, gc, EditorStyles.miniLabel);
                    locRect.xMin -= 2;
                    // ensure some minimum width so that platform field next will line up
                    if (locRect.width < 30)
                    {
                        locRect.xMin = locRect.xMax - 30;
                    }
                }

                // platform to the left of it
                Rect platRect = locRect;
                platRect.width = 0;
                if (plat.Length > 0)
                {
                    GUIContent gc = EditorGUIUtility.TempContent(plat);
                    // calculate size so we can right-align it
                    Vector2 size = EditorStyles.miniLabel.CalcSize(gc);
                    platRect.xMin -= size.x;

                    // draw platform in dimmer color; it's often not very important information
                    Color oldColor = GUI.contentColor;
                    GUI.contentColor = new Color(1, 1, 1, 0.5f);
                    GUI.Label(platRect, gc, EditorStyles.miniLabel);
                    GUI.contentColor = oldColor;
                    platRect.xMin   -= 2;
                }

                // error message
                Rect msgRect = r;
                msgRect.xMax = platRect.xMin;
                GUI.Label(msgRect, EditorGUIUtility.TempContent(err, warn ? Styles.warningIcon : Styles.errorIcon), Styles.messageStyle);
            }
            EditorGUIUtility.SetIconSize(Vector2.zero);
            GUILayout.EndScrollView();
        }
Ejemplo n.º 42
0
 public override void SetupFromCastObject(UnityEngine.Object obj)
 {
     base.SetupFromCastObject(obj);
     SetupFromObject(obj);
 }
Ejemplo n.º 43
0
 internal int AddReference(Object o)
 {
     _references.Add(o);
     return(_references.Count - 1);
 }
Ejemplo n.º 44
0
        public bool Locate(object key, Type type, out IList <IResourceLocation> locations)
        {
            CacheKey cacheKey = new CacheKey()
            {
                m_key = key, m_type = type
            };

            if (m_Cache.TryGetValue(cacheKey, out locations))
            {
                return(locations != null);
            }

            locations = new List <IResourceLocation>();
            if (m_keyToEntries.TryGetValue(key, out List <AddressableAssetEntry> entries))
            {
                foreach (AddressableAssetEntry e in entries)
                {
                    if (AssetDatabase.IsValidFolder(e.AssetPath) && !e.labels.Contains(key as string))
                    {
                        continue;
                    }

                    if (type == null)
                    {
                        if (e.MainAssetType != typeof(SceneAsset))
                        {
                            ObjectIdentifier[] ids =
                                ContentBuildInterface.GetPlayerObjectIdentifiersInAsset(new GUID(e.guid),
                                                                                        EditorUserBuildSettings.activeBuildTarget);
                            IEnumerable <Type> subObjectTypes = AddressableAssetEntry.GatherSubObjectTypes(ids, e.guid);

                            if (subObjectTypes.Any())
                            {
                                foreach (Type t in subObjectTypes)
                                {
                                    GatherEntryLocations(e, t, locations, m_AddressableAssetTree);
                                }
                            }
                            else
                            {
                                GatherEntryLocations(e, null, locations, m_AddressableAssetTree);
                            }
                        }
                        else
                        {
                            GatherEntryLocations(e, null, locations, m_AddressableAssetTree);
                        }
                    }
                    else
                    {
                        GatherEntryLocations(e, type, locations, m_AddressableAssetTree);
                    }
                }
            }

            string keyStr = key as string;

            if (!string.IsNullOrEmpty(keyStr))
            {
                //check if the key is a guid first
                var keyPath = AssetDatabase.GUIDToAssetPath(keyStr);
                if (!string.IsNullOrEmpty(keyPath))
                {
                    //only look for folders from GUID if no locations have been found
                    if (locations.Count == 0)
                    {
                        var slash = keyPath.LastIndexOf('/');
                        while (slash > 0)
                        {
                            keyPath = keyPath.Substring(0, slash);
                            var parentFolderKey = AssetDatabase.AssetPathToGUID(keyPath);
                            if (string.IsNullOrEmpty(parentFolderKey))
                            {
                                break;
                            }

                            if (m_keyToEntries.ContainsKey(parentFolderKey))
                            {
                                locations.Add(new ResourceLocationBase(keyPath, AssetDatabase.GUIDToAssetPath(keyStr), typeof(AssetDatabaseProvider).FullName, type));
                                break;
                            }
                            slash = keyPath.LastIndexOf('/');
                        }
                    }
                }
                else
                {
                    //if the key is not a GUID, see if it is contained in a folder entry
                    keyPath = keyStr;
                    int slash = keyPath.LastIndexOf('/');
                    while (slash > 0)
                    {
                        keyPath = keyPath.Substring(0, slash);
                        if (m_keyToEntries.TryGetValue(keyPath, out var entry))
                        {
                            foreach (var e in entry)
                            {
                                var internalId = GetInternalIdFromFolderEntry(keyStr, e);
                                if (!string.IsNullOrEmpty(internalId) && !string.IsNullOrEmpty(AssetDatabase.AssetPathToGUID(internalId)))
                                {
                                    locations.Add(new ResourceLocationBase(keyStr, internalId, typeof(AssetDatabaseProvider).FullName, type));
                                }
                            }
                            break;
                        }
                        slash = keyPath.LastIndexOf('/');
                    }
                }
            }

            //check resources folders
            if (m_includeResourcesFolders)
            {
                UnityEngine.Object obj = Resources.Load(keyStr, type == null ? typeof(UnityEngine.Object) : type);
                if (obj != null)
                {
                    locations.Add(new ResourceLocationBase(keyStr, keyStr, typeof(LegacyResourcesProvider).FullName, type));
                }
            }

            if (locations.Count == 0)
            {
                locations = null;
                m_Cache.Add(cacheKey, locations);
                return(false);
            }

            m_Cache.Add(cacheKey, locations);
            return(true);
        }
 public ModelPrefabInfo GetInfo(UnityEngine.Object oj)
 {
     return(this.GetInfo(oj.name));
 }
Ejemplo n.º 46
0
 /// <inheritdoc/>
 protected override bool IsValidUnityObjectValue(Object test)
 {
     return(true);
 }
 public static bool Contains(Object obj)
 {
     return(Contains(obj.GetInstanceID()));
 }
 public static bool IsSubAsset(Object obj)
 {
     return(IsSubAsset(obj.GetInstanceID()));
 }
 public static bool TryGetGUIDAndLocalFileIdentifier(Object obj, out string guid, out long localId)
 {
     return(TryGetGUIDAndLocalFileIdentifier(obj.GetInstanceID(), out guid, out localId));
 }
 extern public static void RemoveObjectFromAsset([NotNull] Object objectToRemove);
 extern public static string[] GetLabels(Object obj);
 extern public static void ClearLabels(Object obj);
 public static bool OpenAsset(Object target, [uei.DefaultValue("-1")] int lineNumber)
 {
     return(OpenAsset(target, lineNumber, -1));
 }
 extern public static void SetLabels(Object obj, string[] labels);
Ejemplo n.º 55
0
 public static PrefabInstanceStatus GetInstanceStatus(Object componentOrGameObject)
 {
     return(PrefabUtility.GetPrefabInstanceStatus(componentOrGameObject));
 }
 [uei.ExcludeFromDocs] public static bool OpenAsset(Object target)
 {
     return(OpenAsset(target, -1));
 }
 extern static internal void AddInstanceIDToAssetWithRandomFileId(int instanceIDToAdd, Object assetObject, bool hide);
 extern private static void AddObjectToAsset_Obj([NotNull] Object newAsset, [NotNull] Object sameAssetFile);
 static public void AddObjectToAsset(Object objectToAdd, Object assetObject)
 {
     AddObjectToAsset_Obj(objectToAdd, assetObject);
 }
 extern public static void SetMainObject([NotNull] Object mainObject, string assetPath);