Example #1
0
    /// <summary>
    /// Remove a JelloAttachPoint from this JelloBody.
    /// </summary>
    /// <param name="attachPoint">The JelloAttachPoint to remove.</param>
    public void RemoveAttachPoint(JelloAttachPoint attachPoint)
    {
        List<JelloAttachPoint> tempAttachPoints = new List<JelloAttachPoint>();
        for(int i = 0; i < mAttachPoints.Length; i++)
            if(attachPoint != mAttachPoints[i])
                tempAttachPoints.Add (mAttachPoints[i]);

        mAttachPoints = tempAttachPoints.ToArray();
    }
Example #2
0
    //TODO make alternative method sigantures.
    /// <summary>
    /// Add a JelloAttachPoint to this JelloBody.
    /// </summary>
    /// <param name="attachPoint">The JelloAttachPoint to add.</param>
    public void AddAttachPoint(JelloAttachPoint attachPoint)
    {
        if(mAttachPoints == null)
            mAttachPoints = new JelloAttachPoint[0];

        for(int i = 0; i < mAttachPoints.Length; i++)//dont add the same point twice.
        {
            if(mAttachPoints[i] == attachPoint)
                return;
        }

        JelloAttachPoint[] oldPoints = mAttachPoints;
        mAttachPoints = new JelloAttachPoint[mAttachPoints.Length + 1];
        for(int i =0; i < oldPoints.Length; i++)
        {
            mAttachPoints[i] = oldPoints[i];
        }
        mAttachPoints[mAttachPoints.Length - 1] = attachPoint;
    }
	public virtual void DrawEditAttachPointGUI()
	{
		SerializedProperty eAttachPoint = eAttachPoints.GetArrayElementAtIndex(editIndex);
		SerializedProperty eAttachedTransform = eAttachPoint.FindPropertyRelative("mAttachedTransform");
		SerializedProperty eRotate = eAttachPoint.FindPropertyRelative("rotate");
		SerializedProperty eAngle = eAttachPoint.FindPropertyRelative("transformAngle");
		SerializedProperty eIndices = eAttachPoint.FindPropertyRelative("affectedIndices");

		JelloAttachPoint attachPoint = body.GetAttachPoint(editIndex); 

		EditorGUILayout.PropertyField(eAttachedTransform, new GUIContent("Attached Transform"));//TODO move guicontents to top.

		if(eAttachedTransform.objectReferenceValue != null)
		{
			EditorGUI.indentLevel++;

			EditorGUILayout.PropertyField(eRotate, new GUIContent("Rotate"));

			if(eRotate.boolValue)
				EditorGUILayout.PropertyField(eAngle, new GUIContent("Angle"));

			EditorGUI.indentLevel--;
		}

		GUIStyle positionStyle = new GUIStyle(EditorStyles.label);
		if(eAttachPoint.FindPropertyRelative("point").prefabOverride)
		{
			//positionStyle = new GUIStyle(EditorStyles.boldLabel);
			positionStyle.fontStyle = FontStyle.Bold;
		}
		EditorGUILayout.LabelField("Local Position", handlePositions[0].ToString(), positionStyle);

		string contents = "";
		for(int i = 0; i < eIndices.arraySize; i++)
			contents += eIndices.GetArrayElementAtIndex(i).intValue.ToString() + ", ";

		EditorGUI.indentLevel++;
		EditorGUILayout.BeginHorizontal();
		GUIContent addLegContent = new GUIContent("+");
		GUIContent removeLegContent = new GUIContent("-");

		GUIStyle indicesStyle = new GUIStyle(EditorStyles.label);
		if(eIndices.prefabOverride)
		{
			//indicesStyle = new GUIStyle(EditorStyles.boldLabel);
			indicesStyle.fontStyle = FontStyle.Bold;
		}
		EditorGUILayout.LabelField("Indices", contents, indicesStyle);

		if(GUILayout.Button(removeLegContent) && attachPoint.affectedIndices.Length > 1)
		{
			attachPoint.Rebuild(attachPoint.point, attachPoint.body, true, attachPoint.affectedIndices.Length - 1);

			EditorUtility.SetDirty(body);

			SetEditIndex(editIndex);

			SceneView.RepaintAll();
		}
		if(GUILayout.Button(addLegContent) && attachPoint.affectedIndices.Length < 3)
		{
			attachPoint.Rebuild(attachPoint.point, attachPoint.body, true, attachPoint.affectedIndices.Length + 1);

			EditorUtility.SetDirty(body);
	
			SetEditIndex(editIndex);

			SceneView.RepaintAll();
		}

		EditorGUILayout.EndHorizontal();
		EditorGUI.indentLevel--;
	}