/// <summary> Applies a given offset to the position of all points of a RageGroup</summary>
    private static void PointsPositionOffset(RageGroup @group, Vector3 offset, bool preserveChildPivots)
    {
        if (preserveChildPivots)
        {
            var childList = new List <Transform>();
            foreach (Transform child in group.transform)
            {
                child.parent = null;
                childList.Add(child);
            }
            group.UpdatePathList();

            foreach (var groupItem in group.List)
            {
                PointsPositionOffset(groupItem, offset);
            }

            foreach (Transform child in childList)
            {
                child.parent = group.transform;
                var offsetPos = child.transform.position + offset;
                child.transform.position = new Vector3(offsetPos.x, offsetPos.y, child.transform.position.z);
            }
            group.UpdatePathList();
            return;
        }
        foreach (var groupItem in group.List)
        {
            PointsPositionOffset(groupItem, offset);
        }

        group.UpdatePathList();
    }
Exemplo n.º 2
0
    public static List <RageMagnetPoint> GetAllMagnetPoints(RageGroup group = null)
    {
        List <RageMagnetPoint> result = new List <RageMagnetPoint>();

        Object[] magnets = FindSceneObjectsOfType(typeof(RageMagnet));
        foreach (RageMagnet magnet in magnets)
        {
            if (group != null && magnet.Group != group)
            {
                continue;
            }
            if (magnet.Points == null)
            {
                continue;
            }
            foreach (RageMagnetPoint point in magnet.Points)
            {
                if (result.Contains(point))
                {
                    continue;
                }
                if (point == null)
                {
                    continue;
                }
                result.Add(point);
            }
        }

        return(result);
    }
 public static void RageGroupApplyMaterial(RageGroup group, Material material)
 {
     foreach (var item in group.List)
     {
         item.Spline.GameObject.GetComponent <MeshRenderer>().sharedMaterial = material;
     }
 }
 public void AddExcludedGroupIfPossible(RageGroup group)
 {
     if (group.ExcludedGroups.Contains(this))
     {
         return;
     }
     ExcludedGroups.Add(group);
 }
Exemplo n.º 5
0
    private void ApplyPivotoolsBranch(RageGroup group)
    {
        var pivotools = (RagePivotools)AddComponentCheck <RagePivotools> (group.gameObject);

        pivotools.CenteringType = RagePivotools.CenteringMode.PerBranch;
        pivotools.CenterPivot();
        SmartDestroy(pivotools);
    }
    /// <summary> Applies a given offset to the position of all points of a RageGroup</summary>
    private static void PointsPositionOffset(RageGroup group, Vector3 offset)
    {
        foreach (var groupItem in group.List)
        {
            PointsPositionOffset(groupItem, offset);
        }

        group.UpdatePathList();
    }
Exemplo n.º 7
0
 /// <summary> Use this method as a callback to be fired from an animation clip or another script
 /// Setting _fadeStartTime is what makes the Update controller active </summary>
 public void Fade()
 {
     if (_group == null)
     {
         _group = GetComponent <RageGroup>();
     }
     _fadeStartTime = Time.time + Delay;
     _fadeEndTime   = _fadeStartTime + FadeDuration;
 }
Exemplo n.º 8
0
 private void CheckRageGroupAndList()
 {
     if (Group != null && Group.List != null && Group.List.Count != 0)
     {
         return;
     }
     Group = GetComponent <RageGroup>();
     Group.UpdatePathList();
 }
Exemplo n.º 9
0
 public void AddSwitchsetGroup(Switchset targetSwitchset, string groupId, RageGroup newSwitchsetGroup)
 {
     targetSwitchset.AddItem(groupId, newSwitchsetGroup);
     if (targetSwitchset.ActiveItem == "")
     {
         targetSwitchset.ActiveItem = groupId;
     }
     targetSwitchset.ResetItemsVisibility();
 }
Exemplo n.º 10
0
 private void AddReferences()
 {
     if (Group == null)
     {
         Group = gameObject.GetComponent <RageGroup>();
     }
     if (Data == null)
     {
         Data = ScriptableObject.CreateInstance <RageEdgetuneData>();
     }
 }
Exemplo n.º 11
0
 private void AddReferences()
 {
     if (Group == null)
     {
         Group = gameObject.GetComponent <RageGroup>();
     }
     if (Data == null)
     {
         Data = new RageEdgetuneData();
     }
 }
Exemplo n.º 12
0
 private RageSpline SearchCounterpart(string targetName, RageGroup sourceGroup)
 {
     foreach (RageGroupElement item in sourceGroup.List)
     {
         if (item.Spline.Rs.gameObject.name == targetName)
         {
             return(item.Spline.Rs);
         }
     }
     return(null);
 }
Exemplo n.º 13
0
    /// <summary> Finds the RageGroup if needed, then the current game object's size and z distance (if Perspective camera) </summary>
    public void Initialize()
    {
        if (Group == null)
        {
            Group = gameObject.GetComponent <RageGroup>();
        }
        UseRageCamera.Initialize();
        UpdateThreshold = UseRageCamera.UpdateThreshold;

        _lastObjectHeight = StartObjectHeight = gameObject.transform.lossyScale.y;;
        _lastZoffset      = StartCameraDistance = OffsetFromCamera();
    }
 private bool CheckGroup()
 {
     if (_group != null)
     {
         return(true);
     }
     _group = FindParentRageGroup(gameObject);
     if (_group != null)
     {
         return(true);
     }
     return(false);
 }
 private static bool HasSplineAndGroup(GameObject gameObject)
 {
     _refSpline = gameObject.GetComponent <RageSpline>();
     if (_refSpline == null)
     {
         return(false);
     }
     _group = gameObject.FindParentRageGroup();
     if (_group == null)
     {
         return(false);
     }
     return(true);
 }
Exemplo n.º 16
0
 /// <summary> Tries to find a group in the Game gO and updates its list if found</summary>
 public bool FindRageGroup()
 {
     if (Group == null)
     {
         Group = GetComponent <RageGroup>();
     }
     if (Group == null)
     {
         Debug.Log("Error: No group found. Aborting.");
         return(false);
     }
     Group.UpdatePathList();
     return(true);
 }
Exemplo n.º 17
0
    private void OffsetUVs(RageGroup sourceGroup, RageGroup targetGroup)
    {
        foreach (RageGroupElement item in targetGroup.List)
        {
            var matchingSpline = SearchCounterpart(item.Spline.Rs.gameObject.name, sourceGroup);
            if (matchingSpline == null)
            {
                continue;
            }
            var sourceOffset = matchingSpline.GetTextureOffset();

            //Debug.Log ("Target: "+item.Spline.Rs.name + " , Source: " + matchingSpline.name);
            item.Spline.Rs.SetTextureOffset(sourceOffset);
            item.Spline.Rs.RefreshMesh();
        }
    }
Exemplo n.º 18
0
 public static void RageLayerGroupOffset(RageGroup group, int offset)
 {
     foreach (var item in group.List)
     {
         var layer = item.Spline.GameObject.GetComponent <RageLayer>();
         if (layer != null)
         {
             layer.OffsetMaterialRenderQueue(offset);
         }
     }
             #if UNITY_EDITOR
     if (!EditorApplication.isPlaying)
     {
         Debug.LogWarning("* Multiple Materials Created. Ignore above error messages.");
     }
             #endif
 }
    /// <summary> Fit the Texture scale and offset of all group elements to the group boundaries </summary>
    /// <param name="group"> Group to be processed </param>
    public void RageGroupUvFit(RageGroup group)
    {
        UpdateCenter();

        var min = group.Boundaries[0];
        var max = group.Boundaries[1];

        foreach (var item in group.List)
        {
            var offset = group.Center - item.Spline.Rs.gameObject.transform.position;
            item.Spline.Rs.SetTextureOffset(offset);
            item.Spline.Rs.SetTextureOffset2(offset);
            var textureScale = 1 / (new Vector2(0, max.y) - new Vector2(0, min.y)).magnitude;
            item.Spline.Rs.SetTextureScaleInv(textureScale);
            item.Spline.Rs.SetTextureScale2Inv(textureScale);
            item.Spline.Rs.SetTextureAngleDeg(0f);
            item.Spline.Rs.SetTextureAngle2Deg(0f);
            item.Spline.Rs.RefreshMeshInEditor(true, true, true);
        }
    }
Exemplo n.º 20
0
    /// <summary> Finds (or add if needed) the source and Target groups, fits UVs to both the copies from source to Target UVs
    /// </summary>
    public void Process( )
    {
        if (SourceObject == null || TargetObject == null)
        {
            Debug.Log("Macro error: Both Source and Target gO fields must be filled in. Aborting.");
            return;
        }
        RageGroup sourceGroup = SourceObject.GetComponent <RageGroup>();
        RageGroup targetGroup = TargetObject.GetComponent <RageGroup>();

        if (sourceGroup == null)
        {
            sourceGroup = AddGroups ? SourceObject.AddComponent <RageGroup>() : null;
        }
        if (targetGroup == null)
        {
            targetGroup = AddGroups ? TargetObject.AddComponent <RageGroup>() : null;
        }
        if (sourceGroup == null || targetGroup == null)
        {
            Debug.Log("Macro error: One or both groups missing, aborting.");
            return;
        }
        sourceGroup.UvFit(); targetGroup.UvFit();
        if (NameCleanup)
        {
            sourceGroup.CleanupExtensions(); targetGroup.CleanupExtensions();
        }
        if (PivotoolsBranch)
        {
            ApplyPivotoolsBranch(sourceGroup); ApplyPivotoolsBranch(targetGroup);
        }
        sourceGroup.UpdatePathList(); targetGroup.UpdatePathList();
        OffsetUVs(sourceGroup, targetGroup);
        if (TempGroups)
        {
            SmartDestroy(sourceGroup);
            SmartDestroy(targetGroup);
        }
    }
Exemplo n.º 21
0
 public void AddItem(string groupId, RageGroup newSwitchsetGroup)
 {
     Items.Add(groupId, newSwitchsetGroup);
     ItemKeys.Add(groupId);
     ItemValues.Add(newSwitchsetGroup);
 }
Exemplo n.º 22
0
 public void AttachedComponentsCheck()
 {
     FollowerGroup  = _follower.GetComponent <RageGroup>();
     FollowerSpline = _follower.GetComponent <RageSpline>();
     _edgetune      = Follower.GetComponent <RageEdgetune>();
 }
Exemplo n.º 23
0
 public void Awake()
 {
     _group = GetComponent <RageGroup>();
 }