Beispiel #1
0
    public void DrawCustomInspector()
    {
        if (PrefabUtility.GetPrefabParent(Selection.activeObject) != null)
        {
            return;
        }
        EditorGUILayout.BeginHorizontal("Box");
        GUIStyle lab = new GUIStyle();

        lab.richText = true;
        GUILayout.Label("Attachments are added to tiles when drawing", lab);

        EditorGUILayout.EndHorizontal();
        Tile2DAttachment myTarget = (Tile2DAttachment)target;

        myTarget.aIndex = EditorGUILayout.Popup("Attach to Tile", myTarget.aIndex, aOptions);

        if (GUI.changed && myTarget.aIndex > 0)
        {
            myTarget.replaceTile = aOptions[myTarget.aIndex];
            EditorUtility.SetDirty(myTarget);
        }
    }
Beispiel #2
0
    public void AddAttachment()
    {
        GameObject g = FindAttachment();

        if (g == null)
        {
            if (currentAttachment)
            {
                cacheRenderer.enabled = true;
                DestroyImmediate(currentAttachment.gameObject);
            }
            return;
        }
        if (currentAttachment)
        {
            DestroyImmediate(currentAttachment.gameObject);
        }
        GameObject ng = null;

#if UNITY_EDITOR
        ng = (GameObject)PrefabUtility.InstantiatePrefab(g);
#endif
        if (Application.isPlaying)
        {
            ng = (GameObject)Instantiate(g, transform.position, transform.rotation);
        }

        ng.transform.parent        = transform;
        ng.transform.localPosition = Vector3.zero;
        currentAttachment          = ng.GetComponent <Tile2DAttachment>();
        if (currentAttachment.replaceSprite)
        {
            cacheRenderer.enabled = false;
        }
        SortAttachment();
    }
Beispiel #3
0
	public void AddAttachment() {
		GameObject g = FindAttachment();
		if (g == null) {
			if (currentAttachment) {
				cacheRenderer.enabled = true;
				DestroyImmediate(currentAttachment.gameObject);
			}
			return;
		}
		if (currentAttachment) DestroyImmediate(currentAttachment.gameObject);
		GameObject ng = null;

#if UNITY_EDITOR
		ng = (GameObject)PrefabUtility.InstantiatePrefab(g);
#endif
		if (Application.isPlaying)
			ng = (GameObject)Instantiate(g, transform.position, transform.rotation);

		ng.transform.parent = transform;
		ng.transform.localPosition = Vector3.zero;
		currentAttachment = ng.GetComponent<Tile2DAttachment>();
		if (currentAttachment.replaceSprite) cacheRenderer.enabled = false;
		SortAttachment();
	}